Class which manages the logic relative to send/receive messages from Serial Port. This class implements all the logic necessary to communicate with UART port.
#include <serialPort.h>
|
| 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...
|
|
virtual bool | send (const char *buffer, int size)=0 |
| Method to send data to serial port synchronously. More...
|
|
|
typedef std::vector< char > | VC_DATA |
| vector of characters
|
|
Enumerator |
---|
canonical |
canonical
|
nocanonical |
no-canonical
|
SerialPort |
( |
boost::asio::io_service & |
io, |
|
|
const char * |
port, |
|
|
int |
baud_rate, |
|
|
boost::asio::serial_port_base::flow_control::type |
flow, |
|
|
TypeRec |
type = nocanonical |
|
) |
| |
- Parameters
-
io | Input/Output Service Object reference |
port | Path to the serial port |
baud_rate | Rate of serial port to work |
flow | UART flow control |
type | Type of serial port configuration |
- Parameters
-
io | io_service for input/output operations |
- Returns
- true if clear was possible
const char* getPort |
( |
| ) |
const |
- Returns
- A pointer to the serial port path
- Returns
- true if it is busy
- Returns
- true if it is busy
- Returns
- true if it is opened
bool open |
( |
boost::system::error_code & |
ec | ) |
|
- Parameters
-
- Returns
- true if it is opened
virtual bool send |
( |
const char * |
buffer, |
|
|
int |
size |
|
) |
| |
|
pure virtual |
- Parameters
-
buffer | Data buffer to be sent |
size | Data length in bytes of the data buffer |
- Returns
- true if serial port is opened and write took place
Implemented in AsyncSerialPort, and SyncSerialPort.
bool setPort |
( |
const char * |
port, |
|
|
int |
baud_rate, |
|
|
boost::asio::serial_port_base::flow_control::type |
flow |
|
) |
| |
- Parameters
-
port | Path to the serial port |
baud_rate | Rate of serial port to send/receive data |
flow | UART flow control |
- Returns
- true/false if the port is fixed.