CANopenNode icon indicating copy to clipboard operation
CANopenNode copied to clipboard

producer heartbeat datalength DLC is zero

Open xenpac opened this issue 3 years ago • 4 comments
trafficstars

In CO_NMT_Heartbeat.c, Line: 241, the heartbeat is send.

The current state is copied, but the DLC is left at 0.

shouldnt that be a DLC of 1 ?

xenpac avatar Jun 07 '22 13:06 xenpac

Ok, so anytime CANsend() is called, the DLC is always 0. CANsend has to go through the Tx bufferlist to look for hte matching ID and get the DLC from there. hmm

xenpac avatar Jun 08 '22 10:06 xenpac

ok sorry for the messup.

The Datalength is encoded in the message ID. so DLC=(ID>>12)&0xfL;

The DLC member of the buffer-struct is not used!!

xenpac avatar Jun 08 '22 11:06 xenpac

DLC is configured via CO_CANtxBufferInit(). It is not necessary to configure DLC each time, when sending CAN message.

 * Send CAN message.
 *
 * @param CANmodule This object.
 * @param buffer Pointer to transmit buffer, returned by CO_CANtxBufferInit().
 * Data bytes must be written in buffer before function call.
 *
 * @return #CO_ReturnError_t: CO_ERROR_NO, CO_ERROR_TX_OVERFLOW or
 * CO_ERROR_TX_PDO_WINDOW (Synchronous TPDO is outside window).
 */
CO_ReturnError_t CO_CANsend(CO_CANmodule_t *CANmodule, CO_CANtx_t *buffer);

The DLC member of the buffer-struct is not used!!

It depends on driver implementation.

CANopenNode avatar Jun 08 '22 12:06 CANopenNode

Ok, CANsend() supplys a pointer to the used TXarray entry that shall be send. It has updated the data.

i use the SAMV71 CAN device which has a special way to set the ID and DLC stuff, therefore need seperation.

But no problem it works now. Thanks for assistance ;)

xenpac avatar Jun 09 '22 16:06 xenpac