42 using boost::asio::serial_port_base;
48 Comm(message_handler),
50 baud_rate_(baud_rate),
51 serial_port_(io_service_)
67 catch (boost::system::system_error e)
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)
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.
MessageHandler & message_handler_
virtual void error(const std::string &message)=0
void do_async_write(const boost::asio::const_buffers_1 &buffer, boost::function< void(const boost::system::error_code &, size_t)> handler) override
boost::asio::serial_port serial_port_
Abstract base class for message handler.
Serial(std::string port, unsigned int baud_rate, MessageHandler &message_handler=default_message_handler_)
Open a serial port.
bool set_baud_rate(unsigned int baud_rate)
Set serial port baud rate.