ROSaic
|
This is the central interface between ROSaic and the Rx(s), managing I/O operations such as reading messages and sending commands.. More...
#include <async_manager.hpp>
Public Member Functions | |
AsyncManager (boost::shared_ptr< StreamT > stream, boost::shared_ptr< boost::asio::io_service > io_service, std::size_t buffer_size=8192) | |
Class constructor. More... | |
virtual | ~AsyncManager () |
void | setCallback (const Callback &callback) |
Sets the callback function. More... | |
void | wait (uint16_t *count) |
Waits count seconds before throwing ROS_INFO message in case no message from the receiver arrived. More... | |
bool | send (std::string cmd, std::size_t size) |
Sends commands via the I/O stream. More... | |
bool | isOpen () const |
Determines whether or not the connection is open. More... | |
![]() | |
virtual | ~Manager () |
Protected Member Functions | |
void | read () |
Reads in via async_read_some and hands certain number of bytes (bytes_transferred) over to async_read_some_handler. More... | |
void | asyncReadSomeHandler (const boost::system::error_code &error, std::size_t bytes_transferred) |
Handler for async_read_some (Boost library).. More... | |
void | write (std::string cmd, std::size_t size) |
Sends command "cmd" to the Rx. More... | |
void | close () |
Closes stream "stream_". More... | |
void | tryParsing () |
Tries parsing SBF/NMEA whenever the boolean class variable "try_parsing" is true. More... | |
void | callAsyncWait (uint16_t *count) |
Handles the ROS_INFO throwing (if no incoming message) More... | |
Protected Attributes | |
boost::mutex | parse_mutex_ |
Mutex to control changes of class variable "try_parsing". More... | |
bool | try_parsing_ |
Determines when the tryParsing() method will attempt parsing SBF/NMEA. More... | |
bool | allow_writing_ |
Determines when the asyncReadSomeHandler() method should write SBF/NMEA into the circular buffer. More... | |
boost::condition_variable | parsing_condition_ |
Condition variable complementing "parse_mutex". More... | |
boost::shared_ptr< StreamT > | stream_ |
Stream, represents either serial or TCP/IP connection. More... | |
boost::shared_ptr< boost::asio::io_service > | io_service_ |
io_context object More... | |
std::vector< uint8_t > | in_ |
Buffer for async_read_some() to read continuous SBF/NMEA stream. More... | |
CircularBuffer | circular_buffer_ |
Circular buffer to avoid unsuccessful SBF/NMEA parsing due to incomplete messages. More... | |
uint8_t * | to_be_parsed_ |
Memory location where read_callback_ will start reading unless part of SBF/NMEA had to be appended before. More... | |
boost::shared_ptr< boost::thread > | async_background_thread_ |
New thread for receiving incoming messages. More... | |
Callback | read_callback_ |
Callback to be called once message arrives. More... | |
bool | stopping_ |
Whether or not we want to sever the connection to the Rx. More... | |
const std::size_t | buffer_size_ |
Size of in_ buffers. More... | |
boost::asio::deadline_timer | timer_ |
Boost timer for throwing ROS_INFO message once timed out due to lack of incoming messages. More... | |
const uint16_t | count_max_ |
Number of seconds before ROS_INFO message is thrown (if no incoming message) More... | |
uint16_t | do_read_count_ |
Number of times the DoRead() method has been called (only counts initially) More... | |
Additional Inherited Members | |
![]() | |
typedef boost::function< void(const uint8_t *, std::size_t &)> | Callback |
This is the central interface between ROSaic and the Rx(s), managing I/O operations such as reading messages and sending commands..
StreamT is either boost::asio::serial_port or boost::asio::tcp::ip
Definition at line 112 of file async_manager.hpp.
io_comm_rx::AsyncManager< StreamT >::AsyncManager | ( | boost::shared_ptr< StreamT > | stream, |
boost::shared_ptr< boost::asio::io_service > | io_service, | ||
std::size_t | buffer_size = 8192 |
||
) |
Class constructor.
stream | Whether TCP/IP or serial communication, either boost::asio::serial_port or boost::asio::tcp::ip |
io_service | The io_context object. The io_context represents your program's link to the operating system's I/O services. |
Definition at line 296 of file async_manager.hpp.
References io_comm_rx::AsyncManager< StreamT >::async_background_thread_, io_comm_rx::AsyncManager< StreamT >::buffer_size_, io_comm_rx::AsyncManager< StreamT >::callAsyncWait(), io_comm_rx::AsyncManager< StreamT >::in_, io_comm_rx::AsyncManager< StreamT >::io_service_, io_comm_rx::AsyncManager< StreamT >::stream_, and io_comm_rx::AsyncManager< StreamT >::tryParsing().
|
virtual |
Definition at line 328 of file async_manager.hpp.
References io_comm_rx::AsyncManager< StreamT >::async_background_thread_.
|
protected |
Handler for async_read_some (Boost library)..
Definition at line 348 of file async_manager.hpp.
References io_comm_rx::AsyncManager< StreamT >::allow_writing_, io_comm_rx::AsyncManager< StreamT >::buffer_size_, io_comm_rx::AsyncManager< StreamT >::circular_buffer_, io_comm_rx::AsyncManager< StreamT >::in_, io_comm_rx::AsyncManager< StreamT >::io_service_, io_comm_rx::AsyncManager< StreamT >::parse_mutex_, io_comm_rx::AsyncManager< StreamT >::parsing_condition_, io_comm_rx::AsyncManager< StreamT >::read_callback_, io_comm_rx::AsyncManager< StreamT >::stopping_, io_comm_rx::AsyncManager< StreamT >::try_parsing_, and CircularBuffer::write().
|
protected |
Handles the ROS_INFO throwing (if no incoming message)
Definition at line 290 of file async_manager.hpp.
References io_comm_rx::AsyncManager< StreamT >::wait().
Referenced by io_comm_rx::AsyncManager< StreamT >::AsyncManager().
|
protected |
Closes stream "stream_".
Definition at line 377 of file async_manager.hpp.
References io_comm_rx::AsyncManager< StreamT >::stopping_, and io_comm_rx::AsyncManager< StreamT >::stream_.
|
inlinevirtual |
Determines whether or not the connection is open.
Implements io_comm_rx::Manager.
Definition at line 134 of file async_manager.hpp.
|
protected |
Reads in via async_read_some and hands certain number of bytes (bytes_transferred) over to async_read_some_handler.
Definition at line 334 of file async_manager.hpp.
References io_comm_rx::AsyncManager< StreamT >::do_read_count_, io_comm_rx::AsyncManager< StreamT >::in_, and io_comm_rx::AsyncManager< StreamT >::stream_.
|
virtual |
Sends commands via the I/O stream.
cmd | The command to be sent |
size | The size of the command |
Implements io_comm_rx::Manager.
Definition at line 266 of file async_manager.hpp.
|
inlinevirtual |
Sets the callback function.
Implements io_comm_rx::Manager.
Definition at line 123 of file async_manager.hpp.
References io_comm_rx::Manager::send(), and io_comm_rx::Manager::wait().
|
protected |
Tries parsing SBF/NMEA whenever the boolean class variable "try_parsing" is true.
Definition at line 207 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::AsyncManager().
|
virtual |
Waits count seconds before throwing ROS_INFO message in case no message from the receiver arrived.
Implements io_comm_rx::Manager.
Definition at line 389 of file async_manager.hpp.
References io_comm_rx::AsyncManager< StreamT >::async_background_thread_, io_comm_rx::AsyncManager< StreamT >::count_max_, io_comm_rx::AsyncManager< StreamT >::do_read_count_, and io_comm_rx::AsyncManager< StreamT >::timer_.
Referenced by io_comm_rx::AsyncManager< StreamT >::callAsyncWait().
|
protected |
Sends command "cmd" to the Rx.
Definition at line 282 of file async_manager.hpp.
|
protected |
Determines when the asyncReadSomeHandler() method should write SBF/NMEA into the circular buffer.
Definition at line 160 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler().
|
protected |
New thread for receiving incoming messages.
Definition at line 181 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::AsyncManager(), io_comm_rx::AsyncManager< StreamT >::wait(), and io_comm_rx::AsyncManager< StreamT >::~AsyncManager().
|
protected |
Size of in_ buffers.
Definition at line 190 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::AsyncManager(), and io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler().
|
protected |
Circular buffer to avoid unsuccessful SBF/NMEA parsing due to incomplete messages.
Definition at line 175 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler().
|
protected |
Number of seconds before ROS_INFO message is thrown (if no incoming message)
Definition at line 196 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::wait().
|
protected |
Number of times the DoRead() method has been called (only counts initially)
Definition at line 202 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::read(), and io_comm_rx::AsyncManager< StreamT >::wait().
|
protected |
Buffer for async_read_some() to read continuous SBF/NMEA stream.
Definition at line 172 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::AsyncManager(), io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler(), and io_comm_rx::AsyncManager< StreamT >::read().
|
protected |
io_context object
Definition at line 169 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::AsyncManager(), and io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler().
|
protected |
Mutex to control changes of class variable "try_parsing".
Definition at line 154 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler().
|
protected |
Condition variable complementing "parse_mutex".
Definition at line 163 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler().
|
protected |
Callback to be called once message arrives.
Definition at line 184 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler().
|
protected |
Whether or not we want to sever the connection to the Rx.
Definition at line 187 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler(), and io_comm_rx::AsyncManager< StreamT >::close().
|
protected |
Stream, represents either serial or TCP/IP connection.
Definition at line 166 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::AsyncManager(), io_comm_rx::AsyncManager< StreamT >::close(), and io_comm_rx::AsyncManager< StreamT >::read().
|
protected |
Boost timer for throwing ROS_INFO message once timed out due to lack of incoming messages.
Definition at line 193 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::wait().
|
protected |
Memory location where read_callback_ will start reading unless part of SBF/NMEA had to be appended before.
Definition at line 178 of file async_manager.hpp.
|
protected |
Determines when the tryParsing() method will attempt parsing SBF/NMEA.
Definition at line 157 of file async_manager.hpp.
Referenced by io_comm_rx::AsyncManager< StreamT >::asyncReadSomeHandler().