24#ifndef GOBY_MIDDLEWARE_IO_LINE_BASED_SERIAL_H
25#define GOBY_MIDDLEWARE_IO_LINE_BASED_SERIAL_H
30#include <boost/asio/read_until.hpp>
31#include <boost/asio/streambuf.hpp>
32#include <boost/system/error_code.hpp>
70 bool use_indexed_groups =
false>
73 ThreadType, use_indexed_groups>
76 ThreadType, use_indexed_groups>;
83 :
Base(config, index), eol_matcher_(this->cfg().end_of_line())
91 void async_read()
override;
95 boost::asio::streambuf buffer_;
105 bool use_indexed_groups>
107 subscribe_layer, ThreadType,
108 use_indexed_groups>::async_read()
110 boost::asio::async_read_until(
111 this->mutable_serial_port(), buffer_, eol_matcher_,
112 [
this](
const boost::system::error_code& ec, std::size_t bytes_transferred) {
113 if (!ec && bytes_transferred > 0)
115 std::string bytes(bytes_transferred, 0);
116 std::istream is(&buffer_);
117 is.read(&bytes[0], bytes_transferred);
118 this->handle_read_success(bytes_transferred, bytes);
123 this->handle_read_error(ec);
Class for grouping publications in the Goby middleware. Analogous to "topics" in ROS,...
Implements Thread for a three layer middleware setup ([ intervehicle [ interprocess [ interthread ] ]...
Reads/Writes strings from/to serial port using a line-based (typically ASCII) protocol with a defined...
SerialThreadLineBased(const goby::middleware::protobuf::SerialConfig &config, int index=-1)
Constructs the thread.
~SerialThreadLineBased() override
Provides a matching function object for the boost::asio::async_read_until based on a std::regex.
The global namespace for the Goby project.