LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change CAN Frame Data Length Parameter

Solved!
Go to solution

I am using the NI Embedded CAN for RIO and I need to change the Data Length Parameter in a CAN Frame. 

 

Is there a way to do that? If not, are there any workarounds to this issue?

 

Thanks,

Yousif

0 Kudos
Message 1 of 22
(3,441 Views)

I think that you specify the length of the payload (in bytes) in the message itself.  (Google is your friend.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 22
(3,430 Views)

From what I understand the Data Length Code (DLC) Field in a CAN Frame is not a part of the Data Field. My issue is that the Library's CAN Frame does not provide a method of modifying the DLC.

 

 Is there a way to access the DLC field? If not, is there a way around it?

0 Kudos
Message 3 of 22
(3,419 Views)

It should be automatic, unless you are constructing the message manually, in which case you have to calculate the length of the message and insert it as DLC.

 

Have you seen this tutorial yet?

 

Rather than concentrate on the "how", it might be more productive to know the "why".

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 22
(3,410 Views)

I am trying to communicate with a device which only supports CANopen using the sbRIO 9651. The device I am communicating with expects the DLC Field to change depending on the value of the first byte in the Data Field. 

 

I am trying to modify the DLC field to accommodate for that requirement. 

0 Kudos
Message 5 of 22
(3,403 Views)

@yousifd wrote:

I am trying to communicate with a device which only supports CANopen using the sbRIO 9651. The device I am communicating with expects the DLC Field to change depending on the value of the first byte in the Data Field. 

 

I am trying to modify the DLC field to accommodate for that requirement. 


That doesn't sound right at all.  I'm not sure you are understanding the requirement correctly.  The hint here is that DLC stands for Data Length Code.  Reading this tells you the length, in bytes, of the payload.  This is important so you can tell where the payload ends and the CRC value begins.  You can't find a way to modify it because it shouldn't be modified.


Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 22
(3,337 Views)

I understand where your misunderstanding comes from.

 

What I meant to say was that the device reads the DLC. The DLC value must be either 3 or 5. If the DLC field has a value of 3 then it reads the first byte of the DATA field which always refers to an internal register on the device, then the other 2 bytes are data values that are used to modify the value within the register specified in the first byte of the data length. Same goes for 5. 

 

I am not trying to modify the size of the DLC Field. I am just trying to modify the DLC Field value to accommodate for the DLC requirements of the devices I am communicating with. 

0 Kudos
Message 7 of 22
(3,334 Views)

@yousifd wrote:

I understand where your misunderstanding comes from.

 

What I meant to say was that the device reads the DLC. The DLC value must be either 3 or 5. If the DLC field has a value of 3 then it reads the first byte of the DATA field which always refers to an internal register on the device, then the other 2 bytes are data values that are used to modify the value within the register specified in the first byte of the data length. Same goes for 5. 

 

I am not trying to modify the size of the DLC Field. I am just trying to modify the DLC Field value to accommodate for the DLC requirements of the devices I am communicating with. 


Still sounds to me like you should just use the standard CAN send and receive and forget about the DLC.  If you send three bytes, the DLC will be 3.  if you send five bytes, the DLC will be 5.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 22
(3,331 Views)

If that is the case then everything should be fine. But from what I have been using, NI Embedded CAN for RIO, there doesn't seem to be a way of sending less than 8 bytes in the DATA Field. The example VIs provided with the library use a predefined CAN Frame Cluster which has an array of size 8 without any clear way of modifying it. All of the bytes in the array are initialized to 0.

Unless there is a way of modifying the size of the array within the cluster our only solution is modifying the DLC field. 

0 Kudos
Message 9 of 22
(3,327 Views)

Hi yousif,

 

you DON'T change the size of that array.

You only supply the DLC value in this cluster!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 22
(3,303 Views)