Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] serial_port question
From: Michael Caisse (boost_at_[hidden])
Date: 2009-08-25 19:36:25


Robert Dailey wrote:
> When reading information from a serial_port, it seems like I'm
> required to poll the port for data. Is it possible to receive
> asynchronous events when data is available, kind of like how TCP/IP works?
>
> ---------
> Robert Dailey

Robert -

Just use the serial_port like you would a TCP/IP socket. For example,
I do this in one of my classes reading streams from hardware:

   serial_port.async_read_some( boost::asio::buffer( in_message, MAX_MESSAGE_SIZE ),
                                boost::bind( &SerialClient::read_done,
                                             shared_from_this(),
                                             boost::asio::placeholders::error,
                                             boost::asio::placeholders::bytes_transferred ) );

Why are you having to poll?

Michael

-- 
----------------------------------
Michael Caisse
Object Modeling Designs
www.objectmodelingdesigns.com

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