LinuxSerialPort Class Reference
[Comms - Serial Port interface]

Serial port object for Linux. More...

Inheritance diagram for LinuxSerialPort:
Inheritance graph
[legend]

List of all members.

Public Member Functions

int Open (unsigned port)
int Initialise (unsigned baud)
int Out (const uint8_t *data, size_t size, unsigned timeout)
int In (uint8_t *data, size_t maxSize, unsigned timeout)
void Close ()

Private Member Functions

int Error (int defaultError=ErrorUnspecified)

Private Attributes

int SerialHandle

Detailed Description

Serial port object for Linux.

Version:
2009-10-02
  • Made implementation of i/o functions on Linux use select() rather than hand rolled polling and sleeping.

Definition at line 61 of file serial_port.cpp.


Member Function Documentation

int LinuxSerialPort::Open ( unsigned  port  )  [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.

Implements SerialPort.

Definition at line 99 of file serial_port.cpp.

int LinuxSerialPort::Initialise ( unsigned  baud  )  [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.

Implements SerialPort.

Definition at line 144 of file serial_port.cpp.

int LinuxSerialPort::Out ( const uint8_t data,
size_t  size,
unsigned  timeout 
) [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.

Implements SerialPort.

Definition at line 177 of file serial_port.cpp.

int LinuxSerialPort::In ( uint8_t data,
size_t  maxSize,
unsigned  timeout 
) [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.

Implements SerialPort.

Definition at line 219 of file serial_port.cpp.

void LinuxSerialPort::Close (  )  [virtual]

Close port. Port must not be used again until Open() has been called.

Implements SerialPort.

Definition at line 261 of file serial_port.cpp.

int LinuxSerialPort::Error ( int  defaultError = ErrorUnspecified  )  [private]

Process an error.

Parameters:
defaultError The default error value to return.
Returns:
An error value from Errors

Definition at line 89 of file serial_port.cpp.


Member Data Documentation

File handle for serial port.

Definition at line 74 of file serial_port.cpp.


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

Generated by  doxygen 1.6.1