nidas  v1.2-1520
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
RemoteSerial Class Reference

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 RemoteSerialgetInstance ()
 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...
 
RemoteSerialoperator= (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::Socketsocket
 
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 RemoteSerialinstance = 0
 

Detailed Description

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.

Member Enumeration Documentation

enum RemoteSerial::output
private
Enumerator
HEX 
ASCII 
BOTH 

Constructor & Destructor Documentation

RemoteSerial::~RemoteSerial ( )

Public destructor.

References buffer, nidas::util::Socket::close(), instance, and socket.

RemoteSerial::RemoteSerial ( )
private

References buffer, and bufhead.

Referenced by getInstance().

RemoteSerial::RemoteSerial ( const RemoteSerial )
private

No copying.

Member Function Documentation

void RemoteSerial::charout ( char  c)
private

References ASCII, BOTH, HEX, outputOption, and printf().

Referenced by run().

RemoteSerial * RemoteSerial::getInstance ( )
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().

void RemoteSerial::interrupt ( )
inline

It's time to quit.

References interrupted.

Referenced by run(), and signalCatcher().

int RemoteSerial::main ( int  argc,
char *  argv[] 
)
void RemoteSerial::openConnection ( n_u::Inet4SocketAddress  saddr,
const string &  sensorName 
)
throw (n_u::IOException
)
private
RemoteSerial& RemoteSerial::operator= ( const RemoteSerial )
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().

void RemoteSerial::removeStdin ( )
inlineprivate

Referenced by parseRunstring(), run(), and signalCatcher().

void RemoteSerial::restoreStdin ( )
throw (n_u::IOException
)
private

References _stdinfd, stdinAltered, and termio_save.

Referenced by main().

void RemoteSerial::run ( )
throw (n_u::IOException
)
void RemoteSerial::setupSignals ( )
throw (n_u::IOException
)
private

References signalCatcher().

Referenced by main().

void RemoteSerial::setupStdinout ( )
throw (n_u::IOException
)
private

References _stdinfd, stdinAltered, and termio_save.

Referenced by main().

void RemoteSerial::signalCatcher ( int  isig)
static

Signal handler.

catch signals

References getInstance(), interrupt(), and removeStdin().

Referenced by setupSignals().

string RemoteSerial::socketReadLine ( )
throw (n_u::IOException
)
private
int RemoteSerial::usage ( const char *  argv0)

Referenced by parseRunstring().

Member Data Documentation

int RemoteSerial::_stdinfd
private

Referenced by restoreStdin(), run(), and setupStdinout().

int RemoteSerial::baud
private
char* RemoteSerial::buffer
private
int RemoteSerial::bufhead
private

Referenced by RemoteSerial(), and socketReadLine().

const int RemoteSerial::BUFSIZE
private

Referenced by run(), and socketReadLine().

int RemoteSerial::buftail
private

Referenced by socketReadLine().

int RemoteSerial::databits
private
const char RemoteSerial::ESC = '\x1b'
static

Referenced by run().

string RemoteSerial::hostName
private

Referenced by main(), and parseRunstring().

RemoteSerial * RemoteSerial::instance = 0
staticprivate

Referenced by getInstance(), and ~RemoteSerial().

bool RemoteSerial::interrupted
private

Referenced by run().

int RemoteSerial::messageLength
private

Referenced by run().

string RemoteSerial::messageSeparator
private

Referenced by run().

enum output RemoteSerial::outputOption
private

Referenced by charout(), parseRunstring(), and run().

string RemoteSerial::parity
private
struct pollfd RemoteSerial::pollfds[2]
private

Referenced by run().

string RemoteSerial::sensorName
private

Referenced by main(), and parseRunstring().

bool RemoteSerial::separatorAtEOM
private

Referenced by run().

n_u::Socket* RemoteSerial::socket
private

Referenced by run(), socketReadLine(), and ~RemoteSerial().

unsigned short RemoteSerial::socketPort
private

Referenced by main(), and parseRunstring().

bool RemoteSerial::stdinAltered
private

Referenced by restoreStdin(), and setupStdinout().

int RemoteSerial::stopbits
private
struct termios RemoteSerial::termio_save
private

Referenced by restoreStdin(), and setupStdinout().


The documentation for this class was generated from the following file: