nidas
v1.2-1520
|
RemoteSerial provides a connection between a user's stdin/stdout and a DSMSerialSensor - so that one can send and receive characters while the sensor is connected and being sampled by the DSM. More...
Public Member Functions | |
~RemoteSerial () | |
Public destructor. More... | |
int | main (int argc, char *argv[]) |
Entry point for passing command line args. More... | |
int | parseRunstring (int argc, char *argv[]) |
Configure parameters from runstring. More... | |
int | usage (const char *argv0) |
void | run () throw (n_u::IOException) |
Polling loop, reading and writing from stdin/stdout and socket. More... | |
void | interrupt () |
It's time to quit. More... | |
Static Public Member Functions | |
static RemoteSerial * | getInstance () |
Static method to get singleton instance. More... | |
static void | signalCatcher (int isig) |
Signal handler. More... | |
Static Public Attributes | |
static const char | ESC = '\x1b' |
Private Types | |
enum | output { HEX, ASCII, BOTH } |
Private Member Functions | |
RemoteSerial () | |
void | removeStdin () |
void | setupSignals () throw (n_u::IOException) |
void | setupStdinout () throw (n_u::IOException) |
void | restoreStdin () throw (n_u::IOException) |
void | openConnection (n_u::Inet4SocketAddress saddr, const string &sensorName) throw (n_u::IOException) |
string | socketReadLine () throw (n_u::IOException) |
void | charout (char c) |
RemoteSerial (const RemoteSerial &) | |
No copying. More... | |
RemoteSerial & | operator= (const RemoteSerial &) |
No assignment. More... | |
Private Attributes | |
bool | interrupted |
enum output | outputOption |
string | hostName |
unsigned short | socketPort |
bool | stdinAltered |
struct termios | termio_save |
n_u::Socket * | socket |
string | sensorName |
struct pollfd | pollfds [2] |
const int | BUFSIZE |
char * | buffer |
int | bufhead |
int | buftail |
int | baud |
string | parity |
int | databits |
int | stopbits |
string | messageSeparator |
bool | separatorAtEOM |
int | messageLength |
int | _stdinfd |
Static Private Attributes | |
static RemoteSerial * | instance = 0 |
RemoteSerial provides a connection between a user's stdin/stdout and a DSMSerialSensor - so that one can send and receive characters while the sensor is connected and being sampled by the DSM.
|
private |
RemoteSerial::~RemoteSerial | ( | ) |
Public destructor.
References buffer, nidas::util::Socket::close(), instance, and socket.
|
private |
References buffer, and bufhead.
Referenced by getInstance().
|
private |
No copying.
|
private |
|
static |
Static method to get singleton instance.
The singleton pattern is used here so that signal handlers can access the RemoteSerial instance.
References instance, and RemoteSerial().
Referenced by main(), and signalCatcher().
|
inline |
int RemoteSerial::main | ( | int | argc, |
char * | argv[] | ||
) |
Entry point for passing command line args.
References nidas::util::Inet4Address::getByName(), hostName, openConnection(), parseRunstring(), restoreStdin(), run(), sensorName, setupSignals(), setupStdinout(), socketPort, and nidas::util::Exception::toString().
|
private |
References nidas::util::replaceBackslashSequences().
Referenced by main().
|
private |
No assignment.
int RemoteSerial::parseRunstring | ( | int | argc, |
char * | argv[] | ||
) |
Configure parameters from runstring.
References ASCII, BOTH, HEX, hostName, outputOption, removeStdin(), sensorName, socketPort, and usage().
Referenced by main().
|
inlineprivate |
Referenced by parseRunstring(), run(), and signalCatcher().
|
private |
References _stdinfd, stdinAltered, and termio_save.
Referenced by main().
void RemoteSerial::run | ( | ) | ||
throw | ( | n_u::IOException | ||
) |
Polling loop, reading and writing from stdin/stdout and socket.
References _stdinfd, ASCII, buffer, BUFSIZE, charout(), ESC, nidas::util::Socket::getFd(), nidas::util::Socket::getRemoteSocketAddress(), HEX, interrupt(), interrupted, messageLength, messageSeparator, outputOption, pollfds, printf(), nidas::util::Socket::recv(), removeStdin(), nidas::util::Socket::sendall(), separatorAtEOM, socket, nidas::util::SocketAddress::toString(), and nidas::util::Exception::what().
Referenced by main().
|
private |
References signalCatcher().
Referenced by main().
|
private |
References _stdinfd, stdinAltered, and termio_save.
Referenced by main().
|
static |
Signal handler.
catch signals
References getInstance(), interrupt(), and removeStdin().
Referenced by setupSignals().
|
private |
int RemoteSerial::usage | ( | const char * | argv0 | ) |
Referenced by parseRunstring().
|
private |
Referenced by restoreStdin(), run(), and setupStdinout().
|
private |
|
private |
Referenced by RemoteSerial(), run(), socketReadLine(), and ~RemoteSerial().
|
private |
Referenced by RemoteSerial(), and socketReadLine().
|
private |
Referenced by run(), and socketReadLine().
|
private |
Referenced by socketReadLine().
|
private |
|
static |
Referenced by run().
|
private |
Referenced by main(), and parseRunstring().
|
staticprivate |
Referenced by getInstance(), and ~RemoteSerial().
|
private |
Referenced by run().
|
private |
Referenced by run().
|
private |
Referenced by run().
|
private |
Referenced by charout(), parseRunstring(), and run().
|
private |
|
private |
Referenced by run().
|
private |
Referenced by main(), and parseRunstring().
|
private |
Referenced by run().
|
private |
Referenced by run(), socketReadLine(), and ~RemoteSerial().
|
private |
Referenced by main(), and parseRunstring().
|
private |
Referenced by restoreStdin(), and setupStdinout().
|
private |
|
private |
Referenced by restoreStdin(), and setupStdinout().