get/set RTS on serial port

Hi, As far as I've seen in the boost user mailing page, the topic about getting / setting the RTS and other control lines for the serial port have been already discussed, but my question is if it is planned to be added to boost asio serial port the control of those lines by the get_option / set_option. If not, how can I implement my own set_option to control the RTS line in a way to allow me to use it multiplatform, is there any example, hint, mock class, etx? The serial port is still very used in embedded designs and boost is the best way to go to connect with the pc. Best regards, Marcelo Lorenzati

Marcelo Adrian Lorenzati Sanz wrote:
Hi, As far as I've seen in the boost user mailing page, the topic about getting / setting the RTS and other control lines for the serial port have been already discussed, but my question is if it is planned to be added to boost asio serial port the control of those lines by the get_option / set_option. If not, how can I implement my own set_option to control the RTS line in a way to allow me to use it multiplatform, is there any example, hint, mock class, etx? The serial port is still very used in embedded designs and boost is the best way to go to connect with the pc.
Best regards,
Marcelo Lorenzati
Hi Marcelo - See if the quick outline I provided for an RS485 question helps: http://comments.gmane.org/gmane.comp.lib.boost.user/55835 Regards - michael -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com

Michael Caisse
Hi Marcelo -
See if the quick outline I provided for an RS485 question helps: http://comments.gmane.org/gmane.comp.lib.boost.user/55835
Regards - michael
Thanks Michael, I was looking that post and I tried to implement a class having as example the serial_port.ipp and I came with this (a simple example for windows): class RTSControl { public: explicit RTSControl(bool enable = false) : m_enable(enable) {}; boost::system::error_code store(BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) const { #if defined(BOOST_WINDOWS) || defined(__CYGWIN__) if (m_enable) storage.fRtsControl = RTS_CONTROL_ENABLE; else storage.fRtsControl = RTS_CONTROL_DISABLE; #else #endif //ec = boost::asio::error::operation_not_supported; //ec = boost::system::error_code(); return ec; }; boost::system::error_code load(const BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) { #if defined(BOOST_WINDOWS) || defined(__CYGWIN__) if (storage.fRtsControl == RTS_CONTROL_ENABLE) m_enable = true; else m_enable = true; #else #endif return ec; }; private: bool m_enable; }; ... boost::asio::serial_port serialport; ... serialport.set_option(RTSControl(false)); ... It seems to work, thanks!
participants (2)
-
Marcelo Adrian Lorenzati Sanz
-
Michael Caisse