nidas v1.2.3
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
nidas::util::Termios Class Reference

A class providing get/set methods into a termios structure. More...

#include <Termios.h>

Classes

struct  baudtable
 

Public Types

enum  parity { NONE , ODD , EVEN }
 
enum  flowcontrol { NOFLOWCONTROL , HARDWARE , SOFTWARE }
 HARDWARE flow control is CTSRTS. More...
 
typedef enum flowcontrol flowcontrol
 

Public Member Functions

 Termios ()
 Default constructor: 9600 n81, no flow control, canonical input, output.
 
 Termios (const struct termios *)
 Construct from an existing struct termios.
 
 Termios (int fd, const std::string &devname)
 Construct from an opened serial port.
 
virtual ~Termios ()
 
void apply (int fd, const std::string &devname)
 Set the termios options on a serial port.
 
void set (const struct termios *)
 Set all Termios parameters from the contents of struct termios.
 
const struct termios * get ()
 Get a const pointer to the internal struct termios.
 
bool setBaudRate (int val)
 
int getBaudRate () const
 
void setParity (enum parity val)
 
parity getParity () const
 
std::string getParityString () const
 
void setDataBits (int val)
 Set number of data bits to 5,6,7 or 8.
 
int getDataBits () const
 
void setStopBits (int val)
 Set number of stop bits, to 1 or 2.
 
int getStopBits () const
 
void setLocal (bool val)
 If local, then ignore carrier detect modem control line.
 
bool getLocal () const
 
void setFlowControl (flowcontrol val)
 Set flow control to NOFLOWCONTROL, HARDWARE or SOFTWARE.
 
flowcontrol getFlowControl () const
 
std::string getFlowControlString () const
 
void setRaw (bool val)
 Sets termios options for raw or non-raw(cooked) mode.
 
bool getRaw () const
 
void setRawLength (unsigned char val)
 
unsigned char getRawLength () const
 
void setRawTimeout (unsigned char val)
 
unsigned char getRawTimeout () const
 
tcflag_t & iflag ()
 
tcflag_t & oflag ()
 
tcflag_t & cflag ()
 
tcflag_t & lflag ()
 
cc_t * cc ()
 
tcflag_t getIflag () const
 
tcflag_t getOflag () const
 
void setDefaultTermios ()
 

Static Public Attributes

static struct nidas::util::Termios::baudtable bauds []
 

Private Attributes

struct termios _tio
 
unsigned char _rawlen
 
unsigned char _rawtimeout
 

Detailed Description

A class providing get/set methods into a termios structure.

Member Typedef Documentation

◆ flowcontrol

Member Enumeration Documentation

◆ flowcontrol

HARDWARE flow control is CTSRTS.

SOFTWARE is Xon/Xoff.

Enumerator
NOFLOWCONTROL 
HARDWARE 
SOFTWARE 

◆ parity

Enumerator
NONE 
ODD 
EVEN 

Constructor & Destructor Documentation

◆ Termios() [1/3]

Termios::Termios ( )

Default constructor: 9600 n81, no flow control, canonical input, output.

References setDefaultTermios().

◆ Termios() [2/3]

Termios::Termios ( const struct termios * termios_p)

Construct from an existing struct termios.

References _rawlen, _rawtimeout, and _tio.

◆ Termios() [3/3]

Termios::Termios ( int fd,
const std::string & devname )

Construct from an opened serial port.

Exceptions
IOException

References _rawlen, _rawtimeout, _tio, and fd.

◆ ~Termios()

virtual nidas::util::Termios::~Termios ( )
inlinevirtual

Member Function Documentation

◆ apply()

void Termios::apply ( int fd,
const std::string & devname )

Set the termios options on a serial port.

Exceptions
IOException

References _tio, and fd.

Referenced by nidas::core::SerialPortIODevice::applyTermios(), nidas::util::SerialPort::applyTermios(), and nidas::util::SerialPort::open().

◆ cc()

cc_t * nidas::util::Termios::cc ( )
inline

References _tio.

◆ cflag()

tcflag_t & nidas::util::Termios::cflag ( )
inline

References _tio.

◆ get()

const struct termios * Termios::get ( )

Get a const pointer to the internal struct termios.

References _tio.

◆ getBaudRate()

int Termios::getBaudRate ( ) const

◆ getDataBits()

int Termios::getDataBits ( ) const

◆ getFlowControl()

Termios::flowcontrol Termios::getFlowControl ( ) const

◆ getFlowControlString()

std::string Termios::getFlowControlString ( ) const

◆ getIflag()

tcflag_t nidas::util::Termios::getIflag ( ) const
inline

References _tio.

Referenced by nidas::util::SerialOptions::toString().

◆ getLocal()

bool Termios::getLocal ( ) const

References _tio.

Referenced by nidas::util::SerialOptions::toString().

◆ getOflag()

tcflag_t nidas::util::Termios::getOflag ( ) const
inline

References _tio.

Referenced by nidas::util::SerialOptions::toString().

◆ getParity()

Termios::parity Termios::getParity ( ) const

◆ getParityString()

std::string Termios::getParityString ( ) const

References EVEN, getParity(), NONE, and ODD.

◆ getRaw()

bool Termios::getRaw ( ) const

References _tio.

Referenced by nidas::util::SerialOptions::toString().

◆ getRawLength()

unsigned char Termios::getRawLength ( ) const

References _tio.

◆ getRawTimeout()

unsigned char Termios::getRawTimeout ( ) const

References _tio.

◆ getStopBits()

int Termios::getStopBits ( ) const

◆ iflag()

tcflag_t & nidas::util::Termios::iflag ( )
inline

References _tio.

Referenced by nidas::util::SerialOptions::parse().

◆ lflag()

tcflag_t & nidas::util::Termios::lflag ( )
inline

References _tio.

◆ oflag()

tcflag_t & nidas::util::Termios::oflag ( )
inline

References _tio.

Referenced by nidas::util::SerialOptions::parse().

◆ set()

void Termios::set ( const struct termios * termios_p)

Set all Termios parameters from the contents of struct termios.

References _rawlen, _rawtimeout, and _tio.

◆ setBaudRate()

bool Termios::setBaudRate ( int val)

◆ setDataBits()

void Termios::setDataBits ( int val)

Set number of data bits to 5,6,7 or 8.

References _tio.

Referenced by nidas::core::SerialSensor::fromDOMElement(), and nidas::util::SerialOptions::parse().

◆ setDefaultTermios()

void Termios::setDefaultTermios ( )

References _rawlen, _rawtimeout, and _tio.

Referenced by Termios().

◆ setFlowControl()

void Termios::setFlowControl ( flowcontrol val)

Set flow control to NOFLOWCONTROL, HARDWARE or SOFTWARE.

References _tio, HARDWARE, NOFLOWCONTROL, and SOFTWARE.

Referenced by nidas::util::SerialOptions::parse().

◆ setLocal()

void Termios::setLocal ( bool val)

If local, then ignore carrier detect modem control line.

References _tio.

Referenced by nidas::util::SerialOptions::parse().

◆ setParity()

void Termios::setParity ( enum parity val)

◆ setRaw()

void Termios::setRaw ( bool val)

Sets termios options for raw or non-raw(cooked) mode.

Parameters
valfalse sets the serial port for "cooked" mode, where canonical processing is applied to input lines, and output lines are post-processed before transmission. Input carriage returns are converted to newlines, and output newlines are converted to carriage returns. For other conversions, the appropriate bits (IGNCR, INLCR, ICRNL, ONLCR, OCRNL) from termios.h should be set in iflag() and oflag() after the call to setRaw(). true sets the serial port for "raw" mode, where canonical input and post output processing are not performed. THE VMIN and VTIME members of c_cc are set to getRawLength() and getRawTimeout() respectfully.

References _rawlen, _rawtimeout, and _tio.

Referenced by nidas::util::SerialOptions::parse(), nidas::core::SerialPortIODevice::SerialPortIODevice(), nidas::core::SerialPortIODevice::SerialPortIODevice(), and nidas::core::SerialSensor::SerialSensor().

◆ setRawLength()

void Termios::setRawLength ( unsigned char val)

◆ setRawTimeout()

void Termios::setRawTimeout ( unsigned char val)

◆ setStopBits()

void Termios::setStopBits ( int val)

Set number of stop bits, to 1 or 2.

References _tio.

Referenced by nidas::core::SerialSensor::fromDOMElement(), and nidas::util::SerialOptions::parse().

Member Data Documentation

◆ _rawlen

unsigned char nidas::util::Termios::_rawlen
private

◆ _rawtimeout

unsigned char nidas::util::Termios::_rawtimeout
private

◆ _tio

struct termios nidas::util::Termios::_tio
private

◆ bauds

Termios::baudtable Termios::bauds
static

Referenced by getBaudRate(), and setBaudRate().


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