cSerialBase Class Reference

Low-level communication class to access a serial port. More...

#include <serialbase.h>

Inheritance diagram for cSerialBase:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void Close (void)=0 throw (cSerialBaseException*)
 Close the previously opened communication channel.
 cSerialBase ()
 ctor
virtual double GetTimeout ()
 set the timeout for next readline() calls (negative value means: no timeout, wait for ever)
virtual bool IsOpen (void)=0 throw ()
 Return true if communication channel is open.
virtual void Open (void)=0 throw (cSerialBaseException*)
 Open rs232 port port.
virtual ssize_t Read (void *data, ssize_t size, long timeout_us, bool return_on_less_data)=0 throw (cSerialBaseException*)
virtual char * readline (char *line, int size, char const *eol="\n", bool return_on_less_data=false) throw (cSerialBaseException*)
 Read a line from the device.
virtual void SetTimeout (double _timeout) throw (cSerialBaseException*)
 set the timeout for next readline() calls (negative value means: no timeout, wait for ever)
virtual int write (char const *ptr, int len=0)=0 throw (cSerialBaseException*)
 Write data to a previously opened port.
virtual ~cSerialBase (void)
 dtor

Public Attributes

cDBG dbg
 A stream object to print colored debug messages.

Protected Attributes

double timeout
 timeout in seconds
char ungetch
 an already read data byte of the next line
bool ungetch_valid
 Flag, true if ungetch is valid.

Detailed Description

Low-level communication class to access a serial port.

(This is an abstract base class with pure virtual functions)

Definition at line 93 of file serialbase.h.


Constructor & Destructor Documentation

cSerialBase::cSerialBase (  )  [inline]

ctor

Definition at line 108 of file serialbase.h.

virtual cSerialBase::~cSerialBase ( void   )  [inline, virtual]

dtor

Definition at line 119 of file serialbase.h.


Member Function Documentation

virtual void cSerialBase::Close ( void   )  throw (cSerialBaseException*) [pure virtual]

Close the previously opened communication channel.

Implemented in cCANSerial_ESD, cCANSerial_PEAK, cRS232, cRS232, and cTCPSerial.

virtual double cSerialBase::GetTimeout (  )  [inline, virtual]

set the timeout for next readline() calls (negative value means: no timeout, wait for ever)

Definition at line 147 of file serialbase.h.

virtual bool cSerialBase::IsOpen ( void   )  throw () [pure virtual]

Return true if communication channel is open.

Implemented in cCANSerial_ESD, cCANSerial_PEAK, cRS232, cRS232, and cTCPSerial.

virtual void cSerialBase::Open ( void   )  throw (cSerialBaseException*) [pure virtual]

Open rs232 port port.

Open the device with the parameters provided in the constructor

Implemented in cCANSerial_ESD, cCANSerial_PEAK, cRS232, cRS232, and cTCPSerial.

virtual ssize_t cSerialBase::Read ( void *  data,
ssize_t  size,
long  timeout_us,
bool  return_on_less_data 
) throw (cSerialBaseException*) [pure virtual]

Read data from device. This function waits until max_time_us us passed or the expected number of bytes are received via serial line. if (return_on_less_data is true (default value), the number of bytes that have been received are returned and the data is stored in data If the return_on_less_data is false, data is only read from serial line, if at least size bytes are available.

Implemented in cCANSerial_ESD, cCANSerial_PEAK, cRS232, cRS232, and cTCPSerial.

virtual char* cSerialBase::readline ( char *  line,
int  size,
char const *  eol = "\n",
bool  return_on_less_data = false 
) throw (cSerialBaseException*) [virtual]

Read a line from the device.

A line is terminated with one of the end-of-line (eol) characters ('
' by default) or until timeout

Parameters:
line - ptr to where to store the read line
size - space available in line (bytes)
eol - a string containing all the chars that mark an end of line
return_on_less_data - if (return_on_less_data is true (default value), the number of bytes that have been received are returned and the data is stored in data If the return_on_less_data is false, data is only read from serial line, if at least size bytes are available.

A pointer to the line read is returned.

virtual void cSerialBase::SetTimeout ( double  _timeout  )  throw (cSerialBaseException*) [inline, virtual]

set the timeout for next readline() calls (negative value means: no timeout, wait for ever)

Reimplemented in cCANSerial_ESD, cCANSerial_PEAK, cRS232, and cTCPSerial.

Definition at line 140 of file serialbase.h.

virtual int cSerialBase::write ( char const *  ptr,
int  len = 0 
) throw (cSerialBaseException*) [pure virtual]

Write data to a previously opened port.

Write len bytes from *ptr to the rs232 device

Parameters:
ptr - pointer the byte array to send in memory
len - number of bytes to send
Returns:
the number of bytes actually written

Implemented in cCANSerial_ESD, cCANSerial_PEAK, cRS232, cRS232, and cTCPSerial.


Member Data Documentation

A stream object to print colored debug messages.

Definition at line 195 of file serialbase.h.

double cSerialBase::timeout [protected]

timeout in seconds

Definition at line 104 of file serialbase.h.

char cSerialBase::ungetch [protected]

an already read data byte of the next line

Definition at line 98 of file serialbase.h.

bool cSerialBase::ungetch_valid [protected]

Flag, true if ungetch is valid.

Definition at line 101 of file serialbase.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


cob_sdh
Author(s): Florian Weisshardt
autogenerated on Fri Jan 11 10:03:56 2013