ARPDAS_QNX6 1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
Ser_Sel Class Reference

#include <SerSelector.h>

Inheritance diagram for Ser_Sel:
Collaboration diagram for Ser_Sel:

List of all members.

Public Member Functions

 Ser_Sel (const char *path, int open_flags, int bufsz)
 Ser_Sel ()
 ~Ser_Sel ()
void init (const char *path, int open_flags, int bufsz)
void setup (int baud, int bits, char par, int stopbits, int min, int time)

Protected Member Functions

int fillbuf ()
void consume (int nchars)
void flush_input ()
void report_err (const char *msg,...)
void report_ok ()
int not_found (unsigned char c)
int not_hex (unsigned short &hexval)
int not_int (int &val)
int not_str (const char *str, unsigned int len)
int not_str (const std::string &s)
int not_str (const char *str)
int not_float (float &val)

Protected Attributes

unsigned int nc
unsigned int cp
unsigned char * buf
int bufsize
int n_fills
int n_empties
int n_eagain
int n_eintr

Private Member Functions

void sersel_init ()

Private Attributes

int n_errors
int n_suppressed
int total_errors
int total_suppressed

Detailed Description

A Selectee for monitoring a serial line.

Definition at line 40 of file SerSelector.h.


Constructor & Destructor Documentation

Ser_Sel::Ser_Sel ( const char *  path,
int  open_flags,
int  bufsz 
)
Parameters:
pathThe full path to the serial device. If path == NULL, the fd will not be opened.
open_flagsFlags from <fcntl.h> passed to open()
bufszThe size buffer to be allocated.

Definition at line 67 of file SerSelector.cc.

References init(), and sersel_init().

Here is the call graph for this function:

Ser_Sel::Ser_Sel ( )

Definition at line 73 of file SerSelector.cc.

References sersel_init().

Here is the call graph for this function:

Ser_Sel::~Ser_Sel ( )

Frees the allocated buffer and reports statistics.

Definition at line 117 of file SerSelector.cc.

References buf, free_memory, n_eagain, n_eintr, n_empties, n_fills, nl_error, total_errors, and total_suppressed.


Member Function Documentation

void Ser_Sel::consume ( int  nchars) [protected]

Each call to consume() increments the n_empties counter which is reported at termination. If n_fills is much greater than n_empties, you may need to adjust your min and time settings for more efficient operation.

Parameters:
ncharsnumber of characters to remove from front of buffer

Definition at line 218 of file SerSelector.cc.

References buf, cp, n_empties, and nc.

int Ser_Sel::fillbuf ( ) [protected]

Reads characters from the device, reporting any errors. Guarantees that buf is NUL-terminated, and sets nc to the total number of characters. Each call to fillbuf() increments the n_fills counter, which is reported at termination

Returns:
non-zero on error.

Definition at line 190 of file SerSelector.cc.

References buf, bufsize, Selectee::fd, n_eagain, n_eintr, n_fills, nc, and nl_error.

Referenced by flush_input().

Here is the caller graph for this function:

void Ser_Sel::flush_input ( ) [protected]

Invokes fillbuf() until there is no input remaining.

Definition at line 235 of file SerSelector.cc.

References cp, fillbuf(), and nc.

Here is the call graph for this function:

void Ser_Sel::init ( const char *  path,
int  open_flags,
int  bufsz 
)
Parameters:
pathThe full path to the serial device. If path == NULL, the fd will not be opened.
open_flagsFlags from <fcntl.h> passed to open()
bufszThe size buffer to be allocated.

Definition at line 83 of file SerSelector.cc.

References buf, bufsize, Selectee::fd, Selectee::flags, new_memory(), Selector::Sel_Read, and tm_open_name().

Referenced by Ser_Sel().

Here is the call graph for this function:

Here is the caller graph for this function:

int Ser_Sel::not_float ( float &  val) [protected]

Parsing utility function to convert a string in the input buffer to a float value. Updates cp to point just after the converted string on success.

Parameters:
val[out]The converted value
Returns:
zero if the conversion succeeded.

Definition at line 401 of file SerSelector.cc.

References buf, bufsize, cp, msg(), nc, nl_assert, and report_err().

Here is the call graph for this function:

int Ser_Sel::not_found ( unsigned char  c) [protected]

Parsing utility function that searches forward in the buffer for the specified start character. Updates cp to point just past the start char. If the character is not found, the buffer is emptied.

Parameters:
cThe search character
Returns:
zero if the character is found.

Definition at line 289 of file SerSelector.cc.

References buf, cp, nc, and report_err().

Here is the call graph for this function:

int Ser_Sel::not_hex ( unsigned short &  hexval) [protected]

Parsing utility function to read in a hex integer starting at the current position. Integer may be proceeded by optional whitespace.

Parameters:
[out]hexvalThe integer value
Returns:
zero if an integer was converted, non-zero if the current char is not a digit.

Definition at line 308 of file SerSelector.cc.

References buf, cp, nc, and report_err().

Here is the call graph for this function:

int Ser_Sel::not_int ( int &  val) [protected]

Parsing utility function to read in a decimal integer starting at the current position. Integer may be proceeded by optional whitespace and an optional sign.

Parameters:
[out]valThe integer value
Returns:
zero if an integer was converted, non-zero if the current char is not a digit.

Definition at line 332 of file SerSelector.cc.

References buf, cp, nc, and report_err().

Here is the call graph for this function:

int Ser_Sel::not_str ( const char *  str_in,
unsigned int  len 
) [protected]

Parsing utility function to check that the string matches the input at the current position. On success, advances cp to just after the matched string. On failure, cp points to the first character that does not match. If only a partial record was received, that could be the NUL at the end of the buffer.

Parameters:
strThe comparison string.
Returns:
zero if the string matches the input buffer.

Definition at line 365 of file SerSelector.cc.

References ascii_escape(), buf, cp, nc, nl_error, and report_err().

Referenced by not_str().

Here is the call graph for this function:

Here is the caller graph for this function:

int Ser_Sel::not_str ( const char *  str) [protected]

Definition at line 385 of file SerSelector.cc.

References not_str().

Here is the call graph for this function:

int Ser_Sel::not_str ( const std::string &  s) [protected]

Definition at line 389 of file SerSelector.cc.

References not_str().

Here is the call graph for this function:

void Ser_Sel::report_err ( const char *  fmt,
  ... 
) [protected]

Reports the error message, provided the qualified error count is not above the limit. report_ok() will decrement the qualified error count. It is assumed that all messages are of severity MSG_ERR. Messages at other levels, either more or less severe, should be sent directly to msg().

Definition at line 250 of file SerSelector.cc.

References ascii_escape(), buf, msg(), msgv(), n_errors, n_suppressed, nc, QERR_THRESHOLD, total_errors, and total_suppressed.

Referenced by not_float(), not_found(), not_hex(), not_int(), and not_str().

Here is the call graph for this function:

Here is the caller graph for this function:

void Ser_Sel::report_ok ( ) [protected]

Indicate that data has successfully been received.

Definition at line 273 of file SerSelector.cc.

References msg(), n_errors, and n_suppressed.

Here is the call graph for this function:

void Ser_Sel::sersel_init ( ) [private]

Definition at line 101 of file SerSelector.cc.

References buf, bufsize, cp, Selectee::fd, n_eagain, n_eintr, n_empties, n_errors, n_fills, n_suppressed, nc, total_errors, and total_suppressed.

Referenced by Ser_Sel().

Here is the caller graph for this function:

void Ser_Sel::setup ( int  baud,
int  bits,
char  par,
int  stopbits,
int  min,
int  time 
)

Initializes the serial parameters for the device. The min and time parameters can be used to optimize reads. See tcsetattr VMIN and VTIME parameters for more information.

Parameters:
baudThe desired baud rate
bitsnumber of data bits (5-8)
par'n', 'e', 'o', 'm', 's' for none, even, odd, mark or space.
stopbitsThe number of stop bits: 1 or 2
minThe minimum number of characters to respond to
timeThe time gap value

Definition at line 137 of file SerSelector.cc.

References Selectee::fd, and nl_error.


Member Data Documentation

unsigned char* Ser_Sel::buf [protected]
int Ser_Sel::bufsize [protected]

Definition at line 63 of file SerSelector.h.

Referenced by fillbuf(), init(), not_float(), and sersel_init().

unsigned int Ser_Sel::cp [protected]
int Ser_Sel::n_eagain [protected]

Definition at line 65 of file SerSelector.h.

Referenced by fillbuf(), sersel_init(), and ~Ser_Sel().

int Ser_Sel::n_eintr [protected]

Definition at line 65 of file SerSelector.h.

Referenced by fillbuf(), sersel_init(), and ~Ser_Sel().

int Ser_Sel::n_empties [protected]

Definition at line 64 of file SerSelector.h.

Referenced by consume(), sersel_init(), and ~Ser_Sel().

int Ser_Sel::n_errors [private]

Number of qualified errors. Decremented by report_ok()

Definition at line 69 of file SerSelector.h.

Referenced by report_err(), report_ok(), and sersel_init().

int Ser_Sel::n_fills [protected]

Definition at line 64 of file SerSelector.h.

Referenced by fillbuf(), sersel_init(), and ~Ser_Sel().

int Ser_Sel::n_suppressed [private]

Number of messages currently suppressed.

Definition at line 71 of file SerSelector.h.

Referenced by report_err(), report_ok(), and sersel_init().

unsigned int Ser_Sel::nc [protected]
int Ser_Sel::total_errors [private]

Total number of errors found.

Definition at line 73 of file SerSelector.h.

Referenced by report_err(), sersel_init(), and ~Ser_Sel().

Definition at line 74 of file SerSelector.h.

Referenced by report_err(), sersel_init(), and ~Ser_Sel().


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines