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>;
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);