How to set serial_port flow_control to other than none under boost asio

2.2k Views Asked by At

I found this fine line of code:

serial_port_base::flow_control FLOW( serial_port_base::flow_control::none );

Now, I need flow_control to be set to hardware flow control - how can I do this?

There is no documentation on that so far, and I am already quite sad, that I had to use windows headers to solve my problem with sending a break signal.

Please tell me there is at least a way to setup all serial-port options without using windows headers.

If there is no way without windows headers, I'll take the dirty road here too, so please post dirty examples too.

1

There are 1 best solutions below

1
On BEST ANSWER

If you check out the header file itself in the boost documentation, you'll find the class flow_control:

class flow_control
  {
  public:
    enum type { none, software, hardware };
    BOOST_ASIO_DECL explicit flow_control(type t = none);
    type value() const;
    BOOST_ASIO_DECL boost::system::error_code store(
        BOOST_ASIO_OPTION_STORAGE& storage,
        boost::system::error_code& ec) const;
    BOOST_ASIO_DECL boost::system::error_code load(
        const BOOST_ASIO_OPTION_STORAGE& storage,
        boost::system::error_code& ec);
  private:
    type value_;
  };

You should be able to use serial_port_base::flow_control::hardware in that function call you have to enable hardware flow control.