コード例 #1
0
ファイル: RmpUsb.cpp プロジェクト: pxlong/segwayrmp
  RmpUsb::Impl::Impl(const std::string& rDevicePort)
    : m_IoService()
    , m_SerialPort(m_IoService)
    , m_Timer(m_IoService)
  {
    boost::system::error_code errorCode;
    m_SerialPort.open(rDevicePort, errorCode);

    if (errorCode.value() != boost::system::errc::success)
    {
      std::stringstream stringStream;
      stringStream << "Unable to open serial port " << rDevicePort << ": " << errorCode.message();
      
      throw std::runtime_error(stringStream.str());
    }
    
    m_SerialPort.set_option(boost::asio::serial_port_base::baud_rate(BAUD_RATE));
    m_SerialPort.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none));
    m_SerialPort.set_option(boost::asio::serial_port_base::character_size(CHARACTER_SIZE));
    m_SerialPort.set_option(boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none));
    m_SerialPort.set_option(boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one));
    
    m_Timer.expires_at(boost::posix_time::pos_infin);
         
    CheckDeadline();
  }
コード例 #2
0
ファイル: TCPServer.cpp プロジェクト: gitmesen/carla
 TCPServer::TCPServer()
     : _service(),
       _acceptor(_service),
       _socket(_service),
       _deadline(_service) {
   // No deadline is required until the first socket operation is started. We
   // set the deadline to positive infinity so that the actor takes no action
   // until a specific deadline is set.
   _deadline.expires_at(boost::posix_time::pos_infin);
   // Start the persistent actor that checks for deadline expiry.
   CheckDeadline();
 }