MAV'RIC
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
Mavlink_message_handler Class Reference

Message handler base class. More...

#include <mavlink_message_handler.hpp>

Inheritance diagram for Mavlink_message_handler:
Inheritance graph
[legend]

List of all members.

Classes

struct  cmd_callback_t
 Command callback. More...
struct  cmd_function
 Prototype of function callback for mavlink commands. More...
struct  conf_t
 Structure used to hold parameters during initialisation. More...
struct  msg_callback_t
 Message callback. More...
struct  msg_function
 Prototype of function callback for mavlink messages. More...

Public Types

typedef enum MAV_COMPONENT mav_component_t
 Enumeration of MAV components.

Public Member Functions

 Mavlink_message_handler (Mavlink_stream &mavlink_stream, const conf_t &config)
 Constructor.
template<typename T >
bool add_msg_callback (uint8_t message_id, uint8_t sysid_filter, mav_component_t compid_filter, typename msg_function< T >::type_t function, T *module_struct)
 Registers a new callback for a message.
template<typename T >
bool add_cmd_callback (uint16_t command_id, uint8_t sysid_filter, mav_component_t compid_filter, mav_component_t compid_target, typename cmd_function< T >::type_t function, T *module_struct)
 Registers a new callback for a command.
void receive (Mavlink_stream::msg_received_t *rec)
 Main update function, handles the incoming message according to the registered message and command callbacks.

Static Public Member Functions

static conf_t default_config (void)
 Default configuration.
static void msg_default_dbg (mavlink_message_t *msg)
 Dummy message callback for debug purpose.
static void cmd_default_dbg (mavlink_command_long_t *cmd)
 Dummy command callback for debug purpose.

Protected Member Functions

virtual uint32_t msg_callback_max_count (void)=0
 Get maximum number of message callbacks.
virtual uint32_t cmd_callback_max_count (void)=0
 Get maximum number of command callbacks.
virtual msg_callback_tmsg_callback_list (void)=0
 Get list of message callbacks.
virtual cmd_callback_tcmd_callback_list (void)=0
 Get list of command callbacks.

Detailed Description

Message handler base class.

This class is abstract and does not contains the lists of handlers, use the child class Mavlink_message_handler_T


Member Typedef Documentation

typedef enum MAV_COMPONENT Mavlink_message_handler::mav_component_t

Enumeration of MAV components.

The enumeration MAV_COMPONENT is defined by MAVLink


Constructor & Destructor Documentation

Mavlink_message_handler::Mavlink_message_handler ( Mavlink_stream mavlink_stream,
const conf_t config 
)

Constructor.

Parameters:
configConfig parameters
mavlink_streammavlink stream

Member Function Documentation

template<typename T >
bool Mavlink_message_handler::add_cmd_callback ( uint16_t  command_id,
uint8_t  sysid_filter,
mav_component_t  compid_filter,
mav_component_t  compid_target,
typename cmd_function< T >::type_t  function,
T *  module_struct 
)

Registers a new callback for a command.

You should call mavlink_message_handler_sort_callback function after having added all callbacks, as it is used by mavlink_message_handler_receive to speed up matching

Parameters:
command_idThe function will be called only for commands with ID command_id
sysid_filterThe function will be called only for commands coming from MAVs with ID sysid_filter (0 for all)
compid_filterThe function will be called only for commands coming from component compid_filter (0 for all)
compid_targetThe function will be called only if the commands targets the component compid_target of this system (0 for all)
functionPointer to the function to be executed
module_structPointer to module data structure to be given as argument to the function
Returns:
True if the command callback was correctly added, false otherwise

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
bool Mavlink_message_handler::add_msg_callback ( uint8_t  message_id,
uint8_t  sysid_filter,
mav_component_t  compid_filter,
typename msg_function< T >::type_t  function,
T *  module_struct 
)

Registers a new callback for a message.

You should call mavlink_message_handler_sort_callback function after having added all callbacks, as it is used by mavlink_message_handler_receive to speed up matching

Parameters:
message_idThe function will be called only for messages with ID message_id
sysid_filterThe function will be called only for messages coming from MAVs with ID sysid_filter (0 for all)
compid_filterThe function will be called only for messages coming from component compid_filter (0 for all)
functionPointer to the function to be executed
module_structPointer to module data structure to be given as argument to the function
Returns:
True if the message callback was correctly added, false otherwise

Here is the call graph for this function:

Here is the caller graph for this function:

virtual cmd_callback_t* Mavlink_message_handler::cmd_callback_list ( void  ) [protected, pure virtual]

Get list of command callbacks.

To be overriden by child class

Returns:
list

Implemented in Mavlink_message_handler_T< N, P >, and Mavlink_message_handler_T< N_MSG_CB, N_CMD_CB >.

Here is the caller graph for this function:

virtual uint32_t Mavlink_message_handler::cmd_callback_max_count ( void  ) [protected, pure virtual]

Get maximum number of command callbacks.

To be overriden by child class

Returns:
Maximum number of command callbacks

Implemented in Mavlink_message_handler_T< N, P >, and Mavlink_message_handler_T< N_MSG_CB, N_CMD_CB >.

Here is the caller graph for this function:

void Mavlink_message_handler::cmd_default_dbg ( mavlink_command_long_t *  cmd) [static]

Dummy command callback for debug purpose.

Prints the fields of the incoming command to the debug console

Parameters:
cmdPointer to incoming command

Here is the caller graph for this function:

Default configuration.

Returns:
Config
virtual msg_callback_t* Mavlink_message_handler::msg_callback_list ( void  ) [protected, pure virtual]

Get list of message callbacks.

To be overriden by child class

Returns:
list

Implemented in Mavlink_message_handler_T< N, P >, and Mavlink_message_handler_T< N_MSG_CB, N_CMD_CB >.

Here is the caller graph for this function:

virtual uint32_t Mavlink_message_handler::msg_callback_max_count ( void  ) [protected, pure virtual]

Get maximum number of message callbacks.

To be overriden by child class

Returns:
Maximum number of message callbacks

Implemented in Mavlink_message_handler_T< N, P >, and Mavlink_message_handler_T< N_MSG_CB, N_CMD_CB >.

Here is the caller graph for this function:

void Mavlink_message_handler::msg_default_dbg ( mavlink_message_t *  msg) [static]

Dummy message callback for debug purpose.

Prints the fields of the incoming message to the debug console

Parameters:
msgPointer to incoming message

Here is the caller graph for this function:

Main update function, handles the incoming message according to the registered message and command callbacks.

Parameters:
recPointer to the MAVLink receive message structure

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines