#include <SerialIO.h>
Public Types | |
| enum | HandshakeFlags { HS_NONE, HS_HARDWARE, HS_XONXOFF } |
| Constants for defining the handshake. More... | |
| enum | ParityFlags { PA_NONE, PA_EVEN, PA_ODD, PA_MARK, PA_SPACE } |
| Constants for defining the parity bits. More... | |
| enum | StopBits { SB_ONE, SB_ONE_5, SB_TWO } |
| Constants for defining the stop bits. More... | |
Public Member Functions | |
| void | changeBaudRate (int BaudRate) |
| void | closeIO () |
| void | flushTx () |
| int | getSizeRXQueue () |
| int | openIO () |
| void | purge () |
| void | purgeRx () |
| void | purgeTx () |
| int | readBlocking (char *Buffer, int Length) |
| int | readNonBlocking (char *Buffer, int Length) |
| SerialIO () | |
| Default constructor. More... | |
| void | setBaudRate (int BaudRate) |
| void | setBufferSize (int ReadBufSize, int WriteBufSize) |
| void | setBytePeriod (double Period) |
| void | setDeviceName (const char *Name) |
| void | SetFormat (int ByteSize, ParityFlags Parity, int StopBits) |
| void | setHandshake (HandshakeFlags Handshake) |
| void | setMultiplier (double Multiplier=1) |
| void | setTimeout (double Timeout) |
| int | writeIO (const char *Buffer, int Length) |
| virtual | ~SerialIO () |
| Destructor. More... | |
Protected Attributes | |
| int | m_BaudRate |
| ::timeval | m_BytePeriod |
| int | m_ByteSize |
| int | m_Device |
| std::string | m_DeviceName |
| HandshakeFlags | m_Handshake |
| double | m_Multiplier |
| ParityFlags | m_Parity |
| int | m_ReadBufSize |
| bool | m_ShortBytePeriod |
| int | m_StopBits |
| double | m_Timeout |
| ::termios | m_tio |
| int | m_WriteBufSize |
Wrapper class for serial communication.
Definition at line 30 of file SerialIO.h.
Constants for defining the handshake.
| Enumerator | |
|---|---|
| HS_NONE | |
| HS_HARDWARE | |
| HS_XONXOFF | |
Definition at line 35 of file SerialIO.h.
Constants for defining the parity bits.
| Enumerator | |
|---|---|
| PA_NONE | |
| PA_EVEN | |
| PA_ODD | |
| PA_MARK | |
| PA_SPACE | |
Definition at line 43 of file SerialIO.h.
| enum SerialIO::StopBits |
Constants for defining the stop bits.
| Enumerator | |
|---|---|
| SB_ONE | |
| SB_ONE_5 | |
| SB_TWO | |
Definition at line 54 of file SerialIO.h.
| SerialIO::SerialIO | ( | ) |
Default constructor.
Definition at line 102 of file SerialIO.cpp.
|
virtual |
Destructor.
Definition at line 120 of file SerialIO.cpp.
| void SerialIO::changeBaudRate | ( | int | BaudRate | ) |
Changes the baudrate. The serial port is allready open.
| BaudRate | new baudrate. |
Definition at line 317 of file SerialIO.cpp.
| void SerialIO::closeIO | ( | ) |
Closes the serial port.
Definition at line 289 of file SerialIO.cpp.
|
inline |
Sends the transmit buffer. All bytes of the transmit buffer will be sent.
Definition at line 193 of file SerialIO.h.
| int SerialIO::getSizeRXQueue | ( | ) |
Returns the number of bytes available in the read buffer.
Definition at line 404 of file SerialIO.cpp.
| int SerialIO::openIO | ( | ) |
Opens serial port. The port has to be configured before.
Definition at line 125 of file SerialIO.cpp.
|
inline |
Clears the read and transmit buffer.
Definition at line 170 of file SerialIO.h.
|
inline |
Clears the read buffer.
Definition at line 177 of file SerialIO.h.
|
inline |
Clears the transmit buffer. The content of the buffer will not be transmitted.
Definition at line 185 of file SerialIO.h.
| int SerialIO::readBlocking | ( | char * | Buffer, |
| int | Length | ||
| ) |
Reads the serial port blocking. The function blocks until the requested number of bytes have been read or the timeout occurs.
| Buffer | pointer to the buffer. |
| Length | number of bytes to read |
Definition at line 340 of file SerialIO.cpp.
| int SerialIO::readNonBlocking | ( | char * | Buffer, |
| int | Length | ||
| ) |
Reads the serial port non blocking. The function returns all avaiable bytes but not more than requested.
| Buffer | pointer to the buffer. |
| Length | number of bytes to read |
Definition at line 353 of file SerialIO.cpp.
|
inline |
|
inline |
Sets the buffer sizes.
| ReadBufSize | number of bytes of the read buffer. |
| WriteBufSize | number of bytes of the write buffer. |
Definition at line 109 of file SerialIO.h.
| void SerialIO::setBytePeriod | ( | double | Period | ) |
Sets the byte period for transmitting bytes. If the period is not equal to 0, the transmit will be repeated with the given period until all bytes are transmitted.
| default | is 0. |
Definition at line 309 of file SerialIO.cpp.
|
inline |
|
inline |
Sets the message format.
Definition at line 96 of file SerialIO.h.
|
inline |
Defines the handshake type.
Definition at line 102 of file SerialIO.h.
|
inline |
Sets a multiplier for the baudrate. Some serial cards need a specific multiplier for the baudrate.
| Multiplier | default is one. |
Definition at line 91 of file SerialIO.h.
| void SerialIO::setTimeout | ( | double | Timeout | ) |
| int SerialIO::writeIO | ( | const char * | Buffer, |
| int | Length | ||
| ) |
Writes bytes to the serial port.
| Buffer | buffer of the message |
| Length | number of bytes to send |
Definition at line 376 of file SerialIO.cpp.
|
protected |
Definition at line 201 of file SerialIO.h.
|
protected |
Definition at line 208 of file SerialIO.h.
|
protected |
Definition at line 203 of file SerialIO.h.
|
protected |
Definition at line 200 of file SerialIO.h.
|
protected |
Definition at line 199 of file SerialIO.h.
|
protected |
Definition at line 205 of file SerialIO.h.
|
protected |
Definition at line 202 of file SerialIO.h.
|
protected |
Definition at line 204 of file SerialIO.h.
|
protected |
Definition at line 206 of file SerialIO.h.
|
protected |
Definition at line 209 of file SerialIO.h.
|
protected |
Definition at line 203 of file SerialIO.h.
|
protected |
Definition at line 207 of file SerialIO.h.
|
protected |
Definition at line 198 of file SerialIO.h.
|
protected |
Definition at line 206 of file SerialIO.h.