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 (ROSaicNodeBase *node, boost::shared_ptr< StreamT > stream, boost::shared_ptr< boost::asio::io_service > io_service, std::size_t buffer_size=16384) | |
Class constructor. More... | |
bool | isOpen () const |
Determines whether or not the connection is open. More... | |
bool | send (const std::string &cmd) |
Sends commands via the I/O stream. More... | |
void | setCallback (const Callback &callback) |
Allows to connect to the CallbackHandlers class. More... | |
void | wait (uint16_t *count) |
virtual | ~AsyncManager () |
![]() | |
virtual | ~Manager () |
Protected Member Functions | |
void | asyncReadSomeHandler (const boost::system::error_code &error, std::size_t bytes_transferred) |
Handler for async_read_some (Boost library).. More... | |
void | callAsyncWait (uint16_t *count) |
Handles the ROS_INFO throwing (if no incoming message) More... | |
void | close () |
Closes stream "stream_". More... | |
void | read () |
void | tryParsing () |
void | write (const std::string &cmd) |
Sends command "cmd" to the Rx. More... | |
Protected Attributes | |
bool | allow_writing_ |
boost::shared_ptr< boost::thread > | async_background_thread_ |
New thread for receiving incoming messages. More... | |
const std::size_t | buffer_size_ |
Size of in_ buffers. More... | |
CircularBuffer | circular_buffer_ |
const uint16_t | count_max_ |
uint16_t | do_read_count_ |
std::vector< uint8_t > | in_ |
Buffer for async_read_some() to read continuous SBF/NMEA stream. More... | |
boost::shared_ptr< boost::asio::io_service > | io_service_ |
io_context object More... | |
boost::mutex | parse_mutex_ |
Mutex to control changes of class variable "try_parsing". More... | |
boost::condition_variable | parsing_condition_ |
Condition variable complementing "parse_mutex". More... | |
boost::shared_ptr< boost::thread > | parsing_thread_ |
New thread for receiving incoming messages. More... | |
Callback | read_callback_ |
Callback to be called once message arrives. More... | |
Timestamp | recvTime_ |
Timestamp of receiving buffer. More... | |
bool | stopping_ |
Whether or not we want to sever the connection to the Rx. More... | |
boost::shared_ptr< StreamT > | stream_ |
Stream, represents either serial or TCP/IP connection. More... | |
boost::asio::deadline_timer | timer_ |
bool | try_parsing_ |
Determines when the tryParsing() method will attempt parsing SBF/NMEA. More... | |
boost::shared_ptr< boost::thread > | waiting_thread_ |
New thread for receiving incoming messages. More... | |
Private Attributes | |
ROSaicNodeBase * | node_ |
Pointer to the node. More... | |
Additional Inherited Members | |
![]() | |
typedef boost::function< void(Timestamp, 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 116 of file async_manager.hpp.
io_comm_rx::AsyncManager< StreamT >::AsyncManager | ( | ROSaicNodeBase * | node, |
boost::shared_ptr< StreamT > | stream, | ||
boost::shared_ptr< boost::asio::io_service > | io_service, | ||
std::size_t | buffer_size = 16384 |
||
) |
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 | |
[in] | buffer_size | Size of the circular buffer in bytes |
Definition at line 329 of file async_manager.hpp.
|
virtual |
Definition at line 375 of file async_manager.hpp.
|
protected |
Handler for async_read_some (Boost library)..
Definition at line 401 of file async_manager.hpp.
|
protected |
Handles the ROS_INFO throwing (if no incoming message)
Definition at line 323 of file async_manager.hpp.
|
protected |
Closes stream "stream_".
Definition at line 432 of file async_manager.hpp.
|
inlinevirtual |
Determines whether or not the connection is open.
Implements io_comm_rx::Manager.
Definition at line 147 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 387 of file async_manager.hpp.
|
virtual |
Sends commands via the I/O stream.
cmd | The command to be sent |
Implements io_comm_rx::Manager.
Definition at line 299 of file async_manager.hpp.
|
inlinevirtual |
Allows to connect to the CallbackHandlers class.
callback | The function that becomes our callback, typically the readCallback() method of CallbackHandlers |
Implements io_comm_rx::Manager.
Definition at line 137 of file async_manager.hpp.
|
protected |
Tries parsing SBF/NMEA whenever the boolean class variable "try_parsing" is true
Definition at line 236 of file async_manager.hpp.
|
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 445 of file async_manager.hpp.
|
protected |
Sends command "cmd" to the Rx.
Definition at line 313 of file async_manager.hpp.
|
protected |
Determines when the asyncReadSomeHandler() method should write SBF/NMEA into the circular buffer
Definition at line 180 of file async_manager.hpp.
|
protected |
New thread for receiving incoming messages.
Definition at line 199 of file async_manager.hpp.
|
protected |
Size of in_ buffers.
Definition at line 214 of file async_manager.hpp.
|
protected |
Circular buffer to avoid unsuccessful SBF/NMEA parsing due to incomplete messages
Definition at line 196 of file async_manager.hpp.
|
protected |
Number of seconds before ROS_INFO message is thrown (if no incoming message)
Definition at line 222 of file async_manager.hpp.
|
protected |
Number of times the DoRead() method has been called (only counts initially)
Definition at line 229 of file async_manager.hpp.
|
protected |
Buffer for async_read_some() to read continuous SBF/NMEA stream.
Definition at line 192 of file async_manager.hpp.
|
protected |
io_context object
Definition at line 189 of file async_manager.hpp.
|
private |
Pointer to the node.
Definition at line 151 of file async_manager.hpp.
|
protected |
Mutex to control changes of class variable "try_parsing".
Definition at line 173 of file async_manager.hpp.
|
protected |
Condition variable complementing "parse_mutex".
Definition at line 183 of file async_manager.hpp.
|
protected |
New thread for receiving incoming messages.
Definition at line 202 of file async_manager.hpp.
|
protected |
Callback to be called once message arrives.
Definition at line 208 of file async_manager.hpp.
|
protected |
Timestamp of receiving buffer.
Definition at line 232 of file async_manager.hpp.
|
protected |
Whether or not we want to sever the connection to the Rx.
Definition at line 211 of file async_manager.hpp.
|
protected |
Stream, represents either serial or TCP/IP connection.
Definition at line 186 of file async_manager.hpp.
|
protected |
Boost timer for throwing ROS_INFO message once timed out due to lack of incoming messages
Definition at line 218 of file async_manager.hpp.
|
protected |
Determines when the tryParsing() method will attempt parsing SBF/NMEA.
Definition at line 176 of file async_manager.hpp.
|
protected |
New thread for receiving incoming messages.
Definition at line 205 of file async_manager.hpp.