S810-MX-ADL1N からの移行ガイド(CAN/CAN FD)
本ページは、S810-MX-ADL1N(旧)から S810-MX-ADL2N(新)へ移行する際の実装差分を、既存コードの置換観点で整理したガイドです。
対象は CAN/CAN FD です。
関連リンク
- 移行時の問題切り分け: よくある問題と対処
- 他製品からの移行: SDK2N からの移行, SDK3N からの移行
移行の全体像
ADL1N から ADL2N の移行で、実装に影響するポイントは次の5点です。
- DLL名の変更(
MPXCANFDCtrlFree*->MPXCtrlFree*) MPXOpenの引数変更(Num追加)- CAN API名の変更(
MPXSetCANParamなど ->MPXCAN*) - 一部定数名の変更(
MPX_MODE_*、CAN_ERR*) MPXGetLogの引数型変更(StMPXCANLog**->StMPXLog**)
先に確認する移行前提
- 旧DLL:
MPXCANFDCtrlFree.DLL/MPXCANFDCtrlFree_x64.DLL - 新DLL:
MPXCtrlFree.DLL/MPXCtrlFree_x64.DLL InnerChは従来どおり対象CHを指定(1または2)
API仕様差分(旧->新)
共通API
| ADL1N | ADL2N | 互換性影響 |
|---|---|---|
MPXGetAPIVersion(StMPXAPIVersion*) | 同じ | 変更なし |
MPXOpen(StMPXDeviceInfo* Devices, unsigned char* Count) | MPXOpen(StMPXDeviceInfo* Devices, unsigned char Num, unsigned char* Count) | Num 引数追加 |
MPXClose() | 同じ | 変更なし |
MPXSetLED(...) | 同じ | 変更なし |
MPXGetStatus(...) | 同じ | 変更なし |
MPXMonitorStart(...) | 同じ | 変更なし |
MPXMonitorStop(...) | 同じ | 変更なし |
MPXGetTimeStamp(...) | 同じ | 変更なし |
MPXSetLogCallBack(...) | 同じ | 変更なし |
MPXSetGetLogMode(...) | 同じ | 変更なし |
MPXGetLog(unsigned long, unsigned char, StMPXCANLog**, unsigned short*, unsigned char*) | MPXGetLog(unsigned long, unsigned char, StMPXLog**, unsigned short*, unsigned char*) | 第3引数型変更 |
CAN/CAN FD API
| ADL1N | ADL2N | 互換性影響 |
|---|---|---|
MPXSetCANParam | MPXCANSetParam | API名変更 |
MPXGetLogEx | MPXCANGetLogEx | API名変更 |
MPXSetSlot | MPXCANSetSlot | API名変更 |
MPXChangeSlot | MPXCANChangeSlot | API名変更 |
MPXSendSlot | MPXCANSendSlot | API名変更 |
MPXDirectSend | MPXCANDirectSend | API名変更 |
定数・構造体の移行ポイント
動作モード定数(名称変更)
| ADL1N | ADL2N | 値 |
|---|---|---|
MPX_MODE_LISTEN | MPX_CAN_MODE_LISTEN | 0 |
MPX_MODE_MONITOR | MPX_CAN_MODE_MONITOR | 1 |
MPX_MODE_CAN_SIM | MPX_CAN_MODE_SIM | 2 |
MPX_MODE_NONE | MPX_CAN_MODE_NONE | 0xFF |
値は同じですが、旧定数名は ADL2N ヘッダに存在しません。
CANエラー定数(名称変更)
エラーフラグ
| ADL1N | ADL2N | 値 |
|---|---|---|
CAN_ERRFLG_FALSE | MPX_CAN_ERRFLG_FALSE | 0 |
CAN_ERRFLG_TRUE | MPX_CAN_ERRFLG_TRUE | 1 |
エラー詳細
| ADL1N | ADL2N | 値 |
|---|---|---|
CAN_ERR_NONE | MPX_CAN_ERR_NONE | 0x0000 |
CAN_ERR_BUS | MPX_CAN_ERR_BUS | 0x0001 |
CAN_ERR_WARN | MPX_CAN_ERR_WARN | 0x0002 |
CAN_ERR_PASV | MPX_CAN_ERR_PASV | 0x0004 |
CAN_ERR_BUSOFF | MPX_CAN_ERR_BUSOFF | 0x0008 |
CAN_ERR_BUSWAKE | MPX_CAN_ERR_BUSWAKE | 0x0010 |
CAN_ERR_OVERLOAD | MPX_CAN_ERR_OVERLOAD | 0x0020 |
CAN_ERR_BUSLOCK | MPX_CAN_ERR_BUSLOCK | 0x0040 |
CAN_ERR_ARBLOST | MPX_CAN_ERR_ARBLOST | 0x0080 |
CAN_ERR_STAFF | MPX_CAN_ERR_STAFF | 0x0100 |
CAN_ERR_FORM | MPX_CAN_ERR_FORM | 0x0200 |
CAN_ERR_ACK | MPX_CAN_ERR_ACK | 0x0400 |
CAN_ERR_CRC | MPX_CAN_ERR_CRC | 0x0800 |
CAN_ERR_RECEIVE | MPX_CAN_ERR_RECEIVE | 0x1000 |
CAN_ERR_DOMINANT | MPX_CAN_ERR_DOMINANT | 0x2000 |
CAN_ERR_DELIMITER | MPX_CAN_ERR_DELIMITER | 0x4000 |
変更なしの主要定数
以下は ADL1N と 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構造体の互換性
CAN関連構造体は ADL1N と ADL2N で互換です(名称・レイアウトとも同一)。
StMPXCANParamStMPXCANIDStMPXCANFrameOptionStMPXCANFrameTypeStMPXCANFrameStMPXCANSlotStMPXCANDirectStMPXCANLog
MPXGetLog の型変更
MPXGetLog は関数名が同じでも、受け取り型が変わっています。
- ADL1N:
StMPXCANLog** - ADL2N:
StMPXLog**
移行時は次のいずれかで対応してください。
MPXCANGetLogExへ統一する(推奨)MPXGetLogを継続利用し、StMPXLogからMisc.CANを参照する
戻り値(ER)差分
ERコードは ADL1N と ADL2N で同一です。
| 定数 | 値 |
|---|---|
E_OK | 0 |
E_PARAM | 1 |
E_DEVICE | 2 |
E_COMM | 3 |
E_TGT | 4 |
E_TRG_BUSY | 11 |
E_DCT_FULL | 12 |
E_STATUS | 105 |
E_TIMEOUT | 202 |
E_OTHER | 255 |
実装手順(既存アプリ置換フロー)
- DLL参照名を
MPXCANFDCtrlFree*からMPXCtrlFree*へ変更 MPXOpen呼び出しを3引数版へ修正- CAN API名を
MPXCAN*へ置換 MPX_MODE_*とCAN_ERR*を新定数へ置換- ログ取得を
MPXCANGetLogEx中心に統一(またはMPXGetLog型変更対応)
言語別 置換例
C/C++ 置換例
// 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, ¶m);
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, ¶m);
er = MPXCANGetLogEx(serial, innerCh, logs, num, &got, &over);
C/C++ CAN/CAN FDシミュレーション置換例
// ADL1N
param.Mode = MPX_MODE_CAN_SIM;
MPXSetCANParam(serial, innerCh, ¶m);
MPXSetSlot(serial, innerCh, slots, 2);
MPXMonitorStart(serial, MPX_SYNC_MASTER);
// ADL2N
param.Mode = MPX_CAN_MODE_SIM;
MPXCANSetParam(serial, innerCh, ¶m);
MPXCANSetSlot(serial, innerCh, slots, 2);
MPXMonitorStart(serial, MPX_SYNC_MASTER);
C#(P/Invoke)置換例
[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シミュレーション置換例
// 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 置換例(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シミュレーション置換例
' 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)
差分の大きいAPIの置換指針
MPXGetLog 継続利用時の注意
ADL2Nの MPXGetLog は StMPXLog** を返します。
CANログへアクセスする場合は Misc.CAN を参照してください。
ログ取得は MPXCANGetLogEx への統一を推奨
既存の MPXGetLogEx 利用コードは、API名置換のみで移行できるため、MPXCANGetLogEx への統一が最も安全です。
移行チェックリスト
- DLL名を
MPXCANFDCtrlFree*からMPXCtrlFree*に変更した -
MPXOpenを3引数版へ修正した -
MPXSetCANParamなどCAN APIをMPXCAN*へ置換した -
MPX_MODE_*をMPX_CAN_MODE_*へ置換した -
CAN_ERR*/CAN_ERRFLG_*をMPX_CAN_ERR*/MPX_CAN_ERRFLG_*へ置換した -
MPXGetLogExをMPXCANGetLogExへ置換した -
MPXGetLogを使う場合はStMPXLog**へ型変更した - 置換後に Open/Param/Monitor/Slot/GetLog の基本動作を確認した
関連ページ
- 共通 API 一覧: /S810-MX-ADL2N/3.00/Common/api_list_common
- 共通 API 詳細: /S810-MX-ADL2N/3.00/Common/api_detail_common
- CAN API 一覧: /S810-MX-ADL2N/3.00/CAN/api_list_can
- CAN API 詳細: /S810-MX-ADL2N/3.00/CAN/api_detail_can
- CAN 構造体定義: /S810-MX-ADL2N/3.00/CAN/struct_can