Skip to content

CANOpen SDO write buffer corruption when writing less data bits than the previous data write  #4

@gpender

Description

@gpender

Hi Ulrik,

Observing the CANbus when writing SDOs, a UINT32 with value 0xFFFFFFFF and then immediately writing a UINT8 with value 0x0C the value seen on the CAN bus is 0x0CFFFFFF. This creates a problem for the target CAN device I am using and throws it into an Emergency State.
To overcome this problem I have changed your code to reset to 0x00 the 4 data bytes in the buffer: not particularly elegant but it does seem to work.

canOpenStatus SDO :: setData(u32 val, u8 valid, u8 *n)
{
canOpenStatus ret = CANOPEN_ERROR;
if (valid > 0 && valid <= 4)
{
this->can_data_tx[4] = 0x00;
this->can_data_tx[5] = 0x00;
this->can_data_tx[6] = 0x00;
this->can_data_tx[7] = 0x00;
if (valid == 1)
{
::setU8Val((u8)val, this->can_data_tx, 4);
}
else if (valid == 2)
{
::setU16Val((u16)val, this->can_data_tx, 4);
}

I hope you can fix this issue for me, in the meantime I will use a modified version
Kind Regards
Guy Pender

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions