[ROS2][c++][boost][asio] How to continously read the serial port inside a Node.
Hi:
I'm currently trying to implement a Serial server. I would like to implement it this way.
Create a Class : rclcpp::Node("my_node");
Inside of it, make a function which will be continuously checking the serial port (using the boost/asio library). When something arrives ,the node will parse it and change it's state and do something according the received cmd. The same node will also be capable of writing the Serial port with commands.
What I cannot figure is how to run this inside my class. I read about not using threads inside Nodes and use Executors instead. So I tried creating two callback groups and run a service containing a while(true)
statement. But what comes into my mind is that if somehow the service get called it will hang.
Is there any different approach to this ?. The tool I'm getting serial information from is activated manually so I would like to read and process the data when needed and not using a timer to constantly poll from it.
Best Regards. Honolulu