Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SerialCommPort Class Reference

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

#include <SerialCommPort.h>

Inheritance diagram for SerialCommPort:

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 14 of file SerialCommPort.h.

List of all members.

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", NULL }

Protected Member Functions

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

Static Protected Member Functions

static void initBauds ()
 initializes bauds with all of the symbolic baud rate settings available on host platform

Protected Attributes

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

Static Protected Attributes

static std::map< int, speed_t > bauds
 table of valid baud rates
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 96 of file SerialCommPort.h.


Constructor & Destructor Documentation

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

constructor

Definition at line 17 of file SerialCommPort.h.

~SerialCommPort (  ) 

destructor

Definition at line 37 of file SerialCommPort.h.


Member Function Documentation

virtual bool close (  )  [virtual]

closes rbuf and wbuf

Reimplemented from FileSystemCommPort.

Definition at line 56 of file SerialCommPort.h.

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

Definition at line 170 of file SerialCommPort.cc.

Referenced by setupSerial().

virtual std::string getClassName (  )  const [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 45 of file SerialCommPort.h.

void initBauds (  )  [static, protected]

initializes bauds with all of the symbolic baud rate settings available on host platform

Definition at line 174 of file SerialCommPort.cc.

Referenced by SerialCommPort().

virtual bool open (  )  [virtual]

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

Reimplemented from FileSystemCommPort.

Definition at line 47 of file SerialCommPort.h.

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

watches sttyConfig, reapplies the settings if changed

Reimplemented from FileSystemCommPort.

Definition at line 66 of file SerialCommPort.h.

void setupSerial (  )  [protected, virtual]

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

Definition at line 35 of file SerialCommPort.cc.

Referenced by open(), and plistValueChanged().


Member Data Documentation

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 117 of file SerialCommPort.h.

Referenced by getClassName().

plist::Primitive<unsigned int> baudRate

Definition at line 93 of file SerialCommPort.h.

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

std::map< int, speed_t > bauds [static, protected]

table of valid baud rates

Definition at line 114 of file SerialCommPort.h.

Referenced by initBauds(), SerialCommPort(), and setupSerial().

plist::Primitive<unsigned int> dataBits

Definition at line 94 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 103 of file SerialCommPort.h.

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

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

Definition at line 97 of file SerialCommPort.h.

plist::Primitive<unsigned int> stopBits

Definition at line 95 of file SerialCommPort.h.

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

Configuration string to pass to stty.

Definition at line 99 of file SerialCommPort.h.

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


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

Tekkotsu Hardware Abstraction Layer 5.1CVS
Generated Mon May 9 05:01:41 2016 by Doxygen 1.6.3