42 using boost::asio::serial_port_base;
50 baud_rate_(baud_rate),
51 serial_port_(io_service_)
67 catch (boost::system::system_error e)
69 std::cerr << e.what() << std::endl;
87 serial_port_.set_option(serial_port_base::character_size(8));
88 serial_port_.set_option(serial_port_base::parity(serial_port_base::parity::none));
89 serial_port_.set_option(serial_port_base::stop_bits(serial_port_base::stop_bits::one));
90 serial_port_.set_option(serial_port_base::flow_control(serial_port_base::flow_control::none));
92 catch (boost::system::system_error e)
94 std::cerr << e.what() << std::endl;
107 boost::function<
void (
const boost::system::error_code&,
size_t)> handler)
113 boost::function<
void (
const boost::system::error_code&,
size_t)> handler)
void do_async_read(const boost::asio::mutable_buffers_1 &buffer, boost::function< void(const boost::system::error_code &, size_t)> handler) override
Abstract base class for an asynchronous communication port.
void do_async_write(const boost::asio::const_buffers_1 &buffer, boost::function< void(const boost::system::error_code &, size_t)> handler) override
Serial(std::string port, unsigned int baud_rate)
Open a serial port.
boost::asio::serial_port serial_port_
bool set_baud_rate(unsigned int baud_rate)
Set serial port baud rate.