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)
- Get the device list with
MPXOpen. - Determine roles from
Devices[i].Serial(for example, Master/Slave). - Set communication parameters for each device.
- Set log acquisition mode for each device.
- Execute
MPXMonitorStartin Slave -> Master order. - Run a log acquisition loop per device.
- Execute
MPXMonitorStopin Master -> Slave order. - 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
Serialas the identifier instead of array index.
CAN/LIN Quick Difference Table
- Communication parameter setup:
- CAN/CAN FD:
MPXCANSetParam+StMPXCANParam - LIN:
MPXLINSetParam+StMPXLINParam
- CAN/CAN FD:
- Channel specification:
- CAN/CAN FD:
InnerCh=1/2 - LIN: no
InnerChinMPXLINSetParam
- CAN/CAN FD:
- Log acquisition:
- CAN/CAN FD:
MPXCANGetLogEx+StMPXCANLog - LIN:
MPXLINGetLogEx+StMPXLINLog
- CAN/CAN FD:
Communication Parameter Setup Examples
- CAN/CAN FD (2ch required)
- LIN
// 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);
// LIN: MPXLINSetParam takes 2 arguments (Serial, Param)
StMPXLINParam p = {};
p.Mode = MPX_LIN_MODE_MONITOR;
p.Revision = MPX_LIN_REV_21;
p.Baudrate = 19200;
MPXLINSetParam(serialSlave, &p);
MPXLINSetParam(serialMaster, &p);
MPXSetGetLogMode(serialSlave, MPX_INNERCH_LIN, MPX_GETLOGMODE_GETLOGAPI);
MPXSetGetLogMode(serialMaster, MPX_INNERCH_LIN, MPX_GETLOGMODE_GETLOGAPI);
C/C++ Full Implementation Example (Key Points)
- CAN/CAN FD (2ch required)
- LIN
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();
MPXMonitorStart(serialSlave, MPX_SYNC_SLAVE);
MPXMonitorStart(serialMaster, MPX_SYNC_MASTER);
StMPXLINLog logMaster[256] = {};
StMPXLINLog logSlave[256] = {};
unsigned short cntMaster = 0;
unsigned short cntSlave = 0;
unsigned char ovMaster = 0;
unsigned char ovSlave = 0;
for (;;) {
MPXLINGetLogEx(serialMaster, logMaster, 256, &cntMaster, &ovMaster);
MPXLINGetLogEx(serialSlave, logSlave, 256, &cntSlave, &ovSlave);
Sleep(1);
}
C# (P/Invoke) Implementation Example (Key Points)
- CAN/CAN FD (2ch required)
- LIN
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);
var lp = new StMPXLINParam();
MPXLINSetParam(serialSlave, ref lp);
MPXLINSetParam(serialMaster, ref lp);
Excel VBA Implementation Example (Key Points)
- CAN/CAN FD (2ch required)
- LIN
Ret = MPXCANSetParam(SerialSlave, 1, Param1)
Ret = MPXCANSetParam(SerialSlave, 2, Param2)
Ret = MPXCANSetParam(SerialMaster, 1, Param1)
Ret = MPXCANSetParam(SerialMaster, 2, Param2)
Ret = MPXLINSetParam(SerialSlave, LinParam)
Ret = MPXLINSetParam(SerialMaster, LinParam)
Common Mistakes
- Treating
devices[0]as Master unconditionally (detection order is not fixed) - Not passing the array size to
NuminMPXOpen - Accessing
devices[1]without checkingCount - Reversing start/stop order for multi-device operation
- Not setting both
InnerCh=1/2for CAN - Calling
MPXLINSetParamwith 3 arguments for LIN
Related Pages
- Basic flow: /S810-MX-ADL2N/QuickStart/common_first
- Common API details: /S810-MX-ADL2N/Common/api_detail_common
- CAN API details: /S810-MX-ADL2N/CAN/api_detail_can
- LIN API details: /S810-MX-ADL2N/LIN/api_detail_lin