Public Member Functions | List of all members
CallbackAsyncSerial Class Reference

Asynchronous serial class with read callback Asynchronous serial class with read callback. User code can write data from one thread, and read data will be reported through a callback called from a separate thred. More...

#include <AsyncSerial.h>

Inheritance diagram for CallbackAsyncSerial:
Inheritance graph
[legend]

Public Member Functions

 CallbackAsyncSerial ()
 
 CallbackAsyncSerial (const std::string &devname, unsigned int baud_rate, boost::asio::serial_port_base::parity opt_parity=boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none), boost::asio::serial_port_base::character_size opt_csize=boost::asio::serial_port_base::character_size(8), boost::asio::serial_port_base::flow_control opt_flow=boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none), boost::asio::serial_port_base::stop_bits opt_stop=boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one))
 
void clearCallback ()
 
void setCallback (const boost::function< void(const char *, size_t) > &callback)
 
virtual ~CallbackAsyncSerial ()
 
- Public Member Functions inherited from AsyncSerial
 AsyncSerial ()
 
 AsyncSerial (const std::string &devname, unsigned int baud_rate, boost::asio::serial_port_base::parity opt_parity=boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none), boost::asio::serial_port_base::character_size opt_csize=boost::asio::serial_port_base::character_size(8), boost::asio::serial_port_base::flow_control opt_flow=boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none), boost::asio::serial_port_base::stop_bits opt_stop=boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one))
 
void close ()
 
bool errorStatus () const
 
bool isOpen () const
 
void open (const std::string &devname, unsigned int baud_rate, boost::asio::serial_port_base::parity opt_parity=boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none), boost::asio::serial_port_base::character_size opt_csize=boost::asio::serial_port_base::character_size(8), boost::asio::serial_port_base::flow_control opt_flow=boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none), boost::asio::serial_port_base::stop_bits opt_stop=boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one))
 
void write (const char *data, size_t size)
 
void write (const std::vector< char > &data)
 
void writeString (const std::string &s)
 
virtual ~AsyncSerial ()
 

Additional Inherited Members

- Static Public Attributes inherited from AsyncSerial
static const int readBufferSize = 512
 
- Protected Member Functions inherited from AsyncSerial
void clearReadCallback ()
 
void setErrorStatus (bool e)
 
void setReadCallback (const boost::function< void(const char *, size_t) > &callback)
 

Detailed Description

Asynchronous serial class with read callback Asynchronous serial class with read callback. User code can write data from one thread, and read data will be reported through a callback called from a separate thred.

Definition at line 872 of file AsyncSerial.h.

Constructor & Destructor Documentation

CallbackAsyncSerial::CallbackAsyncSerial ( )
inline

Definition at line 875 of file AsyncSerial.h.

CallbackAsyncSerial::CallbackAsyncSerial ( const std::string &  devname,
unsigned int  baud_rate,
boost::asio::serial_port_base::parity  opt_parity = boost::asio::serial_port_base::parity ( boost::asio::serial_port_base::parity::                                                                 none ),
boost::asio::serial_port_base::character_size  opt_csize = boost::asio::serial_port_base::character_size ( 8 ),
boost::asio::serial_port_base::flow_control  opt_flow = boost::asio::serial_port_base::flow_control ( boost::asio::serial_port_base::flow_control::                                                                       none ),
boost::asio::serial_port_base::stop_bits  opt_stop = boost::asio::serial_port_base::stop_bits ( boost::asio::serial_port_base::stop_bits::                                                                    one ) 
)
inline

Opens a serial device.

Parameters
devnameserial device name, example "/dev/ttyS0" or "COM1"
baud_rateserial baud rate
opt_parityserial parity, default none
opt_csizeserial character size, default 8bit
opt_flowserial flow control, default none
opt_stopserial stop bits, default 1
Exceptions
boost::system::system_errorif cannot open the serial device

Definition at line 892 of file AsyncSerial.h.

virtual CallbackAsyncSerial::~CallbackAsyncSerial ( )
inlinevirtual

Definition at line 929 of file AsyncSerial.h.

Member Function Documentation

void CallbackAsyncSerial::clearCallback ( )
inline

Removes the callback. Any data received after this function call will be lost.

Definition at line 924 of file AsyncSerial.h.

void CallbackAsyncSerial::setCallback ( const boost::function< void(const char *, size_t) > &  callback)
inline

Set the read callback, the callback will be called from a thread owned by the CallbackAsyncSerial class when data arrives from the serial port.

Parameters
callbackthe receive callback

Definition at line 915 of file AsyncSerial.h.


The documentation for this class was generated from the following file:


serialcom
Author(s): Ricardo Pascoal
autogenerated on Mon Mar 2 2015 01:32:52