38 #ifndef KVH_SERIAL_PORT_H 39 #define KVH_SERIAL_PORT_H 96 void open(
const char* port_name,
int baud_rate = 115200);
125 int write(
const char* data,
int length = -1);
137 int read(
char* data,
int max_length,
int timeout = -1);
151 int readBytes(
char* data,
int length,
int timeout = -1);
165 int readLine(
char* data,
int length,
int timeout = -1);
178 bool readLine(std::string* data,
int timeout = -1);
191 bool readBetween(std::string* data,
char start,
char end,
int timeout = -1);
208 bool startReadStream(std::function<
void(
char*,
int)>
f);
220 bool startReadLineStream(std::function<
void(std::string*)>
f);
234 bool startReadBetweenStream(std::function<
void(std::string*)>
f,
char start,
char end);
261 void readLineThread();
271 void readBetweenThread(
char start,
char end);
289 #endif // KVH_SERIAL_PORT_H SerialException(const char *msg)
std::function< void(std::string *)> readBetweenCallback
Stream readBetween callback boost function.
SerialBufferFilledException(const char *msg)
bool stream_paused_
Whether streaming is paused or not.
SerialTimeoutException(const char *msg)
std::thread * stream_thread_
Stream thread.
bool stream_stopped_
Whether streaming is stopped or not.
bool portOpen()
Check whether the port is open or not.
std::function< void(std::string *)> readLineCallback
Stream readLine callback boost function.
std::function< void(char *, int)> readCallback
Stream read callback boost function.
C++ serial port class for ROS.
int baudRate()
Get the current baud rate.