boost::asio and boost::statecharts newbie question
Hello all - I am using the boost::asio library to do serial I/O with simple Linux serial port(s) like /dev/ttyS0. I have found out how this works, and it is a very impressive library (I will offer a small example program so that you might include it for other users of ASIO serial ports once I've got it cleaned up). However, in addition to using boost::asio, I am using the boost::statechart library as the controller (FSM) for a project. I have managed to get the serial port working with the boost::asio library. Now, my problem is that I have an io_service defined and initialized in my statechart FSM. Is there some way to cast or otherwise use the io_service that I have therein into a serial_port? In other words, I would rather not have to put the serial port handling code in the FSM (I'd rather 'refer' to it using the io_service if it is possible). Thanks for your help! Dave
Hi Dave
However, in addition to using boost::asio, I am using the boost::statechart library as the controller (FSM) for a project. I have managed to get the serial port working with the boost::asio library. Now, my problem is that I have an io_service defined and initialized in my statechart FSM.
Ok so far, although I don't see how an io_service defined and initialized in an FSM is a problem.
Is there some way to cast or otherwise use the io_service that I have therein into a serial_port?
I don't see how the casting io_service to serial_port has anything to do with Boost.Statechart? Moreover, if you want to make an object internal to an FSM visible from the outside then it seems you just need to add a get function to your FSM class? I guess I don't understand your question, so can you please be more specific? A small code example is probably best. Thanks, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
Is there some way to cast or otherwise use the io_service that I have therein into a serial_port? In other words, I would rather not have to put the serial port handling code in the FSM (I'd rather 'refer' to it using the io_service if it is possible).
Single io_service processes a lot of asio objects like sockets, timers, serial ports etc. Given an asio object, you can get its io_service using get_io_service() method.
participants (3)
-
Andreas Huber
-
Dave Mazzoni
-
Igor R