10 #ifndef GBXSERIALACFR_SERIAL_H 11 #define GBXSERIALACFR_SERIAL_H 14 #include <gbxserialacfr/uncopyable.h> 15 #include <gbxserialacfr/lockfile/lockfile.h> 27 : message_(message) {}
29 : message_(message) {}
31 virtual const char* what()
const throw() {
return message_.c_str(); }
48 Timeout(
int s,
int us )
61 Serial(
const std::string &dev,
63 const Timeout &timeout,
65 bool useLockFile =
true );
74 void setBaudRate(
int baud);
78 void setTimeout(
const Timeout &timeout );
82 const Timeout &
timeout()
const {
return timeout_; }
87 int read(
void *buf,
int count);
99 int readFull(
void *buf,
int count);
111 int readStringUntil( std::string &str,
char termchar );
116 {
return readStringUntil(str,
'\n'); }
119 int bytesAvailable();
125 int bytesAvailableWait();
128 int write(
const void *buf,
int count);
132 int writeString(
const char *buf);
133 inline int writeString(
const std::string &s) {
134 return writeString(s.c_str());
148 std::string getStatusString();
159 WaitStatus waitForDataOrTimeout(
void);
162 void open(
int flags=0);
165 void close()
throw();
167 bool timeoutsEnabled()
const 168 {
return !( timeout_.sec == 0 && timeout_.usec == 0 ); }
170 const std::string dev_;
int readLine(std::string &str)
Definition: serial.h:115
Encapsulates a serial port.
Definition: serial.h:43
Simple serial port interface.
Definition: gbxnovatelacfr/driver.h:21
int fileDescriptor()
This gives direct access to the file descriptor: be careful with this...
Definition: serial.h:145
Exception thrown by Serial.
Definition: serial.h:22
const Timeout & timeout() const
Definition: serial.h:82
void setDebugLevel(int debugLevel)
Debug messages are printed to stdout. debugLevel should be in the range [0,3].
Definition: serial.h:71
Definition: lockfile.h:57