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 battery_remaining from sys_status message * * @return Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot estimate the remaining battery */ int8_t mavlink_msg_sys_status_get_battery_remaining(const mavlink_message_t* msg) { return _MAV_RETURN_int8_t(msg, 30); }