How to wait for I/O event? example: received CAN message

asked 2021-06-29 02:39:16 -0500

flash_27 gravatar image

updated 2021-06-29 04:09:42 -0500

Hello, I am writing a node that receives CAN messages and translates them in custom ROS messages. It is a LifeCycleNode and inside the on_configuration function i create a CAN socket and set it up. The thing that i do not understand is: where should i put the read() function. Or should I use a non-blockin function?

I found this as a refernce: https://github.com/ROS4SPACE/ros2can_... But I do not know Asio and I do not know if this is the only correct way to do that. THank you in advance.

(I am using Dashing on a Yocto-compiled image on ARM 64bit)

edit retag flag offensive close merge delete

Comments

In the title I meant writing "CAN frame", not "CAN format"

flash_27 gravatar image flash_27  ( 2021-06-29 02:52:32 -0500 )edit

there is an edit button right below the title. You are allow to change it ;-)

mgruhler gravatar image mgruhler  ( 2021-06-29 03:16:36 -0500 )edit

Thank you for the hint

flash_27 gravatar image flash_27  ( 2021-06-29 04:10:23 -0500 )edit

For now, I solved it by creating a new thread inside on_activate() and let it wait for the read() call.

flash_27 gravatar image flash_27  ( 2021-06-29 10:37:30 -0500 )edit