When using multiple devices at the same time, it is necessary to initialize each device and obtain a different ID.
Execute functions by specifying the ID of each device. At the time of termination, perform termination processings for each device.
Here is an example of using multiple devices.
Use two CAN-4P-PE and one CAN-4PF-PE, and each device is set to the following device name.
The variables that store the ID of each device are ID_CAN1, ID_CAN2, and ID_CANFD1
CAN-4P-PE 1st : CAN000
CAN-4P-PE 2nd : CAN001
CAN-4PF-PE : CAN002
Example in C
Device |
CAN-4P-PE 1st |
CAN-4P-PE 2nd |
CAN-4PF-PE |
DeviceName |
CAN000 |
CAN001 |
CAN002 |
ID Declaration |
short ID_CAN1; |
short ID_CAN2; |
short ID_CAN2WF; |
Init |
Ret = CanInit("CAN000" ,&ID_CAN1); |
Ret = CanInit("CAN001" ,&ID_CAN2) |
Ret = CanInit("CAN002" ,&ID_CANFD1); |
Other Functions |
Ret = Can***( ID_CAN1, *** ); |
Ret = Can***( ID_CAN2, *** ); |
Ret = Can***( ID_CANFD1, *** ); |
Example in Python
Device |
CAN-4P-PE 1st |
CAN-4P-PE 2nd |
CAN-4PF-PE |
DeviceName |
CAN000 |
CAN001 |
CAN002 |
ID Declaration |
ID_CAN1 = ctypes.c_short() |
ID_CAN2 = ctypes.c_short() |
ID_CAN2WF = ctypes.c_short() |
Init |
Ret.value = ccan.CanInit ( b"CAN000" , ctypes.byref(ID_CAN1)) |
Ret.value = ccan.CanInit ( b"CAN001" , ctypes.byref(ID_CAN2)) |
Ret.value = ccan.CanInit( b"CAN002" , ctypes.byre(ID_CANFD1)) |
Other Functions |
Ret.value = ccan.Can***( ID_CAN1, *** ) |
Ret.value = ccan.Can***( ID_CAN2, *** ) |
Ret.value = ccan.Can***( ID_CANFD1, *** ) |