So I\'ve been trying to learn the boost::asio stuff to communicate to a serial device using RS232. The documementation is sparse and the examples are non-existent. Can\'t
Thanks to the help from here and other places I got it working. Wrote a small program that might help some people figure out the boost serial port stuff as well.
boostserialportdemo.cpp
In addition to the baud rate, you may also need to set other options like: character_size, flow_control, parity and stop_bits. To write your data to the serial port you can do the following:
boost::asio::write(port, boost::asio::buffer(commands, 4));
The libraries acceptance of buffer types is very flexible and you may want to read further on that topic here: Buffers.
If you are wondering why his example gives a compile error, change CSIZE to C_SIZE on both lines. This is probably the only good example program on the web.
Thanks.