24#ifndef GOBY_MIDDLEWARE_IO_LINE_BASED_PTY_H
25#define GOBY_MIDDLEWARE_IO_LINE_BASED_PTY_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>
72 subscribe_layer, ThreadType, use_indexed_groups>
75 ThreadType, use_indexed_groups>;
82 :
Base(config, index), eol_matcher_(this->cfg().end_of_line())
90 void async_read()
override;
94 boost::asio::streambuf buffer_;
104 bool use_indexed_groups>
106 subscribe_layer, ThreadType,
107 use_indexed_groups>::async_read()
109 boost::asio::async_read_until(
110 this->mutable_socket(), buffer_, eol_matcher_,
111 [
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...
PTYThreadLineBased(const goby::middleware::protobuf::PTYConfig &config, int index=-1)
Constructs the thread.
Provides a matching function object for the boost::asio::async_read_until based on a std::regex.
The global namespace for the Goby project.