vrpn 07.35
Virtual Reality Peripheral Network
|
A simple class wrapping the functionality of vrpn_Serial.h with RAII, object-orientation, and optional STL types. More...
#include <vrpn_SerialPort.h>
Classes | |
struct | AlreadyOpen |
struct | CloseFailure |
struct | DrainFailure |
struct | FlushFailure |
struct | NotOpen |
struct | OpenFailure |
struct | ReadFailure |
struct | RTSFailure |
struct | WriteFailure |
Public Types | |
typedef int | file_handle_type |
Public Member Functions | |||
vrpn_SerialPort (const char *portname, long baud, int charsize=8, vrpn_SER_PARITY parity=vrpn_SER_PARITY_NONE) | |||
Construct and open port. | |||
vrpn_SerialPort () | |||
Construct without opening. | |||
~vrpn_SerialPort () | |||
Destructor - closes port if open. | |||
Open/Close Methods | |||
void | open (const char *portname, long baud, int charsize=8, vrpn_SER_PARITY parity=vrpn_SER_PARITY_NONE) | ||
bool | is_open () const | ||
void | close () | ||
Close the serial port. | |||
Write | |||
| |||
int | write (std::string const &buffer) | ||
int | write (const unsigned char *buffer, int bytes) | ||
Read | |||
Read available characters from input buffer, up to indicated count.
| |||
int | read_available_characters (unsigned char *buffer, int count) | ||
std::string | read_available_characters (int count=-1) | ||
Read available characters from input buffer, up to indicated count (or -1 for no limit) | |||
int | read_available_characters (unsigned char *buffer, int count, struct timeval &timeout) | ||
Read available characters from input buffer, and wait up to the indicated timeout for those remaining, up to indicated count. | |||
std::string | read_available_characters (int count, struct timeval &timeout) | ||
Read available characters from input buffer, and wait up to the indicated timeout for those remaining, up to indicated count. | |||
Buffer manipulation | |||
void | flush_input_buffer () | ||
Throw out any characters within the input buffer. | |||
void | flush_output_buffer () | ||
Throw out any characters (do not send) within the output buffer. | |||
void | drain_output_buffer () | ||
Wait until all of the characters in the output buffer are sent, then return. | |||
RTS | |||
Set and clear functions for the RTS ("ready to send") hardware flow- control bit. These are used on a port that is already open. Some devices (like the Ascension Flock of Birds) use this to reset the device.
| |||
void | set_rts () | ||
void | clear_rts () | ||
void | assign_rts (bool set) | ||
A simple class wrapping the functionality of vrpn_Serial.h with RAII, object-orientation, and optional STL types.
Definition at line 34 of file vrpn_SerialPort.h.
typedef int vrpn_SerialPort::file_handle_type |
Definition at line 36 of file vrpn_SerialPort.h.
vrpn_SerialPort::vrpn_SerialPort | ( | const char * | portname, |
long | baud, | ||
int | charsize = 8, | ||
vrpn_SER_PARITY | parity = vrpn_SER_PARITY_NONE ) |
Construct and open port.
OpenFailure |
Definition at line 36 of file vrpn_SerialPort.C.
References is_open().
vrpn_SerialPort::vrpn_SerialPort | ( | ) |
Construct without opening.
Definition at line 46 of file vrpn_SerialPort.C.
vrpn_SerialPort::~vrpn_SerialPort | ( | ) |
Destructor - closes port if open.
Definition at line 52 of file vrpn_SerialPort.C.
References close(), and is_open().
|
inline |
Definition at line 212 of file vrpn_SerialPort.h.
References clear_rts(), and set_rts().
void vrpn_SerialPort::clear_rts | ( | ) |
Definition at line 197 of file vrpn_SerialPort.C.
References vrpn_clear_rts().
Referenced by assign_rts().
void vrpn_SerialPort::close | ( | ) |
Close the serial port.
NotOpen,CloseFailure |
Definition at line 77 of file vrpn_SerialPort.C.
References vrpn_close_commport().
Referenced by ~vrpn_SerialPort().
void vrpn_SerialPort::drain_output_buffer | ( | ) |
Wait until all of the characters in the output buffer are sent, then return.
Definition at line 179 of file vrpn_SerialPort.C.
References vrpn_drain_output_buffer().
void vrpn_SerialPort::flush_input_buffer | ( | ) |
Throw out any characters within the input buffer.
FlushFailure,NotOpen |
Definition at line 161 of file vrpn_SerialPort.C.
References vrpn_flush_input_buffer().
void vrpn_SerialPort::flush_output_buffer | ( | ) |
Throw out any characters (do not send) within the output buffer.
FlushFailure,NotOpen |
Definition at line 170 of file vrpn_SerialPort.C.
References vrpn_flush_output_buffer().
|
inline |
Definition at line 210 of file vrpn_SerialPort.h.
Referenced by open(), vrpn_SerialPort(), and ~vrpn_SerialPort().
void vrpn_SerialPort::open | ( | const char * | portname, |
long | baud, | ||
int | charsize = 8, | ||
vrpn_SER_PARITY | parity = vrpn_SER_PARITY_NONE ) |
Definition at line 64 of file vrpn_SerialPort.C.
References is_open(), and vrpn_open_commport().
std::string vrpn_SerialPort::read_available_characters | ( | int | count, |
struct timeval & | timeout ) |
Read available characters from input buffer, and wait up to the indicated timeout for those remaining, up to indicated count.
overflow safety
Definition at line 149 of file vrpn_SerialPort.C.
References read_available_characters().
std::string vrpn_SerialPort::read_available_characters | ( | int | count = -1 | ) |
Read available characters from input buffer, up to indicated count (or -1 for no limit)
Definition at line 116 of file vrpn_SerialPort.C.
References read_available_characters().
int vrpn_SerialPort::read_available_characters | ( | unsigned char * | buffer, |
int | count ) |
Definition at line 105 of file vrpn_SerialPort.C.
References vrpn_read_available_characters().
Referenced by read_available_characters(), and read_available_characters().
int vrpn_SerialPort::read_available_characters | ( | unsigned char * | buffer, |
int | count, | ||
struct timeval & | timeout ) |
Read available characters from input buffer, and wait up to the indicated timeout for those remaining, up to indicated count.
Definition at line 138 of file vrpn_SerialPort.C.
References vrpn_read_available_characters().
void vrpn_SerialPort::set_rts | ( | ) |
Definition at line 188 of file vrpn_SerialPort.C.
References vrpn_set_rts().
Referenced by assign_rts().
int vrpn_SerialPort::write | ( | const unsigned char * | buffer, |
int | bytes ) |
Definition at line 95 of file vrpn_SerialPort.C.
References vrpn_write_characters().
int vrpn_SerialPort::write | ( | std::string const & | buffer | ) |
Definition at line 86 of file vrpn_SerialPort.C.
References write().
Referenced by write().