This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-F280025C: How to get data length of CAN receive message?

Part Number: LAUNCHXL-F280025C

Tool/software:

I can't get the actually data length in DLC, it will same as obj setting.

As below, when the send message is 8 length data, but obj setting length is 5.

We will get DLC = 5. Is there have any method to get actually data length?

data length=5,obj length =5, DLC=5 data length=5,obj length =8,DLC=8
data length=8,obj length =5,DLC=5 data length=8,obj length =8, DLC=8

CAN Obj setting:

Read DLC :

  • Hi Yuhua,

    The expert is currently out of office today due to US holiday. Please expect a delay in response.

    Best Regards,

    Aishwarya

  • Hi Yuhua,

    DLC is an information that is added by the user and it is included in the CAN frame during transmission.  The receiving node will read whatever DLC information is in the CAN frame.  DLC does not provide the number of actual bytes that is received.  The best way to manage what the actual number of bytes is in the frame is to ensure that the DLC information that is sent out during transmission matches the actual number of bytes sent.

    Regards,

    Joseph

  • Hi Joseph,

    Thanks for the response.

    So is there have any method to check the actual number ?

    And I have another question in CAN object setting.

    When I set two CAN object to receive, I can't receive both message.

    But when I set only one object for each, I can receive.

    Can you help me to resolve this question?

    Thanks.

    CAN initialize :

    receive CAN message and read:

  • Hi Yuhua,

    So is there have any method to check the actual number ?

    JC: No, you would have to ensure that the transmitting node would send the ACTUAL DLC value that matches the number of bytes that will be transmitted with the CAN data.

    When I set two CAN object to receive, I can't receive both message.

    But when I set only one object for each, I can receive.

    JC: Both receive message object definitions used the same message ID of 0xFFFFFFFF.  First, this is not correct as extended message ID for CAN is 29-bit long so it should be 0x1FFFFFFF.  Second, check if you have used the correct mask value.  The first object has a mask value of 0, meaning that the first message object (RX_MSG1_OBJ_ID) will receive any message ID.  The second message object (RX_MSG2_OBJ_ID) has a mask value of 0x00EA1300  which means that  any message IDs that match the format xxxx.xxxx.111x.1x1x.xxx1.xx11.xxxx.xxxx(binary) where x=ignore bit value, will be assigned to RX_MSG2_OBJ_ID CAN object.

    Please go through example can_ex8_mask  to see how message ID filtering works.

    Regards,

    Joseph

  • Hi Joseph,

    Thanks for the answer. I can receive the message which I need.

    With the object setting, is the object number means the priority of can message?

  • Hi Yuhua,

    Yes, lower object numbers have the priority.

    Regards,

    Joseph