nidas v1.2.3
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.
 
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 RemoteSerialgetInstance ()
 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.
 
RemoteSerialoperator= (const RemoteSerial &)
 No assignment.
 

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
 
charbuffer
 
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

◆ output

Enumerator
HEX 
ASCII 
BOTH 

Constructor & Destructor Documentation

◆ ~RemoteSerial()

RemoteSerial::~RemoteSerial ( )

Public destructor.

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

◆ RemoteSerial() [1/2]

RemoteSerial::RemoteSerial ( )
private

References buffer, and bufhead.

Referenced by getInstance().

◆ RemoteSerial() [2/2]

RemoteSerial::RemoteSerial ( const RemoteSerial & )
private

No copying.

Member Function Documentation

◆ charout()

void RemoteSerial::charout ( char c)
private

References ASCII, BOTH, nidas::core::getSample(), HEX, outputOption, and printf().

Referenced by run().

◆ getInstance()

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().

◆ interrupt()

void RemoteSerial::interrupt ( )
inline

It's time to quit.

References interrupted.

Referenced by run().

◆ main()

int RemoteSerial::main ( int argc,
char * argv[] )

◆ openConnection()

void RemoteSerial::openConnection ( n_u::Inet4SocketAddress saddr,
const string & sensorName )
private

◆ operator=()

RemoteSerial & RemoteSerial::operator= ( const RemoteSerial & )
private

No assignment.

◆ parseRunstring()

int RemoteSerial::parseRunstring ( int argc,
char * argv[] )

Configure parameters from runstring.

References ASCII, BOTH, nidas::core::getSample(), HEX, hostName, outputOption, removeStdin(), sensorName, socketPort, and usage().

Referenced by main().

◆ removeStdin()

void RemoteSerial::removeStdin ( )
inlineprivate

References _stdinfd.

Referenced by parseRunstring(), and run().

◆ restoreStdin()

void RemoteSerial::restoreStdin ( )
private

◆ run()

void RemoteSerial::run ( )

◆ setupSignals()

void RemoteSerial::setupSignals ( )
private

References nidas::core::getSample(), and signalCatcher().

Referenced by main().

◆ setupStdinout()

void RemoteSerial::setupStdinout ( )
private

◆ signalCatcher()

void RemoteSerial::signalCatcher ( int isig)
static

Signal handler.

catch signals

References getInstance(), and nidas::core::getSample().

Referenced by setupSignals().

◆ socketReadLine()

string RemoteSerial::socketReadLine ( )
private

◆ usage()

int RemoteSerial::usage ( const char * argv0)

References nidas::core::getSample().

Referenced by parseRunstring().

Member Data Documentation

◆ _stdinfd

int RemoteSerial::_stdinfd
private

◆ baud

int RemoteSerial::baud
private

Referenced by openConnection().

◆ buffer

char* RemoteSerial::buffer
private

◆ bufhead

int RemoteSerial::bufhead
private

Referenced by RemoteSerial(), and socketReadLine().

◆ BUFSIZE

const int RemoteSerial::BUFSIZE
private

Referenced by run(), and socketReadLine().

◆ buftail

int RemoteSerial::buftail
private

Referenced by socketReadLine().

◆ databits

int RemoteSerial::databits
private

Referenced by openConnection().

◆ ESC

const char RemoteSerial::ESC = '\x1b'
static

Referenced by run().

◆ hostName

string RemoteSerial::hostName
private

Referenced by main(), and parseRunstring().

◆ instance

RemoteSerial * RemoteSerial::instance = 0
staticprivate

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

◆ interrupted

bool RemoteSerial::interrupted
private

Referenced by interrupt(), and run().

◆ messageLength

int RemoteSerial::messageLength
private

Referenced by openConnection(), and run().

◆ messageSeparator

string RemoteSerial::messageSeparator
private

Referenced by openConnection(), and run().

◆ outputOption

enum output RemoteSerial::outputOption
private

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

◆ parity

string RemoteSerial::parity
private

Referenced by openConnection().

◆ pollfds

struct pollfd RemoteSerial::pollfds[2]
private

Referenced by run().

◆ sensorName

string RemoteSerial::sensorName
private

◆ separatorAtEOM

bool RemoteSerial::separatorAtEOM
private

Referenced by openConnection(), and run().

◆ socket

n_u::Socket* RemoteSerial::socket
private

◆ socketPort

unsigned short RemoteSerial::socketPort
private

Referenced by main(), and parseRunstring().

◆ stdinAltered

bool RemoteSerial::stdinAltered
private

Referenced by restoreStdin(), and setupStdinout().

◆ stopbits

int RemoteSerial::stopbits
private

Referenced by openConnection().

◆ termio_save

struct termios RemoteSerial::termio_save
private

Referenced by restoreStdin(), and setupStdinout().


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