SerialPort Class Reference
[Comms - Serial Port interface]

Abstract interfrace to a serial port device. More...

#include <serial_port.h>

Inheritance diagram for SerialPort:
Inheritance graph
[legend]

List of all members.

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 SerialPortNew ()

Detailed Description

Abstract interfrace to a serial port device.

Definition at line 44 of file serial_port.h.


Member Enumeration Documentation

Enumeration of possible error values.

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


Constructor & Destructor Documentation

SerialPort::~SerialPort (  )  [pure virtual]

Destructor which also performs a Close().

Definition at line 320 of file serial_port.cpp.


Member Function Documentation

SerialPort * SerialPort::New (  )  [static]

Construct a serial port.

Returns:
The port object, or zero if an error ocurred.

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.

Parameters:
port Port number.
Returns:
Zero if successful, or a negative error value if failed.

Implemented in WindowsSerialPort, and LinuxSerialPort.

virtual int SerialPort::Initialise ( unsigned  baud  )  [pure virtual]

Initialise port.

Parameters:
baud Baud rate for port.
Returns:
Zero if successful, or a negative error value if failed.
Precondition:
Open() must have been called.

Implemented in WindowsSerialPort, and LinuxSerialPort.

virtual int SerialPort::Out ( const uint8_t data,
size_t  size,
unsigned  timeout 
) [pure virtual]

Transmit data.

This function does not wait if only some of data could be transmitted, instead it returns immediately.

Parameters:
data Pointer to data to be transmitted.
size Size of data.
timeout Time in milliseconds to wait if output is not ready.
Returns:
Number of bytes transmitted or negative error value if failed.
Precondition:
Initialise() must have been called.

Implemented in WindowsSerialPort, and LinuxSerialPort.

virtual int SerialPort::In ( uint8_t data,
size_t  maxSize,
unsigned  timeout 
) [pure virtual]

Receive data.

Parameters:
[out] data Pointer to buffer to hold received data.
maxSize Size of data.
timeout Time in milliseconds to wait if no data available.
Returns:
Number of bytes received or negative error value if failed.
Precondition:
Initialise() must have been called.

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.


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

Generated by  doxygen 1.6.1