Boost Asio serial_port - need help with io

前端 未结 3 1924
太阳男子
太阳男子 2020-12-14 19:38

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

3条回答
  •  别那么骄傲
    2020-12-14 20:30

    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.

提交回复
热议问题