/* extract target sysid and compid from a message. int16_t is used so that the caller can set them to -1 and know when a sysid or compid target is found in the message */ void MAVLink_routing::get_targets(const mavlink_message_t* msg, int16_t &sysid, int16_t &compid) { const mavlink_msg_entry_t *msg_entry = mavlink_get_msg_entry(msg->msgid); if (msg_entry == nullptr) { return; } if (msg_entry->flags & MAV_MSG_ENTRY_FLAG_HAVE_TARGET_SYSTEM) { sysid = _MAV_RETURN_uint8_t(msg, msg_entry->target_system_ofs); } if (msg_entry->flags & MAV_MSG_ENTRY_FLAG_HAVE_TARGET_COMPONENT) { compid = _MAV_RETURN_uint8_t(msg, msg_entry->target_component_ofs); } }
static void print_one_field(mavlink_message_t *msg, const mavlink_field_info_t *f, int idx) { #define PRINT_FORMAT(f, def) (f->print_format?f->print_format:def) switch (f->type) { case MAVLINK_TYPE_CHAR: printf(PRINT_FORMAT(f, "%c"), _MAV_RETURN_char(msg, f->wire_offset+idx*1)); break; case MAVLINK_TYPE_UINT8_T: printf(PRINT_FORMAT(f, "%u"), _MAV_RETURN_uint8_t(msg, f->wire_offset+idx*1)); break; case MAVLINK_TYPE_INT8_T: printf(PRINT_FORMAT(f, "%d"), _MAV_RETURN_int8_t(msg, f->wire_offset+idx*1)); break; case MAVLINK_TYPE_UINT16_T: printf(PRINT_FORMAT(f, "%u"), _MAV_RETURN_uint16_t(msg, f->wire_offset+idx*2)); break; case MAVLINK_TYPE_INT16_T: printf(PRINT_FORMAT(f, "%d"), _MAV_RETURN_int16_t(msg, f->wire_offset+idx*2)); break; case MAVLINK_TYPE_UINT32_T: printf(PRINT_FORMAT(f, "%lu"), (unsigned long)_MAV_RETURN_uint32_t(msg, f->wire_offset+idx*4)); break; case MAVLINK_TYPE_INT32_T: printf(PRINT_FORMAT(f, "%ld"), (long)_MAV_RETURN_int32_t(msg, f->wire_offset+idx*4)); break; case MAVLINK_TYPE_UINT64_T: printf(PRINT_FORMAT(f, "%llu"), (unsigned long long)_MAV_RETURN_uint64_t(msg, f->wire_offset+idx*8)); break; case MAVLINK_TYPE_INT64_T: printf(PRINT_FORMAT(f, "%lld"), (long long)_MAV_RETURN_int64_t(msg, f->wire_offset+idx*8)); break; case MAVLINK_TYPE_FLOAT: printf(PRINT_FORMAT(f, "%f"), (double)_MAV_RETURN_float(msg, f->wire_offset+idx*4)); break; case MAVLINK_TYPE_DOUBLE: printf(PRINT_FORMAT(f, "%f"), _MAV_RETURN_double(msg, f->wire_offset+idx*8)); break; } }
/** * @brief Get field target_component from mission_request message * * @return Component ID */ uint8_t mavlink_msg_mission_request_get_target_component(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 3); }
/** * @brief Get field target_system from mission_request message * * @return System ID */ uint8_t mavlink_msg_mission_request_get_target_system(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 2); }