Set the CAN FD communication timing.
Ret = CanSetCanFdTiming ( Id , ChannelNo , ArbBitrate , ArbTSeg1 , ArbSJW , ArbTSeg2 , DataBitrate , DataSeg1 , DataSJW , DataSeg2 )
Id
[ C: short ] [ Python: ctypes.c_short ]
Specify the device ID retrieved from CanInit.
ChannelNo
[ C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the channel number.
ArbBitrate
[ C: unsigned int ] [ Python: ctypes.c_uint ]
Specify the arbitration bitrate.
The setting range is 60000 to 1000000. The unit is bps. (bit per second)
ArbTSeg1 [
C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the arbitration time segment 1.
The setting range is 2 to 513. The unit is TQ.
ArbSJW [
C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the arbitration SJW.
The setting range is 1 to 127. Also, make sure it is equal to or less than arbitration time segment 2 (ArbTSeg2).
The unit is TQ.
ArbTSeg2 [
C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the arbitration time segment 2.
The setting range is 1 to 128. Also, make sure it is equal to or less than arbitration time segment 1 (ArbTSeg1).
The unit is TQ.
DataBitrate
[ C: unsigned int ] [ Python: ctypes.c_uint ]
Specify the data bitrate.
The setting range is 60000 to 5000000. The unit is bps. (bit per second)
DataTSeg1 [
C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the data time segment 1.
The setting range is 2 to 257. The unit is TQ.
DataSJW [
C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the data SJW. (Synchronization Jump Width)
The setting range is 1 to 127. Also, make sure it is equal to or less than data time segment 2 (DataTSeg2).
The unit is TQ.
DataTSeg2 [
C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the data time segment 2.
The setting range is 1 to 128. Also, make sure it is equal to or less than data time segment 1 (DataTSeg1).
The unit is TQ.
Ret [ C: long ] [ Python: ctypes.c_long ]
Definition |
Value |
Description |
CAN_ERR_SUCCESS |
0 |
Normality completion |
CAN_ERR_DLL_INVALID_ID |
10001 |
Invalid ID specified. |
CAN_ERR_DLL_CALL_DRIVER |
10002 |
Driver can't be called (Failed in the ioctl). |
CAN_ERR_SYS_CH_NO |
20101 |
Channel number is outside the settable range |
CAN_ERR_SYS_ARB_TSEG1 |
20131 |
Arbitration time segment 1 is outside the settable range. |
CAN_ERR_SYS_ARB_SJW |
20132 |
Arbitration Synchronization Jump Width is outside the settable range. |
CAN_ERR_SYS_ARB_TSEG2 |
20133 |
Arbitration time segment 2 is outside the settable range. |
CAN_ERR_SYS_DATA_TSEG1 |
20141 |
Data time segment 1 is outside the settable range. |
CAN_ERR_SYS_DATA_SJW |
20142 |
Data Synchronization Jump Width is outside the settable range. |
CAN_ERR_SYS_DATA_TSEG2 |
20143 |
Data time segment 2 is outside the settable range. |
CAN_ERR_SYS_TIMING_COMBINATION |
20144 |
This is a combination in which the communication parameters cannot be set. |
CAN_ERR_SYS_BUSON |
20200 |
Cannot execute because the bus is on. |
The others (See also: Details of Error Code)
None
Set the CAN FD communication timing.
Setting is possible only when the CAN bus is not connected.
It depends on the combination of the CAN communication clock installed in the device and the prescaler to divide this clock.
Therefore, there are restrictions on the combinations of arbitration bitrate, ArbTSeg1, ArbTSeg2, ArbSJW that can be set on the device, and if it is not possible to set it, it will be corrected to a similar value.
CanGetCanFdTimingUse the function to ensure that the bitrate and sample point ratio are the desired values.
It is easy to check using the CAN communication sample program
For details, please refer to Difference between CAN 2.0B Communication and CAN FD Communication
and CAN communication transmission time.
Set ArbBitrate = 1000000 bps, ArbTSeg1 = 100TQ, ArbSJW = 60TQ, ArbTSeg2 = 60TQ, DataBitrate = 1000000 bps, DataTSeg1 = 50TQ, DataSJW = 30TQ, DataTSeg2 = 30TQ to ChannelNo = 1.
C |
long Ret; |
Python |
Ret = ctypes.c_long() Ret.value
= ccan.CanSetCanFdTiming ( Id , 1 , 1000000 , 100 , 60
, 60 , 1000000 , 50 , 30 , 30 ) |