Пример #1
0
	void do_close(const boost::system::error_code& error)
	{ // something has gone wrong, so close the socket & make this object inactive
		if (error == boost::asio::error::operation_aborted) // if this call is the result of a timer cancel()
			return; // ignore it because the connection cancelled the timer
		if (error)
			cerr << "Error: " << error.message() << endl; // show the error message
		else
			cout << "Error: Connection did not succeed.\n";
		cout << "Press Enter to exit\n";
		serialPort.close();
		active_ = false;
	}
Пример #2
0
 /*
   Attempts to close and reopen the serial port
   Sleeps for one second before returning if an exception is caught
 */
 void open()
 {
   try
   {
     p.close();
     p.open(port);
     p.set_option(boost::asio::serial_port::baud_rate(baudrate));
     return;
   }
   catch (const std::exception &exc)
   {
     ROS_ERROR("DVL: error on open(port=%s): %s; reopening after delay", port.c_str(), exc.what());
     boost::this_thread::sleep(boost::posix_time::seconds(1));
   }
 }
Пример #3
0
 void abort()
 {
   p.close();
 }