Various questions about libcanard

Because you are converting DLC to length incorrectly. You need a mapping function similar to what I posted above, but inverse.

Is the actual length of the data being sent, or can only be the following value
0
1
2
3
4
5
6
7
8
12
16
20
24
32
48
64

What you listed are the only valid payload lengths of a CAN FD data frame. For example, one can’t send a CAN FD data frame with 35 bytes of payload; one would have to pad it out to 48 bytes. In your specific case, the library does the padding for you, so you don’t have to bother.

I found that when I transmitted more than eight bytes(7bytes data + 1 tail byte) of data, I could not receive it successfully.
I have done this:

received_frame.payload_size = CanardCANLengthToDLC[RxHeader.DataLength >> 16];
// --------------------------------------------- PUBLIC API---------------------------------------------

const uint8_t CanardCANDLCToLength[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64};
const uint8_t CanardCANLengthToDLC[65] = {
    0,  1,  2,  3,  4,  5,  6,  7,  8,                               // 0-8
    9,  9,  9,  9,                                                   // 9-12
    10, 10, 10, 10,                                                  // 13-16
    11, 11, 11, 11,                                                  // 17-20
    12, 12, 12, 12,                                                  // 21-24
    13, 13, 13, 13, 13, 13, 13, 13,                                  // 25-32
    14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,  // 33-48
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,  // 49-64
};

The conversion between DLC and length is incorrect. Please do it as I suggested above.

Thanks a lot ,but I still don’t know what parameter to pass in. :confounded:

received_frame.payload_size =xxxxx;

xxxxx: I don’t konw what is this length going to be?
RxHeader.DataLength >> 16 or CanardCANLengthToDLC[RxHeader.DataLength >> 16] or the size of the data i send ,for example :the flowing , 4 ?

uint8_t my_msg[4] = {0};
	canardDSDLSetUxx(&my_msg[0], 	0,          		10,  		8);   // msg1
	canardDSDLSetUxx(&my_msg[0], 	8,          		110,  		8);   // msg2
	canardDSDLSetUxx(&my_msg[0], 	16,          		120,  		8);   // msg3
	canardDSDLSetUxx(&my_msg[0], 	24,          		0xff,  		8);   // msg4

The last option is correct. As the name of the field suggests (payload_size), it is the size of the payload, in bytes. Not DLC.

Thank you very much. I will try it again.

Still can not receive success :expressionless:
Didn’t I set the FDCAN for Uavcan

Maybe this example can help you?

ok,thanks a lot