p0fi
p0fi

Reputation: 1096

how to make boost::asio::serial_port_base::flow_control use hardware flow control?

Im wondering how do i enable hardware flow control on boost::asio::serial_port correctly! Now i try to set this option after I open the Port using

serial_.set_option(boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none));

However, if I run the program I get an error telling me:

set_option: Operation not supported on socket

This isn't a very helpful message for me, since the chip should theoretically support hardware flow control.

Is there something I'm might missing or doing wrong? Thanks!

Upvotes: 2

Views: 1389

Answers (1)

Tanner Sansbury
Tanner Sansbury

Reputation: 51881

To enable hardware flow control, one must use the serial_port_base::flow_control::hardware value for the flow_control option:

serial_port.set_option(boost::asio::serial_port::flow_control(
  boost::asio::serial_port::flow_control::hardware));

If an exception is raised that the operation is not supported, then either:

  • the hardware does not support hardware flow control
  • the virtual serial port does not support hardware flow control
  • Boost.Asio does not know how to enable hardware flow control for the detected system. For non-Windows/cygwin configurations, this snippet shows that only _BSD_SOURCE and __QNXNTO__ configurations are supported.

Upvotes: 2

Related Questions