Q: CAN FD communication is not possible

A:

For information about CAN FD communication, please refer to [Difference between CAN 2.0B Communication and CAN FD Communication].

①For CAN FD communication, different values can be specified for the bit rate setting for the Arbitration Field and the bit rate setting for the Data Field.
   In this case, the MessageType parameter of the CanTransmit function requires a CAN FD message (CCAN_MSG_TYPE_CAN_FD) and a bit rate switch (CCAN_MSG_TYPE_BITRATE_SWITCH).

②Please set the bit rate settings and sampling points for the Arbitration Field and Data Field on the same CAN path to the same settings on the transmitting device and the receiving device.
   For settings, use the CanSetCanFdTiming function.

   Also, to check the setting values, use the CanGetCanFdTiming function.
   For details, please refer to the Function Reference for each function.

 

Example of CAN transmission when the bit rate values of the arbitration filed and the data filed are different :

CAN FD transmission from CAN device ChannelNo = 1.
MessageNum =1, CAN ID = 0x11c, DataLength = 1, Data = 0xff

C

long Ret;

unsigned long MessageType[1];

unsigned long CanId[1];

unsigned short DataLength[1];

unsigned char Data[1][64];

 

MessageType[0] = CCAN_MSG_TYPE_CAN_FD | CCAN_MSG_TYPE_BITRATE_SWITCH;

CanId[0] = 0x11c;

DataLength = 1;

Data[0][0] = 0xff;


Ret = CanTransmit ( Id , 1 , &DataLength[0] , &MessageType[0] , &CanId[0] , &Data[0][0] );
 

Python

Ret = ctypes.c_long()

MessageTypeType = ctypes.c_uint() * 1

MessageType = MessageTypeType()

CanIdType = ctypes.c_uint() * 1

CanId = CanIdType()

DataLengthType = ctypes.c_ushort() *1

DataLength = DataLengthType()

SingleDataType = ctypes.c_ubyte() * 64

DataType = ctypes.SingleDataType * 1

Data = DataType()

 

MessageType[0] = CCAN_MSG_TYPE_CAN_FD | CCAN_MSG_TYPE_BITRATE_SWITCH

CanId[0] = 0x11c

DataLength[0] = 1

Data[0][0] = 0xff

 

Ret.value = ccan.CanTransmit ( Id , 1 , DataLength , MessageType , CanId , Data )