Abstract interfrace to a serial port device. More...
#include <serial_port.h>

Public Types | |
| enum | Errors { ErrorUnspecified = -100, ErrorInvalidPort = -101, ErrorPortInUse = -102, ErrorInvalidSettings = -103, ErrorTransmitError = -104, ErrorReceiveError = -105 } |
Public Member Functions | |
| virtual int | Open (unsigned port)=0 |
| virtual int | Initialise (unsigned baud)=0 |
| virtual int | Out (const uint8_t *data, size_t size, unsigned timeout)=0 |
| virtual int | In (uint8_t *data, size_t maxSize, unsigned timeout)=0 |
| virtual void | Close ()=0 |
| virtual | ~SerialPort ()=0 |
Static Public Member Functions | |
| static SerialPort * | New () |
Abstract interfrace to a serial port device.
Definition at line 44 of file serial_port.h.
| enum SerialPort::Errors |
Enumeration of possible error values.
| ErrorUnspecified |
Unknown error type. |
| ErrorInvalidPort |
Port number specified in Open() is not valid, or port does not exist. |
| ErrorPortInUse |
Port specified in Open() is alread in use. |
| ErrorInvalidSettings |
Values specified in Initialise() are not valid for the device. |
| ErrorTransmitError |
An error occured during data transmission by Out(). |
| ErrorReceiveError |
An error occured during data reception by In(). |
Definition at line 116 of file serial_port.h.
| SerialPort::~SerialPort | ( | ) | [pure virtual] |
Destructor which also performs a Close().
Definition at line 320 of file serial_port.cpp.
| SerialPort * SerialPort::New | ( | ) | [static] |
Construct a serial port.
Definition at line 314 of file serial_port.cpp.
| virtual int SerialPort::Open | ( | unsigned | port | ) | [pure virtual] |
Open port for communications over a specified port number.
| port | Port number. |
Implemented in WindowsSerialPort, and LinuxSerialPort.
| virtual int SerialPort::Initialise | ( | unsigned | baud | ) | [pure virtual] |
Initialise port.
| baud | Baud rate for port. |
Implemented in WindowsSerialPort, and LinuxSerialPort.
Transmit data.
This function does not wait if only some of data could be transmitted, instead it returns immediately.
| data | Pointer to data to be transmitted. | |
| size | Size of data. | |
| timeout | Time in milliseconds to wait if output is not ready. |
Implemented in WindowsSerialPort, and LinuxSerialPort.
Receive data.
| [out] | data | Pointer to buffer to hold received data. |
| maxSize | Size of data. | |
| timeout | Time in milliseconds to wait if no data available. |
Implemented in WindowsSerialPort, and LinuxSerialPort.
| virtual void SerialPort::Close | ( | ) | [pure virtual] |
Close port. Port must not be used again until Open() has been called.
Implemented in WindowsSerialPort, and LinuxSerialPort.
1.6.1