Skip to main content

Migration Guide from S810-MX-ADL1N (CAN/CAN FD)

This page summarizes implementation differences when migrating from S810-MX-ADL1N (old) to S810-MX-ADL2N (new), focusing on code replacement.
Target protocol is CAN/CAN FD.

Migration Overview

The following five points affect implementation when migrating from ADL1N to ADL2N.

  1. DLL name changes (MPXCANFDCtrlFree* -> MPXCtrlFree*)
  2. MPXOpen argument change (Num added)
  3. CAN API name changes (MPXSetCANParam etc. -> MPXCAN*)
  4. Partial constant name changes (MPX_MODE_*, CAN_ERR*)
  5. MPXGetLog argument type change (StMPXCANLog** -> StMPXLog**)

Preconditions to Confirm First

  • Old DLL: MPXCANFDCtrlFree.DLL / MPXCANFDCtrlFree_x64.DLL
  • New DLL: MPXCtrlFree.DLL / MPXCtrlFree_x64.DLL
  • InnerCh remains the target channel number (1 or 2)

API Specification Differences (Old -> New)

Common APIs

ADL1NADL2NCompatibility Impact
MPXGetAPIVersion(StMPXAPIVersion*)SameNo change
MPXOpen(StMPXDeviceInfo* Devices, unsigned char* Count)MPXOpen(StMPXDeviceInfo* Devices, unsigned char Num, unsigned char* Count)Num argument added
MPXClose()SameNo change
MPXSetLED(...)SameNo change
MPXGetStatus(...)SameNo change
MPXMonitorStart(...)SameNo change
MPXMonitorStop(...)SameNo change
MPXGetTimeStamp(...)SameNo change
MPXSetLogCallBack(...)SameNo change
MPXSetGetLogMode(...)SameNo change
MPXGetLog(unsigned long, unsigned char, StMPXCANLog**, unsigned short*, unsigned char*)MPXGetLog(unsigned long, unsigned char, StMPXLog**, unsigned short*, unsigned char*)3rd argument type changed

CAN/CAN FD APIs

ADL1NADL2NCompatibility Impact
MPXSetCANParamMPXCANSetParamAPI name changed
MPXGetLogExMPXCANGetLogExAPI name changed
MPXSetSlotMPXCANSetSlotAPI name changed
MPXChangeSlotMPXCANChangeSlotAPI name changed
MPXSendSlotMPXCANSendSlotAPI name changed
MPXDirectSendMPXCANDirectSendAPI name changed

Constants and Structures Migration Points

Operation Mode Constants (Name Changes)

ADL1NADL2NValue
MPX_MODE_LISTENMPX_CAN_MODE_LISTEN0
MPX_MODE_MONITORMPX_CAN_MODE_MONITOR1
MPX_MODE_CAN_SIMMPX_CAN_MODE_SIM2
MPX_MODE_NONEMPX_CAN_MODE_NONE0xFF

Values are unchanged, but old constant names are not present in ADL2N headers.

CAN Error Constants (Name Changes)

Error Flags

ADL1NADL2NValue
CAN_ERRFLG_FALSEMPX_CAN_ERRFLG_FALSE0
CAN_ERRFLG_TRUEMPX_CAN_ERRFLG_TRUE1

Error Details

ADL1NADL2NValue
CAN_ERR_NONEMPX_CAN_ERR_NONE0x0000
CAN_ERR_BUSMPX_CAN_ERR_BUS0x0001
CAN_ERR_WARNMPX_CAN_ERR_WARN0x0002
CAN_ERR_PASVMPX_CAN_ERR_PASV0x0004
CAN_ERR_BUSOFFMPX_CAN_ERR_BUSOFF0x0008
CAN_ERR_BUSWAKEMPX_CAN_ERR_BUSWAKE0x0010
CAN_ERR_OVERLOADMPX_CAN_ERR_OVERLOAD0x0020
CAN_ERR_BUSLOCKMPX_CAN_ERR_BUSLOCK0x0040
CAN_ERR_ARBLOSTMPX_CAN_ERR_ARBLOST0x0080
CAN_ERR_STAFFMPX_CAN_ERR_STAFF0x0100
CAN_ERR_FORMMPX_CAN_ERR_FORM0x0200
CAN_ERR_ACKMPX_CAN_ERR_ACK0x0400
CAN_ERR_CRCMPX_CAN_ERR_CRC0x0800
CAN_ERR_RECEIVEMPX_CAN_ERR_RECEIVE0x1000
CAN_ERR_DOMINANTMPX_CAN_ERR_DOMINANT0x2000
CAN_ERR_DELIMITERMPX_CAN_ERR_DELIMITER0x4000

Major Constants with No Change

The following definitions are unchanged between ADL1N and ADL2N.

  • MPX_CAN_PARAM_ABR_*
  • MPX_CAN_PARAM_SP_*
  • MPX_CAN_PARAM_DBR_*
  • MPX_CAN_FRAME_TYPE_*
  • MPX_CAN_SLOT_*
  • MPX_CAN_PROTOCOL_*
  • MPX_CAN_BRS_*
  • MPX_CAN_IDE_*
  • MPX_CAN_RTR_*
  • MPX_CAN_SIM_INC_*

CAN Structure Compatibility

CAN-related structures are compatible between ADL1N and ADL2N (same names and layouts).

  • StMPXCANParam
  • StMPXCANID
  • StMPXCANFrameOption
  • StMPXCANFrameType
  • StMPXCANFrame
  • StMPXCANSlot
  • StMPXCANDirect
  • StMPXCANLog

MPXGetLog Type Change

MPXGetLog keeps the same function name but return pointer type changed.

  • ADL1N: StMPXCANLog**
  • ADL2N: StMPXLog**

When migrating, use one of the following.

  1. Standardize to MPXCANGetLogEx (recommended)
  2. Keep using MPXGetLog and access CAN data via Misc.CAN in StMPXLog

Return Code (ER) Differences

ER codes are the same in ADL1N and ADL2N.

ConstantValue
E_OK0
E_PARAM1
E_DEVICE2
E_COMM3
E_TGT4
E_TRG_BUSY11
E_DCT_FULL12
E_STATUS105
E_TIMEOUT202
E_OTHER255

Implementation Procedure (Replacement Flow)

  1. Replace DLL references from MPXCANFDCtrlFree* to MPXCtrlFree*
  2. Update MPXOpen calls to 3-argument version
  3. Replace CAN API names to MPXCAN*
  4. Replace MPX_MODE_* and CAN_ERR* with new constant names
  5. Standardize log acquisition to MPXCANGetLogEx (or handle MPXGetLog type change)

Language-Specific Replacement Examples

C/C++ Replacement Example

// ADL1N
StMPXDeviceInfo devs[8] = {};
unsigned char count = 0;
ER er = MPXOpen(devs, &count);
unsigned long serial = (count > 0) ? devs[0].Serial : 0;
er = MPXSetCANParam(serial, innerCh, &param);
er = MPXGetLogEx(serial, innerCh, logs, num, &got, &over);

// ADL2N
StMPXDeviceInfo devs[8] = {};
unsigned char count = 0;
ER er = MPXOpen(devs, 8, &count);
unsigned long serial = (count > 0) ? devs[0].Serial : 0;
er = MPXCANSetParam(serial, innerCh, &param);
er = MPXCANGetLogEx(serial, innerCh, logs, num, &got, &over);

C/C++ CAN/CAN FD Simulation Replacement Example

// ADL1N
param.Mode = MPX_MODE_CAN_SIM;
MPXSetCANParam(serial, innerCh, &param);
MPXSetSlot(serial, innerCh, slots, 2);
MPXMonitorStart(serial, MPX_SYNC_MASTER);

// ADL2N
param.Mode = MPX_CAN_MODE_SIM;
MPXCANSetParam(serial, innerCh, &param);
MPXCANSetSlot(serial, innerCh, slots, 2);
MPXMonitorStart(serial, MPX_SYNC_MASTER);

C# (P/Invoke) Replacement Example

[DllImport("MPXCANFDCtrlFree.dll", EntryPoint = "MPXOpen", CallingConvention = CallingConvention.StdCall)]
public static extern int MPXOpen_Adl1n(
[In, Out] StMPXDeviceInfo[] devices,
ref byte count);

[DllImport("MPXCtrlFree.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int MPXOpen(
[In, Out] StMPXDeviceInfo[] devices,
byte num,
ref byte count);

[DllImport("MPXCANFDCtrlFree.dll", EntryPoint = "MPXSetCANParam", CallingConvention = CallingConvention.StdCall)]
public static extern int MPXSetCANParam(uint serial, byte innerCh, ref StMPXCANParam param);

[DllImport("MPXCtrlFree.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int MPXCANSetParam(uint serial, byte innerCh, ref StMPXCANParam param);

[DllImport("MPXCANFDCtrlFree.dll", EntryPoint = "MPXGetLogEx", CallingConvention = CallingConvention.StdCall)]
public static extern int MPXGetLogEx(uint serial, byte innerCh, [In, Out] StMPXCANLog[] log, ushort num, ref ushort count, ref byte over);

[DllImport("MPXCtrlFree.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int MPXCANGetLogEx(uint serial, byte innerCh, [In, Out] StMPXCANLog[] log, ushort num, ref ushort count, ref byte over);

C# (P/Invoke) CAN/CAN FD Simulation Replacement Example

// ADL1N
param.Mode = MPX_MODE_CAN_SIM;
er = MPXSetCANParam(serial, innerCh, ref param);
er = MPXSetSlot(serial, innerCh, slots, (byte)slots.Length);
er = MPXMonitorStart(serial, MPX_SYNC_MASTER);

// ADL2N
param.Mode = MPX_CAN_MODE_SIM;
er = MPXCANSetParam(serial, innerCh, ref param);
er = MPXCANSetSlot(serial, innerCh, slots, (byte)slots.Length);
er = MPXMonitorStart(serial, MPX_SYNC_MASTER);

Excel VBA Replacement Example (x64)

' ADL1N
Declare PtrSafe Function MPXOpen Lib "MPXCANFDCtrlFree_x64.DLL" (ByRef Devices As StMPXDeviceInfo, ByRef Count As Byte) As Long
Declare PtrSafe Function MPXSetCANParam Lib "MPXCANFDCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByRef Param As StMPXCANParam) As Long
Declare PtrSafe Function MPXGetLogEx Lib "MPXCANFDCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByRef Log As StMPXCANLog, ByVal Num As Integer, ByRef Count As Integer, ByRef BufferOver As Byte) As Long
Declare PtrSafe Function MPXSetSlot Lib "MPXCANFDCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByRef Slots As StMPXCANSlot, ByVal SlotCount As Byte) As Long
Declare PtrSafe Function MPXChangeSlot Lib "MPXCANFDCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByVal SlotNo As Byte, ByVal SlotEnabled As Byte, ByVal ReqInfo As Byte, ByRef Frame As StMPXCANFrame) As Long
Declare PtrSafe Function MPXSendSlot Lib "MPXCANFDCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByVal SlotNo As Byte) As Long
Declare PtrSafe Function MPXDirectSend Lib "MPXCANFDCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByRef Frame As StMPXCANDirect) As Long

' ADL2N
Declare PtrSafe Function MPXOpen Lib "MPXCtrlFree_x64.DLL" (ByRef Devices As StMPXDeviceInfo, ByVal Num As Byte, ByRef Count As Byte) As Long
Declare PtrSafe Function MPXCANSetParam Lib "MPXCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByRef Param As StMPXCANParam) As Long
Declare PtrSafe Function MPXCANGetLogEx Lib "MPXCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByRef Log As StMPXCANLog, ByVal Num As Integer, ByRef Count As Integer, ByRef BufferOver As Byte) As Long
Declare PtrSafe Function MPXCANSetSlot Lib "MPXCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByRef Slots As StMPXCANSlot, ByVal SlotCount As Byte) As Long
Declare PtrSafe Function MPXCANChangeSlot Lib "MPXCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByVal SlotNo As Byte, ByVal SlotEnabled As Byte, ByVal ReqInfo As Byte, ByRef Frame As StMPXCANFrame) As Long
Declare PtrSafe Function MPXCANSendSlot Lib "MPXCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByVal SlotNo As Byte) As Long
Declare PtrSafe Function MPXCANDirectSend Lib "MPXCtrlFree_x64.DLL" (ByVal Serial As Long, ByVal InnerCh As Byte, ByRef Frame As StMPXCANDirect) As Long

Excel VBA CAN/CAN FD Simulation Replacement Example

' ADL1N
Param.Mode = MPX_MODE_CAN_SIM
Ret = MPXSetCANParam(Serial, InnerCh, Param)
Ret = MPXSetSlot(Serial, InnerCh, Slots(0), 2)
Ret = MPXMonitorStart(Serial, MPX_SYNC_MASTER)

' ADL2N
Param.Mode = MPX_CAN_MODE_SIM
Ret = MPXCANSetParam(Serial, InnerCh, Param)
Ret = MPXCANSetSlot(Serial, InnerCh, Slots(0), 2)
Ret = MPXMonitorStart(Serial, MPX_SYNC_MASTER)

Replacement Guidance for APIs with Large Differences

Notes When Continuing to Use MPXGetLog

In ADL2N, MPXGetLog returns StMPXLog**.
When accessing CAN logs, refer to Misc.CAN.

Existing code using MPXGetLogEx can migrate by replacing API name only. Therefore standardizing to MPXCANGetLogEx is the safest approach.

Migration Checklist

  • DLL names changed from MPXCANFDCtrlFree* to MPXCtrlFree*
  • MPXOpen updated to 3-argument version
  • CAN APIs such as MPXSetCANParam replaced with MPXCAN*
  • MPX_MODE_* replaced with MPX_CAN_MODE_*
  • CAN_ERR* / CAN_ERRFLG_* replaced with MPX_CAN_ERR* / MPX_CAN_ERRFLG_*
  • MPXGetLogEx replaced with MPXCANGetLogEx
  • If using MPXGetLog, pointer type changed to StMPXLog**
  • Basic operation of Open/Param/Monitor/Slot/GetLog verified after replacement