Skip to main content

Multi-Device Control Start Guide

This page is an implementation guide for controlling multiple MicroPeckerX units (two or more) at the same time.
The key points are to pass the Serial values obtained by MPXOpen correctly to each API and to keep the start/stop order consistent.

Scope and Prerequisites

  • Use MPXOpen(Devices, Num, Count) for device detection.
  • Each API operates a specific device by specifying Serial.
  • For log acquisition, use MPXSetGetLogMode + MPXGetLog / MPXCANGetLogEx / MPXLINGetLogEx.
  • Up to 4 devices can be recognized simultaneously by MPXOpen.

Implementation Flow (Common)

  1. Get the device list with MPXOpen.
  2. Determine roles from Devices[i].Serial (for example, Master/Slave).
  3. Set communication parameters for each device.
  4. Set log acquisition mode for each device.
  5. Execute MPXMonitorStart in Slave -> Master order.
  6. Run a log acquisition loop per device.
  7. Execute MPXMonitorStop in Master -> Slave order.
  8. Finish with MPXClose.

Important Rules (Multi-Device)

  • Start order: start the slave side first, then the master side last.
  • Stop order: stop the master side first, then the slave side last.
  • Role management: use Serial as the identifier instead of array index.

CAN/LIN Quick Difference Table

  • Communication parameter setup:
    • CAN/CAN FD: MPXCANSetParam + StMPXCANParam
    • LIN: MPXLINSetParam + StMPXLINParam
  • Channel specification:
    • CAN/CAN FD: InnerCh=1/2
    • LIN: no InnerCh in MPXLINSetParam
  • Log acquisition:
    • CAN/CAN FD: MPXCANGetLogEx + StMPXCANLog
    • LIN: MPXLINGetLogEx + StMPXLINLog

Communication Parameter Setup Examples

// CAN/CAN FD: configure both CH1 and CH2
StMPXCANParam p1 = {};
StMPXCANParam p2 = {};
p1.EnableTerminate = MPX_CAN_TERMINATE_ENABLE;
p1.Mode = MPX_CAN_MODE_MONITOR; // CH1 runs in monitor mode
p1.ArbitrationBaudrate = MPX_CAN_PARAM_ABR_500K;
p1.ArbitrationSamplepoint = MPX_CAN_PARAM_SP_80P;
p1.DataBaudrate = MPX_CAN_PARAM_DBR_2M;
p1.DataSamplepoint = MPX_CAN_PARAM_SP_80P;
p2 = p1;
p2.Mode = MPX_CAN_MODE_NONE; // CH2 disabled

MPXCANSetParam(serialSlave, 1, &p1);
MPXCANSetParam(serialSlave, 2, &p2);
MPXCANSetParam(serialMaster, 1, &p1);
MPXCANSetParam(serialMaster, 2, &p2);

MPXSetGetLogMode(serialSlave, 1, MPX_GETLOGMODE_GETLOGAPI);
MPXSetGetLogMode(serialMaster, 1, MPX_GETLOGMODE_GETLOGAPI);

C/C++ Full Implementation Example (Key Points)

MPXMonitorStart(serialSlave, MPX_SYNC_SLAVE);
MPXMonitorStart(serialMaster, MPX_SYNC_MASTER);

StMPXCANLog logMaster[256] = {};
StMPXCANLog logSlave[256] = {};
unsigned short cntMaster = 0;
unsigned short cntSlave = 0;
unsigned char ovMaster = 0;
unsigned char ovSlave = 0;

for (;;) {
MPXCANGetLogEx(serialMaster, 1, logMaster, 256, &cntMaster, &ovMaster);
MPXCANGetLogEx(serialSlave, 1, logSlave, 256, &cntSlave, &ovSlave);
Sleep(1);
}

unsigned long ms = 0;
unsigned short us = 0;
MPXMonitorStop(serialMaster, &ms, &us);
MPXMonitorStop(serialSlave, &ms, &us);
MPXClose();

C# (P/Invoke) Implementation Example (Key Points)

var p1 = new StMPXCANParam();
var p2 = new StMPXCANParam();

MPXCANSetParam(serialSlave, 1, ref p1);
MPXCANSetParam(serialSlave, 2, ref p2);
MPXCANSetParam(serialMaster, 1, ref p1);
MPXCANSetParam(serialMaster, 2, ref p2);

Excel VBA Implementation Example (Key Points)

Ret = MPXCANSetParam(SerialSlave, 1, Param1)
Ret = MPXCANSetParam(SerialSlave, 2, Param2)
Ret = MPXCANSetParam(SerialMaster, 1, Param1)
Ret = MPXCANSetParam(SerialMaster, 2, Param2)

Common Mistakes

  • Treating devices[0] as Master unconditionally (detection order is not fixed)
  • Not passing the array size to Num in MPXOpen
  • Accessing devices[1] without checking Count
  • Reversing start/stop order for multi-device operation
  • Not setting both InnerCh=1/2 for CAN
  • Calling MPXLINSetParam with 3 arguments for LIN