#include <ttyconn.h>
Public Member Functions | |
TTYConnector (const std::string &) | |
TTYConnector (const int, const int) | |
virtual | ~TTYConnector () throw () |
virtual Data * | read () |
Add the "owning" object, which is to be notified of disconnections. | |
virtual ssize_t | write (const Data &b) |
Write a blob of data to the underlying connection. | |
string | get_id (void) const |
Instance identification string (abstract virtual). | |
virtual bool | connected (void) const |
Are we connected? | |
Protected Member Functions | |
void | setup_fds (int, int) |
void | open_device (string) |
Protected Attributes | |
int | read_fd |
The fd we read from. | |
int | write_fd |
The fd we write to. | |
pthread_mutex_t | mutex |
Protect changes to the fd's. | |
Private Member Functions | |
void | connect (void) |
Connect to a TTY (for reading and writing...). | |
void | disconnect (void) |
Disconnect from the TTY we're connected to. | |
Private Attributes | |
struct termios * | saved_state |
When putting a TTY into raw mode, save the state to be restored here. |
This TTY could be a serial device, or a UNIX TTY. Should that be divided somehow into two classes? Perhaps a FileConnector could handle some aspects of serial devices, since they'll appear as device files under /dev.
Definition at line 56 of file ttyconn.h.
TTYConnector::TTYConnector | ( | const std::string & | dev | ) |
Definition at line 50 of file ttyconn.cc.
References connect(), mutex, open_device(), and PTHREAD_CHECK_AND_THROW.
TTYConnector::TTYConnector | ( | const | int, | |
const | int | |||
) |
Definition at line 61 of file ttyconn.cc.
References connect(), mutex, PTHREAD_CHECK_AND_THROW, and setup_fds().
TTYConnector::~TTYConnector | ( | void | ) | throw () [virtual] |
Definition at line 72 of file ttyconn.cc.
References CATCH_OR_DIE, disconnect(), and mutex.
Data * TTYConnector::read | ( | ) | [virtual] |
Add the "owning" object, which is to be notified of disconnections.
Implements Connector.
Definition at line 245 of file ttyconn.cc.
References Connector::BufSize, and read_fd.
ssize_t TTYConnector::write | ( | const Data & | b | ) | [virtual] |
Write a blob of data to the underlying connection.
Implements Connector.
Definition at line 261 of file ttyconn.cc.
References Data::data(), Data::len(), and write_fd.
void TTYConnector::setup_fds | ( | int | r, | |
int | w | |||
) | [protected] |
Definition at line 115 of file ttyconn.cc.
References mutex, read_fd, saved_state, and write_fd.
Referenced by TTYConnector().
void TTYConnector::open_device | ( | string | dev_fn | ) | [protected] |
Definition at line 152 of file ttyconn.cc.
References mutex, read_fd, and write_fd.
Referenced by TTYConnector().
string TTYConnector::get_id | ( | void | ) | const [virtual] |
Instance identification string (abstract virtual).
Implements Connector.
Definition at line 218 of file ttyconn.cc.
bool TTYConnector::connected | ( | void | ) | const [virtual] |
void TTYConnector::connect | ( | void | ) | [private] |
Connect to a TTY (for reading and writing...).
Definition at line 174 of file ttyconn.cc.
References mutex, read_fd, and write_fd.
Referenced by TTYConnector().
void TTYConnector::disconnect | ( | void | ) | [private, virtual] |
Disconnect from the TTY we're connected to.
Disconnect us from the TTYs, optionally restoring saved TTY state to the input fd.
Implements Connector.
Definition at line 198 of file ttyconn.cc.
References read_fd, saved_state, and write_fd.
Referenced by ~TTYConnector().
struct termios* TTYConnector::saved_state [read, private] |
When putting a TTY into raw mode, save the state to be restored here.
Definition at line 98 of file ttyconn.h.
Referenced by disconnect(), and setup_fds().
int TTYConnector::read_fd [protected] |
The fd we read from.
..
Definition at line 101 of file ttyconn.h.
Referenced by connect(), connected(), disconnect(), get_id(), open_device(), read(), and setup_fds().
int TTYConnector::write_fd [protected] |
The fd we write to.
..
Definition at line 102 of file ttyconn.h.
Referenced by connect(), connected(), disconnect(), get_id(), open_device(), setup_fds(), and write().
pthread_mutex_t TTYConnector::mutex [protected] |
Protect changes to the fd's.
Definition at line 103 of file ttyconn.h.
Referenced by connect(), connected(), open_device(), setup_fds(), TTYConnector(), and ~TTYConnector().