Page 1 of 1
CAN FD DLC beetween 0 to 15
Posted: Tue 30. Jul 2024, 09:49
by matthieu
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
Re: CAN FD DLC beetween 0 to 15
Posted: Tue 30. Jul 2024, 10:40
by M.Maidhof
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
Re: CAN FD DLC beetween 0 to 15
Posted: Tue 30. Jul 2024, 13:26
by matthieu
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));
}
}
Re: CAN FD DLC beetween 0 to 15
Posted: Tue 30. Jul 2024, 13:42
by M.Maidhof
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 (36.65 KiB) Viewed 4915 times
regards
Michael
Re: CAN FD DLC beetween 0 to 15
Posted: Thu 1. Aug 2024, 09:50
by matthieu
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
Re: CAN FD DLC beetween 0 to 15
Posted: Thu 1. Aug 2024, 10:57
by M.Maidhof
Hello,
yes, you must keep the DLC values as specified in the PCANBasic help (0-15 only).
regards
Michael