Public Types | Public Member Functions | Protected Attributes
SerialIO Class Reference

#include <SerialIO.h>

List of all members.

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.
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.

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

Detailed Description

Wrapper class for serial communication.

Definition at line 29 of file SerialIO.h.


Member Enumeration Documentation

Constants for defining the handshake.

Enumerator:
HS_NONE 
HS_HARDWARE 
HS_XONXOFF 

Definition at line 34 of file SerialIO.h.

Constants for defining the parity bits.

Enumerator:
PA_NONE 
PA_EVEN 
PA_ODD 
PA_MARK 
PA_SPACE 

Definition at line 42 of file SerialIO.h.

Constants for defining the stop bits.

Enumerator:
SB_ONE 
SB_ONE_5 
SB_TWO 

Definition at line 53 of file SerialIO.h.


Constructor & Destructor Documentation

Default constructor.

Definition at line 105 of file SerialIO.cpp.

SerialIO::~SerialIO ( ) [virtual]

Destructor.

Definition at line 123 of file SerialIO.cpp.


Member Function Documentation

void SerialIO::changeBaudRate ( int  BaudRate)

Changes the baudrate. The serial port is allready open.

Parameters:
BaudRatenew baudrate.

Definition at line 320 of file SerialIO.cpp.

Closes the serial port.

Definition at line 292 of file SerialIO.cpp.

void SerialIO::flushTx ( ) [inline]

Sends the transmit buffer. All bytes of the transmit buffer will be sent.

Definition at line 192 of file SerialIO.h.

Returns the number of bytes available in the read buffer.

Definition at line 407 of file SerialIO.cpp.

Opens serial port. The port has to be configured before.

Definition at line 128 of file SerialIO.cpp.

void SerialIO::purge ( ) [inline]

Clears the read and transmit buffer.

Definition at line 169 of file SerialIO.h.

void SerialIO::purgeRx ( ) [inline]

Clears the read buffer.

Definition at line 176 of file SerialIO.h.

void SerialIO::purgeTx ( ) [inline]

Clears the transmit buffer. The content of the buffer will not be transmitted.

Definition at line 184 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.

Parameters:
Bufferpointer to the buffer.
Lengthnumber of bytes to read

Definition at line 343 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.

Parameters:
Bufferpointer to the buffer.
Lengthnumber of bytes to read

Definition at line 356 of file SerialIO.cpp.

void SerialIO::setBaudRate ( int  BaudRate) [inline]

Sets the baudrate.

Parameters:
BaudRatebaudrate.

Definition at line 76 of file SerialIO.h.

void SerialIO::setBufferSize ( int  ReadBufSize,
int  WriteBufSize 
) [inline]

Sets the buffer sizes.

Parameters:
ReadBufSizenumber of bytes of the read buffer.
WriteBufSizenumber of bytes of the write buffer.

Definition at line 108 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.

Parameters:
defaultis 0.

Definition at line 312 of file SerialIO.cpp.

void SerialIO::setDeviceName ( const char *  Name) [inline]

Sets the device name

Parameters:
Name'COM1', 'COM2', ...

Definition at line 70 of file SerialIO.h.

void SerialIO::SetFormat ( int  ByteSize,
ParityFlags  Parity,
int  StopBits 
) [inline]

Sets the message format.

Definition at line 95 of file SerialIO.h.

void SerialIO::setHandshake ( HandshakeFlags  Handshake) [inline]

Defines the handshake type.

Definition at line 101 of file SerialIO.h.

void SerialIO::setMultiplier ( double  Multiplier = 1) [inline]

Sets a multiplier for the baudrate. Some serial cards need a specific multiplier for the baudrate.

Parameters:
Multiplierdefault is one.

Definition at line 90 of file SerialIO.h.

void SerialIO::setTimeout ( double  Timeout)

Sets the timeout.

Parameters:
Timeoutin seconds

Definition at line 301 of file SerialIO.cpp.

int SerialIO::writeIO ( const char *  Buffer,
int  Length 
)

Writes bytes to the serial port.

Parameters:
Bufferbuffer of the message
Lengthnumber of bytes to send

Definition at line 379 of file SerialIO.cpp.


Member Data Documentation

int SerialIO::m_BaudRate [protected]

Definition at line 200 of file SerialIO.h.

::timeval SerialIO::m_BytePeriod [protected]

Definition at line 207 of file SerialIO.h.

int SerialIO::m_ByteSize [protected]

Definition at line 202 of file SerialIO.h.

int SerialIO::m_Device [protected]

Definition at line 199 of file SerialIO.h.

std::string SerialIO::m_DeviceName [protected]

Definition at line 198 of file SerialIO.h.

Definition at line 204 of file SerialIO.h.

double SerialIO::m_Multiplier [protected]

Definition at line 201 of file SerialIO.h.

Definition at line 203 of file SerialIO.h.

int SerialIO::m_ReadBufSize [protected]

Definition at line 205 of file SerialIO.h.

bool SerialIO::m_ShortBytePeriod [protected]

Definition at line 208 of file SerialIO.h.

int SerialIO::m_StopBits [protected]

Definition at line 202 of file SerialIO.h.

double SerialIO::m_Timeout [protected]

Definition at line 206 of file SerialIO.h.

::termios SerialIO::m_tio [protected]

Definition at line 197 of file SerialIO.h.

int SerialIO::m_WriteBufSize [protected]

Definition at line 205 of file SerialIO.h.


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


cob_relayboard
Author(s): Christian Connette
autogenerated on Sat Jun 8 2019 21:02:18