CAN FD DLC beetween 0 to 15

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
matthieu
Posts: 9
Joined: Mon 15. Jul 2024, 16:25

CAN FD DLC beetween 0 to 15

Post by matthieu » Tue 30. Jul 2024, 09:49

Hello,

I'm currently trying to handle flexible data rate but when I try to set up the DLC an exception appears : The specified data length code is not valid. Value must be between 0 and 15. However I saw that normally CAN FD is working with my version : 4.9.0.942.
First, I set the message type and then the dlc. Is there something to do to make it works?

Matthieu

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: CAN FD DLC beetween 0 to 15

Post by M.Maidhof » Tue 30. Jul 2024, 10:40

Hi,

which value for DLC do you set in your application? Can you please share parts of the code? Which PCAN hardware do you use?

regards

Michael

matthieu
Posts: 9
Joined: Mon 15. Jul 2024, 16:25

Re: CAN FD DLC beetween 0 to 15

Post by matthieu » Tue 30. Jul 2024, 13:26

the value isn't always the same, this time it was 22.

Code: Select all

 if (dataBaseMessage.DLC <= 8)
 {
     if (!dataBaseMessage.isExtID ?? false)
         this.MsgType = MessageType.Standard;
     else if (dataBaseMessage.isExtID ?? false)
         this.MsgType = MessageType.Extended;
 }
 else
     this.MsgType = MessageType.FlexibleDataRate;
 this.DLC = dataBaseMessage.DLC;
 this.ID = dataBaseMessage.ID;


 public byte DLC
 {
     get { return messageBC.Message.DLC; }
     set
     {
         messageBC.Message.DLC = value;
         OnPropertyChanged(nameof(DLC));
     }
 }

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: CAN FD DLC beetween 0 to 15

Post by M.Maidhof » Tue 30. Jul 2024, 13:42

Hi,

DLC values can only have a value between 0 and 15. Looks like your "dataBaseMessage.DLC" is not valid. From where did you get it? Please see help of PCANBasic for more details about possible DLC:
DLC.JPG
DLC.JPG (36.65 KiB) Viewed 4902 times
regards

Michael

matthieu
Posts: 9
Joined: Mon 15. Jul 2024, 16:25

Re: CAN FD DLC beetween 0 to 15

Post by matthieu » Thu 1. Aug 2024, 09:50

Hi,

the DLC that I retrieve is from a dbc file and the message is characterized by this line : "BO_ 2566741502 DM43: 22 Vector__XXX"
Anyway, I wasn't aware of the way DLC is working for CAN FD, so I couldn't get it to work properly.
Now that I'm aware, I guess I should set the DLC to the value just above, depending on the format of the DLC?

Matthieu,
Br

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: CAN FD DLC beetween 0 to 15

Post by M.Maidhof » Thu 1. Aug 2024, 10:57

Hello,

yes, you must keep the DLC values as specified in the PCANBasic help (0-15 only).

regards

Michael

Post Reply