|
nidas v1.2.3
|
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. | |
| int | main (int argc, char *argv[]) |
| Entry point for passing command line args. | |
| int | parseRunstring (int argc, char *argv[]) |
| Configure parameters from runstring. | |
| int | usage (const char *argv0) |
| void | run () |
| Polling loop, reading and writing from stdin/stdout and socket. | |
| void | interrupt () |
| It's time to quit. | |
Static Public Member Functions | |
| static RemoteSerial * | getInstance () |
| Static method to get singleton instance. | |
| static void | signalCatcher (int isig) |
| Signal handler. | |
Static Public Attributes | |
| static const char | ESC = '\x1b' |
Private Types | |
| enum | output { HEX , ASCII , BOTH } |
Private Member Functions | |
| RemoteSerial () | |
| void | removeStdin () |
| void | setupSignals () |
| void | setupStdinout () |
| void | restoreStdin () |
| void | openConnection (n_u::Inet4SocketAddress saddr, const string &sensorName) |
| string | socketReadLine () |
| void | charout (char c) |
| RemoteSerial (const RemoteSerial &) | |
| No copying. | |
| RemoteSerial & | operator= (const RemoteSerial &) |
| No assignment. | |
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.
References ASCII, BOTH, nidas::core::getSample(), HEX, outputOption, and printf().
Referenced by run().
|
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 |
Entry point for passing command line args.
References nidas::core::getSample(), hostName, openConnection(), parseRunstring(), restoreStdin(), run(), sensorName, setupSignals(), setupStdinout(), and socketPort.
|
private |
References _stdinfd, baud, databits, nidas::core::getSample(), messageLength, messageSeparator, parity, nidas::util::replaceBackslashSequences(), nidas::util::Socket::sendall(), sensorName, separatorAtEOM, socket, socketReadLine(), and stopbits.
Referenced by main().
|
private |
No assignment.
Configure parameters from runstring.
References ASCII, BOTH, nidas::core::getSample(), HEX, hostName, outputOption, removeStdin(), sensorName, socketPort, and usage().
Referenced by main().
|
inlineprivate |
References _stdinfd.
Referenced by parseRunstring(), and run().
|
private |
References _stdinfd, nidas::core::getSample(), stdinAltered, and termio_save.
Referenced by main().
| void RemoteSerial::run | ( | ) |
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(), nidas::core::getSample(), HEX, interrupt(), interrupted, messageLength, messageSeparator, outputOption, pollfds, printf(), nidas::util::Socket::recv(), removeStdin(), nidas::util::Socket::sendall(), separatorAtEOM, socket, and nidas::util::Exception::what().
Referenced by main().
|
private |
References nidas::core::getSample(), and signalCatcher().
Referenced by main().
|
private |
References _stdinfd, nidas::core::getSample(), stdinAltered, and termio_save.
Referenced by main().
Signal handler.
catch signals
References getInstance(), and nidas::core::getSample().
Referenced by setupSignals().
|
private |
References buffer, bufhead, BUFSIZE, buftail, nidas::core::getSample(), len, nidas::util::Socket::recv(), and socket.
Referenced by openConnection().
References nidas::core::getSample().
Referenced by parseRunstring().
|
private |
Referenced by openConnection(), removeStdin(), restoreStdin(), run(), and setupStdinout().
|
private |
Referenced by openConnection().
|
private |
Referenced by RemoteSerial(), run(), socketReadLine(), and ~RemoteSerial().
|
private |
Referenced by RemoteSerial(), and socketReadLine().
Referenced by run(), and socketReadLine().
|
private |
Referenced by socketReadLine().
|
private |
Referenced by openConnection().
|
private |
Referenced by main(), and parseRunstring().
|
staticprivate |
Referenced by getInstance(), and ~RemoteSerial().
|
private |
Referenced by interrupt(), and run().
|
private |
Referenced by openConnection(), and run().
|
private |
Referenced by openConnection(), and run().
Referenced by charout(), parseRunstring(), and run().
|
private |
Referenced by openConnection().
|
private |
Referenced by main(), openConnection(), and parseRunstring().
|
private |
Referenced by openConnection(), and run().
|
private |
Referenced by openConnection(), run(), socketReadLine(), and ~RemoteSerial().
Referenced by main(), and parseRunstring().
|
private |
Referenced by restoreStdin(), and setupStdinout().
|
private |
Referenced by openConnection().
|
private |
Referenced by restoreStdin(), and setupStdinout().