Skip to content
New issue

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

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

Already on GitHub? # to your account

ODriveHardwareCAN sendMsg always returns true #4

Open
bthacher-crabi opened this issue Jul 17, 2024 · 1 comment
Open

ODriveHardwareCAN sendMsg always returns true #4

bthacher-crabi opened this issue Jul 17, 2024 · 1 comment

Comments

@bthacher-crabi
Copy link

While trying to write to 6 ODrives using the Arduino GIGA R1 WiFi, I found that only the first 3 messages would successfully be transmitted. At first, I realized that I wasn't checking the output of the ODriveCAN::setPosition function that internally calls can_intf.write, which calls the sendMsg function defined in ODriveHardwareCAN.hpp, but then I realized that since the underlying Arduino_CAN write function (which calls the mbed::CAN write function) returns 1 on success and 0 on failure. This means that the last line in the sendMsg function (return can_intf.write(msg) >= 0;) causes this function to always return true without checking if the message was queued or not. By removing the >= and checking the output to wait until messages were sent, I was able to get my project working. I'm not sure how high the sendMsg is in the firmware stack, so I'm not sure if removing the >= would fix only my platform and break others, but if it would work I think it would be a very important fix. I also understand that 6 ODrives may not be the most common setup, but the code as it is does not work properly on my platform.

The line in question

Let me know if more information is needed, thank you!

@samuelsadok
Copy link
Member

Thanks for digging into this and tracking the issue down! After looking at it, it seems that the Arduino mbed core is not behaving according to the Arduino API specs, so I went ahead and opened this issue: arduino/ArduinoCore-mbed#924. Let's see what the response is on that, and then we'll do a fix on this repo. Good to know that you were already able to make it work for you in the meantime!

And yes controlling many ODrives at once is definitely a use case we want to support well.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants