Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gpender opened this issue Dec 9, 2020 · 0 comments

Comments

@gpender
Copy link

gpender commented Dec 9, 2020

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

@gpender gpender changed the title CANOpen Write buffer corruption when writing less data bits than the previous data write CANOpen SDO write buffer corruption when writing less data bits than the previous data write Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant