27#ifndef NIDAS_UTIL_SERIALPORT_H
28#define NIDAS_UTIL_SERIALPORT_H
41namespace nidas {
namespace util {
105 virtual int open(
int mode = O_RDONLY);
193 virtual int read(
char *buf,
int len);
197 virtual int write(
const void *buf,
int len);
Definition SerialPort.h:44
void flushOutput()
Do a tcflush() system call on the device.
Definition SerialPort.cc:209
int _savealloc
Definition SerialPort.h:286
bool _blocking
Definition SerialPort.h:288
static int createPty(bool hup)
Create a pseudo-terminal and return the file descriptor.
Definition SerialPort.cc:368
int getModemStatus()
Get the current state of the modem bits.
Definition SerialPort.cc:138
void flushBoth()
Definition SerialPort.cc:223
static bool waitForOpen(int fd, int timeout)
Wait up to timeout seconds for pts to be opened.
Definition SerialPort.cc:438
char * _savep
Definition SerialPort.h:280
static int createPtyLink(const std::string &linkname)
Static utility that creates a pseudo-terminal, returning the file descriptor of the master side and c...
Definition SerialPort.cc:429
void drain()
Do a tcdrain() system call on the device.
Definition SerialPort.cc:202
const std::string & getName() const
Get device name of the SerialPort.
Definition SerialPort.h:94
state
Definition SerialPort.h:278
@ OK
Definition SerialPort.h:278
@ TIMEOUT_OR_EOF
Definition SerialPort.h:278
void setModemStatus(int val)
Set the current state of the modem bits.
Definition SerialPort.cc:147
Termios & termios()
Writable reference to the SerialPort's Termios.
Definition SerialPort.h:79
void flushInput()
Do a tcflush() system call on the device.
Definition SerialPort.cc:216
char * _savebuf
Definition SerialPort.h:282
virtual int read(char *buf, int len)
Definition SerialPort.cc:313
int timeoutOrEOF() const
Definition SerialPort.h:179
void applyTermios()
Apply the Termios settings to an opened serial port.
Definition SerialPort.cc:101
std::string _name
Definition SerialPort.h:276
virtual ~SerialPort()
close the file descriptor if is is open.
Definition SerialPort.cc:73
static std::string modemFlagsToString(int modem)
Definition SerialPort.cc:174
void close()
close the file descriptor.
Definition SerialPort.cc:80
Termios _termios
Definition SerialPort.h:272
void clearModemBits(int val)
Clear the indicated modem bits.
Definition SerialPort.cc:154
int getFd() const
Definition SerialPort.h:114
virtual char readchar()
Do a buffered read and return character read.
Definition SerialPort.cc:331
void setName(const std::string &val)
Set device name of the SerialPort.
Definition SerialPort.h:99
void setBlocking(bool val)
Definition SerialPort.cc:107
int _savelen
Definition SerialPort.h:284
virtual int readUntil(char *buf, int len, char term)
Read bytes until either the term character is read, or len-1 number of characters have been read.
Definition SerialPort.cc:230
bool getCarrierDetect()
Definition SerialPort.cc:168
SerialPort()
Definition SerialPort.cc:49
SerialPort & operator=(const SerialPort &)
No assignment.
void setModemBits(int val)
Set the indicated modem bits.
Definition SerialPort.cc:161
virtual int open(int mode=O_RDONLY)
open the serial port.
Definition SerialPort.cc:90
virtual int readLine(char *buf, int len)
Do a readUntil with a newline terminator.
Definition SerialPort.cc:297
enum nidas::util::SerialPort::state _state
virtual int write(const void *buf, int len)
Definition SerialPort.cc:303
static void createLinkToPty(const std::string &linkname, int fd)
Create a symbolic link to ptsname(fd).
Definition SerialPort.cc:391
bool getBlocking()
Definition SerialPort.cc:126
const Termios & getTermios() const
Readonly reference to Termios.
Definition SerialPort.h:84
int _fd
Definition SerialPort.h:274
A class providing get/set methods into a termios structure.
Definition Termios.h:48
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948
int fd
Definition twod.c:56