Class which manages the logic relative to send/receive messages from Synchronous Serial Port. This class implements all the logic necessary to communicate with UART port.

#include <syncSerialPort.h>

Inheritance diagram for SyncSerialPort:

Public Member Functions

 SyncSerialPort (const char *port, int baud_rate, boost::asio::serial_port_base::flow_control::type flow, TypeRec type=nocanonical)
 Constructor of the class. More...
 
 SyncSerialPort ()
 Constructor of the class.
 
virtual ~SyncSerialPort ()
 Destructor of the class.
 
bool send (const char *buffer, int size)
 Method to send data to serial port synchronously. More...
 
size_t readWithTimeout (char *buff, size_t max_length, int timeout_ms)
 Method to create a synchronous read of the Serial Port non blocking. More...
 
- Public Member Functions inherited from SerialPort
 SerialPort (boost::asio::io_service &io, const char *port, int baud_rate, boost::asio::serial_port_base::flow_control::type flow, TypeRec type=nocanonical)
 Constructor of the class. More...
 
 SerialPort (boost::asio::io_service &io)
 Constructor of the class. More...
 
virtual ~SerialPort ()
 Destructor of the class.
 
bool setPort (const char *port, int baud_rate, boost::asio::serial_port_base::flow_control::type flow)
 Method to establish serial port when it is not established in constructor. More...
 
const char * getPort () const
 Method to take the serial port path. More...
 
bool open (boost::system::error_code &ec)
 Method to open serial port. More...
 
bool isOpened () const
 Method to query if serial port is opened by the current app. More...
 
bool isBusy () const
 Method to query if serial port is opened by any app. More...
 
bool isBusyOp () const
 Method to query if serial port is opened by any app. More...
 
void close ()
 Method to close serial port.
 
bool flush ()
 Method to clear the serial port buffer. More...
 

Additional Inherited Members

- Public Types inherited from SerialPort
enum  TypeRec { canonical = 0, nocanonical = 1 }
 Enum to indicate how serial port must be configured. More...
 
- Protected Types inherited from SerialPort
typedef std::vector< char > VC_DATA
 vector of characters
 
- Protected Attributes inherited from SerialPort
boost::asio::serial_port m_serial_port
 Serial Port Object.
 
std::string m_port
 Port Path name.
 
int m_baud_rate
 Baud Rate to communicate.
 
boost::asio::serial_port_base::flow_control::type m_flow_control
 UART flow control.
 
TypeRec m_TypeR
 Canonical or non-canonical.
 

Constructor & Destructor Documentation

SyncSerialPort ( const char *  port,
int  baud_rate,
boost::asio::serial_port_base::flow_control::type  flow,
TypeRec  type = nocanonical 
)
Parameters
portPath to the serial port
baud_rateRate of serial port to work
flowUART flow control
typeType of serial port configuration

Member Function Documentation

size_t readWithTimeout ( char *  buff,
size_t  max_length,
int  timeout_ms 
)
Parameters
buffBuffer to save bytes received
max_lengthMax length of bytes received
timeout_msTimeout to stop reading in milliseconds
Returns
0 if not data read, number of read bytes in the other case
bool send ( const char *  buffer,
int  size 
)
virtual
Parameters
bufferData buffer to be sent
sizeData length in bytes of the data buffer
Returns
true if serial port is opened and write took place

Implements SerialPort.