5 #include <boost/asio/io_service.hpp>
6 #include <boost/asio/posix/stream_descriptor.hpp>
7 #include <boost/asio/write.hpp>
8 #include <boost/asio/read.hpp>
36 typedef std::shared_ptr<SerialDevice>
Ptr;
37 typedef std::shared_ptr<const SerialDevice>
ConstPtr;
41 const std::string &
getName()
const;
43 static Ptr open(boost::asio::io_service &context,
const std::string &path);
47 void setPositions(
const double *
const positions,
const std::size_t length);
48 void set(
const double *
const positions,
const double *
const velocities,
const std::size_t length);
56 SerialDevice(boost::asio::posix::stream_descriptor &&fd,
const std::string &name);
63 boost::system::error_code ec;
65 const size_t res = boost::asio::write(
fd_, boost::asio::buffer(
reinterpret_cast<const uint8_t *
>(&msg),
sizeof(msg)), boost::asio::transfer_all(), ec);
69 throw boost::system::system_error(ec);
76 boost::asio::posix::stream_descriptor
fd_;