Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SerialCommPort Class Reference

#include <SerialCommPort.h>

Inheritance diagram for SerialCommPort:

List of all members.


Detailed Description

Provides CommPort interface to serial port devices -- essentially just a FileSystemCommPort, but can apply terminal IO settings.

You could use FileSystemCommPort instead of this class, and thus rely on a prior manual call to stty. However, other programs (or rebooting) will reset those parameters, so it's nice to use this class to ensure the desired settings are reapplied each time the device is opened.

Definition at line 13 of file SerialCommPort.h.


Public Types

enum  parity_t { EVEN, ODD, NONE }

Public Member Functions

 SerialCommPort (const std::string &name)
 constructor
 ~SerialCommPort ()
 destructor
virtual std::string getClassName () const
 Returns the name of the class (aka its type).
virtual bool open ()
 tries to have rbuf and/or wbuf open path, subject to mode
virtual bool close ()
 closes rbuf and wbuf
virtual void plistValueChanged (const plist::PrimitiveBase &pl)
 watches sttyConfig, reapplies the settings if changed

Public Attributes

plist::Primitive< unsigned int > baudRate
plist::Primitive< unsigned int > dataBits
plist::Primitive< unsigned int > stopBits
plist::NamedEnumeration< parity_tparity
plist::Primitive< std::string > sttyConfig
 Configuration string to pass to stty.

Static Public Attributes

static const char *const parityNames [] = { "EVEN", "ODD", "NONE", "" }

Protected Member Functions

virtual void setupSerial ()
 performs serial port initialization (if fd is non-negative)
void dispError (const char *where, int ret, int err)

Protected Attributes

int fd
 file descriptor for serial port -- needed for tcsetattr and ioctl interfaces

Static Protected Attributes

static const std::string autoRegisterSerialCommPort = CommPort::getRegistry().registerType<SerialCommPort>("SerialCommPort")
 holds the class name, set via registration with the CommPort registry

Member Enumeration Documentation

enum parity_t

Enumerator:
EVEN 
ODD 
NONE 

Definition at line 93 of file SerialCommPort.h.


Constructor & Destructor Documentation

SerialCommPort ( const std::string &  name  )  [inline, explicit]

constructor

Definition at line 16 of file SerialCommPort.h.

~SerialCommPort (  )  [inline]

destructor

Definition at line 34 of file SerialCommPort.h.


Member Function Documentation

virtual std::string getClassName (  )  const [inline, virtual]

Returns the name of the class (aka its type).

Suggested implementation is to declare a static string member, set it to the result of calling the registry's registerType, and then return that member here

Reimplemented from FileSystemCommPort.

Definition at line 42 of file SerialCommPort.h.

virtual bool open (  )  [inline, virtual]

tries to have rbuf and/or wbuf open path, subject to mode

Reimplemented from FileSystemCommPort.

Definition at line 44 of file SerialCommPort.h.

virtual bool close (  )  [inline, virtual]

closes rbuf and wbuf

Reimplemented from FileSystemCommPort.

Definition at line 53 of file SerialCommPort.h.

virtual void plistValueChanged ( const plist::PrimitiveBase pl  )  [inline, virtual]

watches sttyConfig, reapplies the settings if changed

Reimplemented from FileSystemCommPort.

Definition at line 63 of file SerialCommPort.h.

void setupSerial (  )  [protected, virtual]

performs serial port initialization (if fd is non-negative)

Definition at line 31 of file SerialCommPort.cc.

Referenced by open(), and plistValueChanged().

void dispError ( const char *  where,
int  ret,
int  err 
) [protected]

Definition at line 126 of file SerialCommPort.cc.

Referenced by setupSerial().


Member Data Documentation

plist::Primitive<unsigned int> baudRate

Definition at line 90 of file SerialCommPort.h.

Referenced by plistValueChanged(), SerialCommPort(), setupSerial(), and ~SerialCommPort().

plist::Primitive<unsigned int> dataBits

Definition at line 91 of file SerialCommPort.h.

Referenced by plistValueChanged(), SerialCommPort(), setupSerial(), and ~SerialCommPort().

plist::Primitive<unsigned int> stopBits

Definition at line 92 of file SerialCommPort.h.

Referenced by plistValueChanged(), SerialCommPort(), setupSerial(), and ~SerialCommPort().

const char *const parityNames = { "EVEN", "ODD", "NONE", "" } [static]

Definition at line 94 of file SerialCommPort.h.

Configuration string to pass to stty.

Definition at line 96 of file SerialCommPort.h.

Referenced by plistValueChanged(), SerialCommPort(), setupSerial(), and ~SerialCommPort().

int fd [protected]

file descriptor for serial port -- needed for tcsetattr and ioctl interfaces

Definition at line 100 of file SerialCommPort.h.

Referenced by close(), open(), and setupSerial().

const std::string autoRegisterSerialCommPort = CommPort::getRegistry().registerType<SerialCommPort>("SerialCommPort") [static, protected]

holds the class name, set via registration with the CommPort registry

Definition at line 108 of file SerialCommPort.h.

Referenced by getClassName().


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

Tekkotsu Hardware Abstraction Layer 4.0
Generated Thu Nov 22 01:01:23 2007 by Doxygen 1.5.4