Boost logo

Boost Users :

Subject: Re: [Boost-users] get/set RTS on serial port
From: Marcelo Adrian Lorenzati Sanz (mlorenzati_at_[hidden])
Date: 2010-06-08 01:13:03


Michael Caisse <boost <at> objectmodelingdesigns.com> writes:

> 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!


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net