KITmedical / kacanopen

Easy-to-use CanOpen stack and CanOpen-to-ROS bridge.
Other
93 stars 57 forks source link

Return flag to users for TPDO send errors #15

Closed jonbinney closed 4 years ago

jonbinney commented 6 years ago

Before this change, the caller of Core::send() PDO::send() had no way to know when the send failed (the return value was void). The underlying driver send functions do return values though. This PR just passes those up through Core and PDO classes. This changes the return type of the functions, but shouldn't require anyone ussing these functions to change code. If they were expecting void return type before, now they'll just not do anything with the returned bool.

It will, however, require people to recompile, since the ABI will change.

jonbinney commented 6 years ago

Also I moved the printing of the send error to stderr so that it is disabled by default. A low level library function printing directly to stderr by default was annoying (flooding consoles for us). Let me know if this seems reasonable; another option would be to add another prepocessor variable to turn on/off this fprintf statement, and have it be on by default.

thk1 commented 6 years ago

Hi. Thanks for your contribution! I think using DEBUG_MSG_CONSOLE_ON is fine, however, the fprintf statement needs to stay inside the if block in line 121. Please fix this and use a separate commit for the change in can_socket.c. I will merge it then.

jonbinney commented 6 years ago

Wow, good catch.... having that fprintf outside of the if made no sense at all. I must have been tired....

I have made the fix and split the fprintf change into its own commit.

jonbinney commented 6 years ago

Looks like one of the tests on travis failed, but it seems unrelated to the changes in this PR - some network problem with apt.