class ugcs::vsm::Mavlink_demuxer¶
Overview¶
Mavlink message demultiplexer based on message, system and component identifiers. More…
#include <mavlink_demuxer.h> class Mavlink_demuxer { public: // typedefs typedef signed Message_id; typedef int64_t System_id; typedef signed Component_id; typedef ugcs::vsm::Param_exception<Duplicate_handler_dummy_struct,> Duplicate_handler; typedef Callback_proxy<void, typename mavlink::Message<message_id, Extention_type>::Ptr> Handler; typedef Callback_proxy<bool, Io_buffer::Ptr, mavlink::MESSAGE_ID_TYPE, System_id, uint8_t, uint32_t> Default_handler; // structs struct Duplicate_handler_dummy_struct; // classes template <mavlink::MESSAGE_ID_TYPE message_id, class Extention_type> class Callback; class Callback_base; // fields static constexpr Message_id MESSAGE_ID_ANY = -1; static constexpr System_id SYSTEM_ID_ANY = -1; static constexpr Component_id COMPONENT_ID_ANY = -1; // construction Mavlink_demuxer(const Mavlink_demuxer&); // methods void Disable(); void Register_default_handler(Default_handler handler); template <mavlink::MESSAGE_ID_TYPE message_id, class Extention_type> Key Register_handler( Handler<message_id, Extention_type> handler, System_id system_id = SYSTEM_ID_ANY, Component_id component_id = COMPONENT_ID_ANY, Request_processor::Ptr processor = nullptr ); bool Demux( Io_buffer::Ptr buffer, mavlink::MESSAGE_ID_TYPE message_id, System_id system_id, uint8_t component_id, uint32_t request_id ); void Unregister_handler(Key&); };
Detailed Documentation¶
Mavlink message demultiplexer based on message, system and component identifiers.
Supposed to be conveniently used with Mavlink_decoder. Messages from different mavlink extensions but with same identifiers can not be demultiplexed simultaneously.
Typedefs¶
typedef signed Message_id
Helper type for Mavlink message id which is able to hold special values.
typedef int64_t System_id
Helper type for Mavlink system id which is able to hold special values.
typedef signed Component_id
Helper type for Mavlink component id which is able to hold special values.
typedef Callback_proxy<void, typename mavlink::Message<message_id, Extention_type>::Ptr> Handler
Handler type for the specific demultiplexed Mavlink message.
typedef Callback_proxy<bool, Io_buffer::Ptr, mavlink::MESSAGE_ID_TYPE, System_id, uint8_t, uint32_t> Default_handler
Default handler which is called for all Mavlink messages which does not have a handler.
Io_buffer contains the raw payload data.
Returns:
true message will be resubmitted to demuxer for further processing, otherwise false.
Fields¶
static constexpr Message_id MESSAGE_ID_ANY = -1
Special value representing any Mavlink message id.
static constexpr System_id SYSTEM_ID_ANY = -1
Special value representing any Mavlink system id.
static constexpr Component_id COMPONENT_ID_ANY = -1
Special value representing any Mavlink component id.
Construction¶
Mavlink_demuxer(const Mavlink_demuxer&)
Delete copy constructor.
Methods¶
void Disable()
Should be called prior to intention to delete the instance.
void Register_default_handler(Default_handler handler)
Register default handler.
Called when more specific handler does not exist. Always called from the thread, which calls Demux method.
template <mavlink::MESSAGE_ID_TYPE message_id, class Extention_type> Key Register_handler( Handler<message_id, Extention_type> handler, System_id system_id = SYSTEM_ID_ANY, Component_id component_id = COMPONENT_ID_ANY, Request_processor::Ptr processor = nullptr )
Register handler for specific Mavlink message, system id and component id.
Parameters:
handler |
Handler taking specific Mavlink message. |
system_id |
System id to call the handler for, or SYSTEM_ID_ANY to call the handler for any system id. |
component_id |
Component id to call the handler for, or COMPONENT_ID_ANY to call the handler for any component id. |
processor |
If given, specifies request processor in which context the handler should be executed, otherwise handler is executed from the thread which calls Demux method. |
Returns:
Valid registration key which can be used to unregister the handler later.
bool Demux( Io_buffer::Ptr buffer, mavlink::MESSAGE_ID_TYPE message_id, System_id system_id, uint8_t component_id, uint32_t request_id )
Demultiplex Mavlink message.
Returns:
true if message was handled by some non-default handler, otherwise false.
void Unregister_handler(Key&)
Unregister handler using registration key.
Key is invalidated upon exit from the method.