SerialAdvanced Class Reference

Interface to a serial port. More...

#include <Devices/SerialAdvanced.H>

Inheritance diagram for SerialAdvanced:
Inheritance graph
[legend]
Collaboration diagram for SerialAdvanced:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SerialAdvanced (OptionManager &mgr, const std::string &descrName="SerialAdvanced Port", const std::string &tagName="SerialAdvancedPort")
 Constructor.
 ~SerialAdvanced (void)
 destructor
void configure (const char *dev="/dev/ttyS0", const int speed=9600, const char *format="8N1", const bool flowSoft=false, const bool flowHard=true, const int=0)
 Configure the port before it is started.
void toggleDTR (const time_t millisec)
 Set the DTR mode off momentarily.
void sendBreak (void)
 transmit continuous stream of zero-valued bits for specific duration.
int read (void *buffer, const int nbytes)
 attempt to read up to nbytes from serial port into the buffer
char read (void)
 attempts to get the next character from the serial port
int write (const void *buffer, const int nbytes)
 write bytes to the port
void perror (void)
 print a verbal message indicating the last error.

Protected Member Functions

void start2 ()
 open the port and get started
void stop2 ()
 close the port and get stopped

Detailed Description

Interface to a serial port.

The port will be open at start() time; see ModelComponent.H for details. Because typically one may use several serial ports with different configs, this ModelComponent does not export any command-line option (there would be too many otherwise if many ports are used). Typically, thus, the port can be configured either via config files or using the various access functions provided in this class.

Definition at line 85 of file SerialAdvanced.H.


Constructor & Destructor Documentation

SerialAdvanced::SerialAdvanced ( OptionManager mgr,
const std::string descrName = "SerialAdvanced Port",
const std::string tagName = "SerialAdvancedPort" 
)

Constructor.

Definition at line 109 of file SerialAdvanced.C.

SerialAdvanced::~SerialAdvanced ( void   ) 

destructor

Definition at line 633 of file SerialAdvanced.C.


Member Function Documentation

void SerialAdvanced::configure ( const char *  dev = "/dev/ttyS0",
const int  speed = 9600,
const char *  format = "8N1",
const bool  flowSoft = false,
const bool  flowHard = true,
const int  tout = 0 
)

Configure the port before it is started.

This will update our internal ModelParam values to the specified ones; thus this should be called before start(). In contrast, the setXXX functions below are for reconfiguration at runtime, once the port is already open and running. This function is provided as a shortcut to set a bunch of ModelParam values in one simple call.

Parameters:
dev device name (e.g., "/dev/ttyS0")
speed speed in bauds. See setSpeed() for valid values
format a 3-char string for charbits, parity, and stop bits; for example "8N1"; parity should be "N", "E" or "O".
flowSoft use software flow control if true
flowHard use hardware flow control if true
tout read timeout in 1/10000s or 0 for no timeout

Definition at line 165 of file SerialAdvanced.C.

References OModelParam< T >::setVal().

void SerialAdvanced::perror ( void   ) 

print a verbal message indicating the last error.

Definition at line 574 of file SerialAdvanced.C.

Referenced by start2().

char SerialAdvanced::read ( void   ) 

attempts to get the next character from the serial port

for comptability with dirk's code

Definition at line 537 of file SerialAdvanced.C.

Referenced by read().

int SerialAdvanced::read ( void *  buffer,
const int  nbytes 
)

attempt to read up to nbytes from serial port into the buffer

Parameters:
buffer holds bytes after read number of bytes to attempt to read
Returns:
0 on a timeout, -1 on error, number of bytes actually read on a success

Definition at line 522 of file SerialAdvanced.C.

References read().

void SerialAdvanced::sendBreak ( void   ) 

transmit continuous stream of zero-valued bits for specific duration.

Definition at line 428 of file SerialAdvanced.C.

void SerialAdvanced::start2 (  )  [protected, virtual]

open the port and get started

Reimplemented from ModelComponent.

Definition at line 128 of file SerialAdvanced.C.

References OModelParam< T >::getVal(), and perror().

void SerialAdvanced::stop2 (  )  [protected, virtual]

close the port and get stopped

Reimplemented from ModelComponent.

Definition at line 155 of file SerialAdvanced.C.

void SerialAdvanced::toggleDTR ( const time_t  millisec  ) 

Set the DTR mode off momentarily.

Parameters:
millisec number of milliseconds.

Definition at line 405 of file SerialAdvanced.C.

int SerialAdvanced::write ( const void *  buffer,
const int  nbytes 
)

write bytes to the port

Parameters:
buffer begin writing from the location buffer.
nbytes number of bytes to write
Returns:
-1 on failure, number of bytes written on success

Definition at line 548 of file SerialAdvanced.C.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:43:48 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3