Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

SerialPort Class Reference
[Miscellaneous Library Utilities]

#include <SerialPort.hh>

Inherits Module.

Inherited by SerialPortNonBlock, and SerialPortThreaded.

List of all members.


Detailed Description

Interface class for low level access to serial ports.

This module provides an abstract base interface for accessing serial ports under QNX and Linux. The initialization and configuration of the serial ports are done by this base class. However, derived classes must define a number of virtual methods to implement serial port access functionality.


Public Types

enum  comm_t {
  COM1, COM2, COM3, COM4,
  COM5, COM6, COM7, COM8,
  COM9, COM10
}
enum  baud_t {
  baud_0, baud_50, baud_75, baud_110,
  baud_134, baud_150, baud_200, baud_300,
  baud_600, baud_1200, baud_1800, baud_2400,
  baud_4800, baud_9600, baud_19200, baud_38400,
  baud_57600, baud_115200
}
enum  callType_t { BLOCKING, NONBLOCKING }

Public Member Functions

 SerialPort (comm_t port, baud_t brate)
void init (void)
void uninit (void)
void activate (void)
void deactivate (void)
void update (void)
bool updateable (void)
virtual int getData (char buf[], float time[], int size)=0
 A standard interface method to get serial data with time stamps.

virtual int getData (char buf[], int size)=0
 A standard interface method to get serial data without time stamps.

virtual int sendData (char buf[], int size)=0
 A standard interface method to send data through the associated serial port.

virtual bool isGetFull (void)=0
 A standard interface method to check if there is any serial data that has been received but not requested.

virtual int getGetCount (void)=0
 A standard interface method to obtain the total number of received bytes ready to be read.

virtual bool isSendFull (void)=0
 A standard interface method to check if there is any serial data that in the process of transmission.

virtual void flushGet (void)=0
 A standard interface method to flush the reception related internal buffers and variables.

virtual void flushSend (void)=0
 A standard interface method to flush the transmission related internal buffers and variables.

int getSerialHandle (void)
float getByteTime (void)
void setFrameSize (int s)
int getFrameSize (void)
void flushDeviceIn (void)
void flushDeviceOut (void)
void openPort (callType_t c)
void closePort (void)
void startPort (void)
void stopPort (void)


Member Enumeration Documentation

enum SerialPort::baud_t
 

This enum type defines allowable values for the serial baud rate.

enum SerialPort::callType_t
 

This enum type defines the allowable types of the serial function calls. In the BOCKING mode I/O calls to the serial port are done in synchronous mode where the caller program hangs until the complete result is returned. In the NONBLOCKING the calls are asynchronous where the caller is not delayed and provided with the available result.

enum SerialPort::comm_t
 

This enum type defines available serial port IDs.


Constructor & Destructor Documentation

SerialPort::SerialPort comm_t  port,
baud_t  brate
 

This constructor initializes the internal parameters of the serial port interface module according to the desired serial port id, port, and communication baud rate, brate.


Member Function Documentation

void SerialPort::closePort void   ) 
 

This method closes the serial port and deallocates all the memory and threads associated with it.

void SerialPort::flushDeviceIn void   )  [inline]
 

This method flushes the input stream device driver assigned to the serial port.

void SerialPort::flushDeviceOut void   )  [inline]
 

This method flushes the output stream device driver assigned to the serial port.

virtual void SerialPort::flushGet void   )  [pure virtual]
 

A standard interface method to flush the reception related internal buffers and variables.

This virtual function defines a standard interface for a method that resets the internal variables and buffers that are used in serial data reception. This method must be defined by the child class.

virtual void SerialPort::flushSend void   )  [pure virtual]
 

A standard interface method to flush the transmission related internal buffers and variables.

This virtual function defines a standard interface for a method that resets the internal variables and buffers that are used in serial data transmission. This method must be defined by the child class.

float SerialPort::getByteTime void   )  [inline]
 

This method returns the time it takes for one byte xmit and/or rcv which depends on the baud rate.

virtual int SerialPort::getData char  buf[],
int  size
[pure virtual]
 

A standard interface method to get serial data without time stamps.

This virtual function defines a standard interface for a method that pops size number of bytes from the incoming FIFO of the serial port without time stamps. It must be defined by the classes derived from this base class. The data is copied over to a user-defined array of bytes, buf. Method returns the actual number of bytes transfered which may be less than the number of bytes asked, size.

virtual int SerialPort::getData char  buf[],
float  time[],
int  size
[pure virtual]
 

A standard interface method to get serial data with time stamps.

This virtual function defines a standard interface for a method that pops size number of bytes from the incoming FIFO of the serial port with time stamps. It must be defined by the classes derived from this base class. The data is copied over to a user-defined array of bytes, buf. The time stamps for each data is copied point into another user-defined array, time. Method returns the actual number of bytes transfered which may be less than the number of bytes asked, size.

int SerialPort::getFrameSize void   )  [inline]
 

This method returns the current frame size that is used with the serial port I/O calls.

virtual int SerialPort::getGetCount void   )  [pure virtual]
 

A standard interface method to obtain the total number of received bytes ready to be read.

This virtual function defines a standard interface for a method that returns the total number of received serial bytes that has not been read by the application program. This method must be defined by the child class.

int SerialPort::getSerialHandle void   )  [inline]
 

This method returns a handle to the open file for the serial port.

virtual bool SerialPort::isGetFull void   )  [pure virtual]
 

A standard interface method to check if there is any serial data that has been received but not requested.

This virtual function defines a standard interface for a method that checks the availability of received serial data that has not been transfered over to the application program. It returns TRUE is there is any data to be read, or FALSE if the incoming FIFO is empty. This method must be defined by the child class.

virtual bool SerialPort::isSendFull void   )  [pure virtual]
 

A standard interface method to check if there is any serial data that in the process of transmission.

This virtual function defines a standard interface for a method that returns the total number of bytes to be sent through the serial port that has not been transfered over to the serial port device driver. This method must be defined by the child class.

void SerialPort::openPort callType_t  c  ) 
 

This method opens the com port and sets it up with the desired serial port I/O call type, c.

virtual int SerialPort::sendData char  buf[],
int  size
[pure virtual]
 

A standard interface method to send data through the associated serial port.

This virtual function defines a standard interface for a method that pushes size number of bytes that are located in the user-defined array buf into the outgoing FIFO. This data is transmitted immediately in the order it is given. The method returns the actual number of bytes that are successfully loaded into the outgoing FIFO which may be less than the total number of bytes in the buffer, size, to avoid overflowing the outgoing FIFO.

void SerialPort::setFrameSize int  s  )  [inline]
 

This method sets the frame size for the serial port I/O calls.

void SerialPort::startPort void   ) 
 

This method activates the serial port I/O functionality. It resets the internal data structures and starts reception and transmission of data.

void SerialPort::stopPort void   ) 
 

This method stops the serial port transactions and restores the setings of the serial port device driver to its old values. The serial port device is not destroyed.


RHexLib Reference Documentation