{
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
}

{
 //  MAVLink Pascal Unit for APM communication.
 //  Author: Hiroshi Takey, August 2016
 //

 Especial thanks to Andrew Tridgell, Randy, Lucas de Marchi, Gustavo José de Sousa and Ardupilot Team for
 let me learn and show me the power of the API APM.

 Thanks to Lorenz Meier to create and share Mavlink to the world.

 MAVLink or Micro Air Vehicle Link is a protocol for communicating with small unmanned vehicle.
 It is designed as a header-only message marshaling library. MAVLink was first released early
 2009 by Lorenz Meier under LGPL license.

 You can follow Mavlink project at https://github.com/mavlink/mavlink
}

unit MAVLink;

interface

uses Classes, System.Types, System.SysUtils, System.UITypes, System.Variants, FMX.Memo;

const
  // TypeLibrary Major and minor versions
  MAVLINK_MAX_DIALECT_PAYLOAD_SIZE:integer = 255;
  MAVLINK_LITTLE_ENDIAN:integer = 1;
  MAVLINK_BIG_ENDIAN:integer = 0;
  MAVLINK_STX:byte = 254;
  MAVLinkMajorVersion = 1;
  MAVLinkMinorVersion = 0;
  MAVLINK_MESSAGE_CRCS: array of byte = [50, 124, 137, 0, 237, 217, 104, 119, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 214, 159, 220, 168, 24, 23, 170, 144, 67, 115, 39, 246, 185, 104, 237, 244, 222, 212, 9, 254, 230, 28, 28, 132, 221, 232, 11, 153, 41, 39, 78, 0, 0, 0, 15, 3, 0, 0, 0, 0, 0, 153, 183, 51, 82, 118, 148, 21, 0, 243, 124, 0, 0, 38, 20, 158, 152, 143, 0, 0, 0, 106, 49, 22, 143, 140, 5, 150, 0, 231, 183, 63, 54, 0, 0, 0, 0, 0, 0, 0, 175, 102, 158, 208, 56, 93, 138, 108, 32, 185, 84, 34, 0, 124, 237, 4, 76, 128, 56, 116, 134, 237, 203, 250, 87, 203, 220, 25, 226, 46, 29, 223, 85, 6, 229, 203, 1, 195, 109, 168, 181, 0, 0, 131, 0, 0, 0, 154, 178, 200, 134, 219, 208, 188, 84, 22, 19, 21, 134, 0, 78, 68, 189, 127, 154, 21, 21, 144, 1, 234, 73, 181, 22, 83, 167, 138, 234, 240, 47, 189, 52, 174, 229, 85, 159, 186, 72, 0, 0, 0, 0, 92, 36, 71, 98, 0, 0, 0, 0, 0, 134, 205, 94, 128, 54, 63, 112, 201, 221, 226, 238, 103, 235, 14, 0, 77, 50, 163, 115, 47, 0, 0, 0, 0, 0, 0, 207, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 104, 85, 0, 0, 184, 0, 8, 204, 49, 170, 44, 83, 46, 0];
  X25_INIT_CRC: integer = $ffff;
  MAVLINK_MESSAGE_LENGTHS: array of byte = [9, 31, 12, 0, 14, 28, 3, 32, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 25, 23, 30, 101, 22, 26, 16, 14, 28, 32, 28, 28, 22, 22, 21, 6, 6, 37, 4, 4, 2, 2, 4, 2, 2, 3, 13, 12, 37, 0, 0, 0, 27, 25, 0, 0, 0, 0, 0, 68, 26, 185, 181, 42, 6, 4, 0, 11, 18, 0, 0, 37, 20, 35, 33, 3, 0, 0, 0, 22, 39, 37, 53, 51, 53, 51, 0, 28, 56, 42, 33, 0, 0, 0, 0, 0, 0, 0, 26, 32, 32, 20, 32, 62, 44, 64, 84, 9, 254, 16, 0, 36, 44, 64, 22, 6, 14, 12, 97, 2, 2, 113, 35, 6, 79, 35, 35, 22, 13, 255, 14, 18, 43, 8, 22, 14, 36, 43, 41, 0, 0, 14, 0, 0, 0, 36, 60, 30, 42, 8, 4, 12, 15, 13, 6, 15, 14, 0, 12, 3, 8, 28, 44, 3, 9, 22, 12, 18, 34, 66, 98, 8, 48, 19, 3, 20, 24, 29, 45, 4, 40, 2, 206, 7, 29, 0, 0, 0, 0, 27, 44, 22, 25, 0, 0, 0, 0, 0, 42, 14, 2, 3, 2, 1, 33, 1, 6, 2, 4, 2, 3, 2, 0, 1, 3, 2, 4, 2, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 52, 53, 0, 0, 38, 0, 254, 36, 30, 18, 18, 51, 9, 0];


type LargeUint = UInt64;

type
  MAVLINK_MSG_ID = record
const
  MAVLINK_MSG_ID_HEARTBEAT = $00000000;
  MAVLINK_MSG_ID_SYS_STATUS = $00000001;
  MAVLINK_MSG_ID_SYSTEM_TIME = $00000002;
  MAVLINK_MSG_ID_PING = $00000004;
  MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL = $00000005;
  MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK = $00000006;
  MAVLINK_MSG_ID_AUTH_KEY = $00000007;
  MAVLINK_MSG_ID_SET_MODE = $0000000B;
  MAVLINK_MSG_ID_PARAM_REQUEST_READ = $00000014;
  MAVLINK_MSG_ID_PARAM_REQUEST_LIST = $00000015;
  MAVLINK_MSG_ID_PARAM_VALUE = $00000016;
  MAVLINK_MSG_ID_PARAM_SET = $00000017;
  MAVLINK_MSG_ID_GPS_RAW_INT = $00000018;
  MAVLINK_MSG_ID_GPS_STATUS = $00000019;
  MAVLINK_MSG_ID_SCALED_IMU = $0000001A;
  MAVLINK_MSG_ID_RAW_IMU = $0000001B;
  MAVLINK_MSG_ID_RAW_PRESSURE = $0000001C;
  MAVLINK_MSG_ID_SCALED_PRESSURE = $0000001D;
  MAVLINK_MSG_ID_ATTITUDE = $0000001E;
  MAVLINK_MSG_ID_ATTITUDE_QUATERNION = $0000001F;
  MAVLINK_MSG_ID_LOCAL_POSITION_NED = $00000020;
  MAVLINK_MSG_ID_GLOBAL_POSITION_INT = $00000021;
  MAVLINK_MSG_ID_RC_CHANNELS_SCALED = $00000022;
  MAVLINK_MSG_ID_RC_CHANNELS_RAW = $00000023;
  MAVLINK_MSG_ID_SERVO_OUTPUT_RAW = $00000024;
  MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST = $00000025;
  MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST = $00000026;
  MAVLINK_MSG_ID_MISSION_ITEM = $00000027;
  MAVLINK_MSG_ID_MISSION_REQUEST = $00000028;
  MAVLINK_MSG_ID_MISSION_SET_CURRENT = $00000029;
  MAVLINK_MSG_ID_MISSION_CURRENT = $0000002A;
  MAVLINK_MSG_ID_MISSION_REQUEST_LIST = $0000002B;
  MAVLINK_MSG_ID_MISSION_COUNT = $0000002C;
  MAVLINK_MSG_ID_MISSION_CLEAR_ALL = $0000002D;
  MAVLINK_MSG_ID_MISSION_ITEM_REACHED = $0000002E;
  MAVLINK_MSG_ID_MISSION_ACK = $0000002F;
  MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN = $00000030;
  MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN = $00000031;
  MAVLINK_MSG_ID_PARAM_MAP_RC = $00000032;
  MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA = $00000036;
  MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA = $00000037;
  MAVLINK_MSG_ID_ATTITUDE_QUATERNION_COV = $0000003D;
  MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT = $0000003E;
  MAVLINK_MSG_ID_GLOBAL_POSITION_INT_COV = $0000003F;
  MAVLINK_MSG_ID_LOCAL_POSITION_NED_COV = $00000040;
  MAVLINK_MSG_ID_RC_CHANNELS = $00000041;
  MAVLINK_MSG_ID_REQUEST_DATA_STREAM = $00000042;
  MAVLINK_MSG_ID_DATA_STREAM = $00000043;
  MAVLINK_MSG_ID_MANUAL_CONTROL = $00000045;
  MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE = $00000046;
  MAVLINK_MSG_ID_MISSION_ITEM_INT = $00000049;
  MAVLINK_MSG_ID_VFR_HUD = $0000004A;
  MAVLINK_MSG_ID_COMMAND_INT = $0000004B;
  MAVLINK_MSG_ID_COMMAND_LONG = $0000004C;
  MAVLINK_MSG_ID_COMMAND_ACK = $0000004D;
  MAVLINK_MSG_ID_MANUAL_SETPOINT = $00000051;
  MAVLINK_MSG_ID_SET_ATTITUDE_TARGET = $00000052;
  MAVLINK_MSG_ID_ATTITUDE_TARGET = $00000053;
  MAVLINK_MSG_ID_SET_POSITION_TARGET_LOCAL_NED = $00000054;
  MAVLINK_MSG_ID_POSITION_TARGET_LOCAL_NED = $00000055;
  MAVLINK_MSG_ID_SET_POSITION_TARGET_GLOBAL_INT = $00000056;
  MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT = $00000057;
  MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET = $00000059;
  MAVLINK_MSG_ID_HIL_STATE = $0000005A;
  MAVLINK_MSG_ID_HIL_CONTROLS = $0000005B;
  MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW = $0000005C;
  MAVLINK_MSG_ID_OPTICAL_FLOW = $00000064;
  MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE = $00000065;
  MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE = $00000066;
  MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE = $00000067;
  MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE = $00000068;
  MAVLINK_MSG_ID_HIGHRES_IMU = $00000069;
  MAVLINK_MSG_ID_OPTICAL_FLOW_RAD = $0000006A;
  MAVLINK_MSG_ID_HIL_SENSOR = $0000006B;
  MAVLINK_MSG_ID_SIM_STATE = $0000006C;
  MAVLINK_MSG_ID_RADIO_STATUS = $0000006D;
  MAVLINK_MSG_ID_FILE_TRANSFER_PROTOCOL = $0000006E;
  MAVLINK_MSG_ID_TIMESYNC = $0000006F;
  MAVLINK_MSG_ID_HIL_GPS = $00000071;
  MAVLINK_MSG_ID_HIL_OPTICAL_FLOW = $00000072;
  MAVLINK_MSG_ID_HIL_STATE_QUATERNION = $00000073;
  MAVLINK_MSG_ID_SCALED_IMU2 = $00000074;
  MAVLINK_MSG_ID_LOG_REQUEST_LIST = $00000075;
  MAVLINK_MSG_ID_LOG_ENTRY = $00000076;
  MAVLINK_MSG_ID_LOG_REQUEST_DATA = $00000077;
  MAVLINK_MSG_ID_LOG_DATA = $00000078;
  MAVLINK_MSG_ID_LOG_ERASE = $00000079;
  MAVLINK_MSG_ID_LOG_REQUEST_END = $0000007A;
  MAVLINK_MSG_ID_GPS_INJECT_DATA = $0000007B;
  MAVLINK_MSG_ID_GPS2_RAW = $0000007C;
  MAVLINK_MSG_ID_POWER_STATUS = $0000007D;
  MAVLINK_MSG_ID_SERIAL_CONTROL = $0000007E;
  MAVLINK_MSG_ID_GPS_RTK = $0000007F;
  MAVLINK_MSG_ID_GPS2_RTK = $00000080;
  MAVLINK_MSG_ID_SCALED_IMU3 = $00000081;
  MAVLINK_MSG_ID_DATA_TRANSMISSION_HANDSHAKE = $00000082;
  MAVLINK_MSG_ID_ENCAPSULATED_DATA = $00000083;
  MAVLINK_MSG_ID_DISTANCE_SENSOR = $00000084;
  MAVLINK_MSG_ID_TERRAIN_REQUEST = $00000085;
  MAVLINK_MSG_ID_TERRAIN_DATA = $00000086;
  MAVLINK_MSG_ID_TERRAIN_CHECK = $00000087;
  MAVLINK_MSG_ID_TERRAIN_REPORT = $00000088;
  MAVLINK_MSG_ID_SCALED_PRESSURE2 = $00000089;
  MAVLINK_MSG_ID_ATT_POS_MOCAP = $0000008A;
  MAVLINK_MSG_ID_SET_ACTUATOR_CONTROL_TARGET = $0000008B;
  MAVLINK_MSG_ID_ACTUATOR_CONTROL_TARGET = $0000008C;
  MAVLINK_MSG_ID_SCALED_PRESSURE3 = $0000008F;
  MAVLINK_MSG_ID_BATTERY_STATUS = $00000093;
  MAVLINK_MSG_ID_AUTOPILOT_VERSION = $00000094;
  MAVLINK_MSG_ID_LANDING_TARGET = $00000095;
  MAVLINK_MSG_ID_SENSOR_OFFSETS = $00000096;
  MAVLINK_MSG_ID_SET_MAG_OFFSETS = $00000097;
  MAVLINK_MSG_ID_MEMINFO = $00000098;
  MAVLINK_MSG_ID_AP_ADC = $00000099;
  MAVLINK_MSG_ID_DIGICAM_CONFIGURE = $0000009A;
  MAVLINK_MSG_ID_DIGICAM_CONTROL = $0000009B;
  MAVLINK_MSG_ID_MOUNT_CONFIGURE = $0000009C;
  MAVLINK_MSG_ID_MOUNT_CONTROL = $0000009D;
  MAVLINK_MSG_ID_MOUNT_STATUS = $0000009E;
  MAVLINK_MSG_ID_FENCE_POINT = $000000A0;
  MAVLINK_MSG_ID_FENCE_FETCH_POINT = $000000A1;
  MAVLINK_MSG_ID_FENCE_STATUS = $000000A2;
  MAVLINK_MSG_ID_AHRS = $000000A3;
  MAVLINK_MSG_ID_SIMSTATE = $000000A4;
  MAVLINK_MSG_ID_HWSTATUS = $000000A5;
  MAVLINK_MSG_ID_RADIO = $000000A6;
  MAVLINK_MSG_ID_LIMITS_STATUS = $000000A7;
  MAVLINK_MSG_ID_WIND = $000000A8;
  MAVLINK_MSG_ID_DATA16 = $000000A9;
  MAVLINK_MSG_ID_DATA32 = $000000AA;
  MAVLINK_MSG_ID_DATA64 = $000000AB;
  MAVLINK_MSG_ID_DATA96 = $000000AC;
  MAVLINK_MSG_ID_RANGEFINDER = $000000AD;
  MAVLINK_MSG_ID_AIRSPEED_AUTOCAL = $000000AE;
  MAVLINK_MSG_ID_RALLY_POINT = $000000AF;
  MAVLINK_MSG_ID_RALLY_FETCH_POINT = $000000B0;
  MAVLINK_MSG_ID_COMPASSMOT_STATUS = $000000B1;
  MAVLINK_MSG_ID_AHRS2 = $000000B2;
  MAVLINK_MSG_ID_CAMERA_STATUS = $000000B3;
  MAVLINK_MSG_ID_CAMERA_FEEDBACK = $000000B4;
  MAVLINK_MSG_ID_BATTERY2 = $000000B5;
  MAVLINK_MSG_ID_AHRS3 = $000000B6;
  MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST = $000000B7;
  MAVLINK_MSG_ID_REMOTE_LOG_DATA_BLOCK = $000000B8;
  MAVLINK_MSG_ID_REMOTE_LOG_BLOCK_STATUS = $000000B9;
  MAVLINK_MSG_ID_LED_CONTROL = $000000BA;
  MAVLINK_MSG_ID_MAG_CAL_PROGRESS = $000000BF;
  MAVLINK_MSG_ID_MAG_CAL_REPORT = $000000C0;
  MAVLINK_MSG_ID_EKF_STATUS_REPORT = $000000C1;
  MAVLINK_MSG_ID_PID_TUNING = $000000C2;
  MAVLINK_MSG_ID_GIMBAL_REPORT = $000000C8;
  MAVLINK_MSG_ID_GIMBAL_CONTROL = $000000C9;
  MAVLINK_MSG_ID_GIMBAL_RESET = $000000CA;
  MAVLINK_MSG_ID_GIMBAL_AXIS_CALIBRATION_PROGRESS = $000000CB;
  MAVLINK_MSG_ID_GIMBAL_SET_HOME_OFFSETS = $000000CC;
  MAVLINK_MSG_ID_GIMBAL_HOME_OFFSET_CALIBRATION_RESULT = $000000CD;
  MAVLINK_MSG_ID_GIMBAL_SET_FACTORY_PARAMETERS = $000000CE;
  MAVLINK_MSG_ID_GIMBAL_FACTORY_PARAMETERS_LOADED = $000000CF;
  MAVLINK_MSG_ID_GIMBAL_ERASE_FIRMWARE_AND_CONFIG = $000000D0;
  MAVLINK_MSG_ID_GIMBAL_PERFORM_FACTORY_TESTS = $000000D1;
  MAVLINK_MSG_ID_GIMBAL_REPORT_FACTORY_TESTS_PROGRESS = $000000D2;
  MAVLINK_MSG_ID_GIMBAL_REQUEST_AXIS_CALIBRATION_STATUS = $000000D3;
  MAVLINK_MSG_ID_GIMBAL_REPORT_AXIS_CALIBRATION_STATUS = $000000D4;
  MAVLINK_MSG_ID_GIMBAL_REQUEST_AXIS_CALIBRATION = $000000D5;
  MAVLINK_MSG_ID_GOPRO_HEARTBEAT = $000000D7;
  MAVLINK_MSG_ID_GOPRO_GET_REQUEST = $000000D8;
  MAVLINK_MSG_ID_GOPRO_GET_RESPONSE = $000000D9;
  MAVLINK_MSG_ID_GOPRO_SET_REQUEST = $000000DA;
  MAVLINK_MSG_ID_GOPRO_SET_RESPONSE = $000000DB;
  MAVLINK_MSG_ID_RPM = $000000E2;
  MAVLINK_MSG_ID_VIBRATION = $000000F1;
  MAVLINK_MSG_ID_HOME_POSITION = $000000F2;
  MAVLINK_MSG_ID_SET_HOME_POSITION = $000000F3;
  MAVLINK_MSG_ID_ADSB_VEHICLE = $000000F6;
  MAVLINK_MSG_ID_V2_EXTENSION = $000000F8;
  MAVLINK_MSG_ID_MEMORY_VECT = $000000F9;
  MAVLINK_MSG_ID_DEBUG_VECT = $000000FA;
  MAVLINK_MSG_ID_NAMED_VALUE_FLOAT = $000000FB;
  MAVLINK_MSG_ID_NAMED_VALUE_INT = $000000FC;
  MAVLINK_MSG_ID_STATUSTEXT = $000000FD;
  MAVLINK_MSG_ID_DEBUG = $000000FE;
end;

// Constants for enum MAV_CMD
type
  MAV_CMD = record
const
  MAV_CMD_WAYPOINT = $00000010;
  MAV_CMD_LOITER_UNLIM = $00000011;
  MAV_CMD_LOITER_TURNS = $00000012;
  MAV_CMD_LOITER_TIME = $00000013;
  MAV_CMD_RETURN_TO_LAUNCH = $00000014;
  MAV_CMD_LAND = $00000015;
  MAV_CMD_TAKEOFF = $00000016;
  MAV_CMD_CONTINUE_AND_CHANGE_ALT = $0000001E;
  MAV_CMD_LOITER_TO_ALT = $0000001F;
  MAV_CMD_ROI = $00000050;
  MAV_CMD_PATHPLANNING = $00000051;
  MAV_CMD_SPLINE_WAYPOINT = $00000052;
  MAV_CMD_ALTITUDE_WAIT = $00000053;
  MAV_CMD_GUIDED_ENABLE = $0000005C;
  MAV_CMD_LAST = $0000005F;
  MAV_CMD_CONDITION_DELAY = $00000070;
  MAV_CMD_CONDITION_CHANGE_ALT = $00000071;
  MAV_CMD_CONDITION_DISTANCE = $00000072;
  MAV_CMD_CONDITION_YAW = $00000073;
  MAV_CMD_CONDITION_LAST = $0000009F;
  MAV_CMD_DO_SET_MODE = $000000B0;
  MAV_CMD_DO_JUMP = $000000B1;
  MAV_CMD_DO_CHANGE_SPEED = $000000B2;
  MAV_CMD_DO_SET_HOME = $000000B3;
  MAV_CMD_DO_SET_PARAMETER = $000000B4;
  MAV_CMD_DO_SET_RELAY = $000000B5;
  MAV_CMD_DO_REPEAT_RELAY = $000000B6;
  MAV_CMD_DO_SET_SERVO = $000000B7;
  MAV_CMD_DO_REPEAT_SERVO = $000000B8;
  MAV_CMD_DO_FLIGHTTERMINATION = $000000B9;
  MAV_CMD_DO_LAND_START = $000000BD;
  MAV_CMD_DO_RALLY_LAND = $000000BE;
  MAV_CMD_DO_GO_AROUND = $000000BF;
  MAV_CMD_DO_CONTROL_VIDEO = $000000C8;
  MAV_CMD_DO_SET_ROI = $000000C9;
  MAV_CMD_DO_DIGICAM_CONFIGURE = $000000CA;
  MAV_CMD_DO_DIGICAM_CONTROL = $000000CB;
  MAV_CMD_DO_MOUNT_CONFIGURE = $000000CC;
  MAV_CMD_DO_MOUNT_CONTROL = $000000CD;
  MAV_CMD_DO_SET_CAM_TRIGG_DIST = $000000CE;
  MAV_CMD_DO_FENCE_ENABLE = $000000CF;
  MAV_CMD_DO_PARACHUTE = $000000D0;
  MAV_CMD_DO_MOTOR_TEST = $000000D1;
  MAV_CMD_DO_INVERTED_FLIGHT = $000000D2;
  MAV_CMD_DO_GRIPPER = $000000D3;
  MAV_CMD_DO_AUTOTUNE_ENABLE = $000000D4;
  MAV_CMD_DO_MOUNT_CONTROL_QUAT = $000000DC;
  MAV_CMD_DO_GUIDED_MASTER = $000000DD;
  MAV_CMD_DO_GUIDED_LIMITS = $000000DE;
  MAV_CMD_DO_LAST = $000000F0;
  MAV_CMD_PREFLIGHT_CALIBRATION = $000000F1;
  MAV_CMD_PREFLIGHT_SET_SENSOR_OFFSETS = $000000F2;
  MAV_CMD_PREFLIGHT_STORAGE = $000000F5;
  MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN = $000000F6;
  MAV_CMD_OVERRIDE_GOTO = $000000FC;
  MAV_CMD_MISSION_START = $0000012C;
  MAV_CMD_COMPONENT_ARM_DISARM = $00000190;
  MAV_CMD_GET_HOME_POSITION = $0000019A;
  MAV_CMD_START_RX_PAIR = $000001F4;
  MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES = $00000208;
  MAV_CMD_IMAGE_START_CAPTURE = $000007D0;
  MAV_CMD_IMAGE_STOP_CAPTURE = $000007D1;
  MAV_CMD_VIDEO_START_CAPTURE = $000009C4;
  MAV_CMD_VIDEO_STOP_CAPTURE = $000009C5;
  MAV_CMD_PANORAMA_CREATE = $00000AF0;
  MAV_CMD_PAYLOAD_PREPARE_DEPLOY = $00007531;
  MAV_CMD_PAYLOAD_CONTROL_DEPLOY = $00007532;
  MAV_CMD_ENUM_END = $00007533;
  MAV_CMD_DO_START_MAG_CAL = $0000A5B8;
  MAV_CMD_DO_ACCEPT_MAG_CAL = $0000A5B9;
  MAV_CMD_DO_CANCEL_MAG_CAL = $0000A5BA;
  MAV_CMD_DO_SEND_BANNER = $0000A5BC;
end;

// Constants for enum LIMITS_STATE
type
  LIMITS_STATE = record
const
  LIMITS_STATE_LIMITS_INIT = $00000000;
  LIMITS_STATE_LIMITS_DISABLED = $00000001;
  LIMITS_STATE_LIMITS_ENABLED = $00000002;
  LIMITS_STATE_LIMITS_TRIGGERED = $00000003;
  LIMITS_STATE_LIMITS_RECOVERING = $00000004;
  LIMITS_STATE_LIMITS_RECOVERED = $00000005;
  LIMITS_STATE_ENUM_END = $00000006;
end;

// Constants for enum LIMIT_MODULE
type
  LIMIT_MODULE = record
const
  LIMIT_MODULE_LIMIT_GPSLOCK = $00000001;
  LIMIT_MODULE_LIMIT_GEOFENCE = $00000002;
  LIMIT_MODULE_LIMIT_ALTITUDE = $00000004;
  LIMIT_MODULE_ENUM_END = $00000005;
end;

// Constants for enum RALLY_FLAGS
type
  RALLY_FLAGS = record
const
  RALLY_FLAGS_FAVORABLE_WIND = $00000001;
  RALLY_FLAGS_LAND_IMMEDIATELY = $00000002;
  RALLY_FLAGS_ENUM_END = $00000003;
end;

// Constants for enum PARACHUTE_ACTION
type
  PARACHUTE_ACTION = record
const
  PARACHUTE_ACTION_PARACHUTE_DISABLE = $00000000;
  PARACHUTE_ACTION_PARACHUTE_ENABLE = $00000001;
  PARACHUTE_ACTION_PARACHUTE_RELEASE = $00000002;
  PARACHUTE_ACTION_ENUM_END = $00000003;
end;

// Constants for enum MOTOR_TEST_THROTTLE_TYPE
type
  MOTOR_TEST_THROTTLE_TYPE = record
const
  MOTOR_TEST_THROTTLE_TYPE_MOTOR_TEST_THROTTLE_PERCENT = $00000000;
  MOTOR_TEST_THROTTLE_TYPE_MOTOR_TEST_THROTTLE_PWM = $00000001;
  MOTOR_TEST_THROTTLE_TYPE_MOTOR_TEST_THROTTLE_PILOT = $00000002;
  MOTOR_TEST_THROTTLE_TYPE_ENUM_END = $00000003;
end;

// Constants for enum GRIPPER_ACTIONS
type
  GRIPPER_ACTIONS = record
const
  GRIPPER_ACTIONS_GRIPPER_ACTION_RELEASE = $00000000;
  GRIPPER_ACTIONS_GRIPPER_ACTION_GRAB = $00000001;
  GRIPPER_ACTIONS_ENUM_END = $00000002;
end;

// Constants for enum CAMERA_STATUS_TYPES
type
  CAMERA_STATUS_TYPES = record
const
  CAMERA_STATUS_TYPES_CAMERA_STATUS_TYPE_HEARTBEAT = $00000000;
  CAMERA_STATUS_TYPES_CAMERA_STATUS_TYPE_TRIGGER = $00000001;
  CAMERA_STATUS_TYPES_CAMERA_STATUS_TYPE_DISCONNECT = $00000002;
  CAMERA_STATUS_TYPES_CAMERA_STATUS_TYPE_ERROR = $00000003;
  CAMERA_STATUS_TYPES_CAMERA_STATUS_TYPE_LOWBATT = $00000004;
  CAMERA_STATUS_TYPES_CAMERA_STATUS_TYPE_LOWSTORE = $00000005;
  CAMERA_STATUS_TYPES_CAMERA_STATUS_TYPE_LOWSTOREV = $00000006;
  CAMERA_STATUS_TYPES_ENUM_END = $00000007;
end;

// Constants for enum CAMERA_FEEDBACK_FLAGS
type
  CAMERA_FEEDBACK_FLAGS = record
const
  CAMERA_FEEDBACK_FLAGS_CAMERA_FEEDBACK_PHOTO = $00000000;
  CAMERA_FEEDBACK_FLAGS_CAMERA_FEEDBACK_VIDEO = $00000001;
  CAMERA_FEEDBACK_FLAGS_CAMERA_FEEDBACK_BADEXPOSURE = $00000002;
  CAMERA_FEEDBACK_FLAGS_CAMERA_FEEDBACK_CLOSEDLOOP = $00000003;
  CAMERA_FEEDBACK_FLAGS_CAMERA_FEEDBACK_OPENLOOP = $00000004;
  CAMERA_FEEDBACK_FLAGS_ENUM_END = $00000005;
end;

// Constants for enum MAV_MODE_GIMBAL
type
  MAV_MODE_GIMBAL = record
const
  MAV_MODE_GIMBAL_UNINITIALIZED = $00000000;
  MAV_MODE_GIMBAL_CALIBRATING_PITCH = $00000001;
  MAV_MODE_GIMBAL_CALIBRATING_ROLL = $00000002;
  MAV_MODE_GIMBAL_CALIBRATING_YAW = $00000003;
  MAV_MODE_GIMBAL_INITIALIZED = $00000004;
  MAV_MODE_GIMBAL_ACTIVE = $00000005;
  MAV_MODE_GIMBAL_RATE_CMD_TIMEOUT = $00000006;
  MAV_MODE_GIMBAL_ENUM_END = $00000007;
end;

// Constants for enum GIMBAL_AXIS
type
  GIMBAL_AXIS = record
const
  GIMBAL_AXIS_YAW = $00000000;
  GIMBAL_AXIS_PITCH = $00000001;
  GIMBAL_AXIS_ROLL = $00000002;
  GIMBAL_AXIS_ENUM_END = $00000003;
end;

// Constants for enum GIMBAL_AXIS_CALIBRATION_STATUS
type
  GIMBAL_AXIS_CALIBRATION_STATUS = record
const
  GIMBAL_AXIS_CALIBRATION_STATUS_IN_PROGRESS = $00000000;
  GIMBAL_AXIS_CALIBRATION_STATUS_SUCCEEDED = $00000001;
  GIMBAL_AXIS_CALIBRATION_STATUS_FAILED = $00000002;
  GIMBAL_AXIS_CALIBRATION_STATUS_ENUM_END = $00000003;
end;

// Constants for enum FACTORY_TEST
type
  FACTORY_TEST = record
const
  FACTORY_TEST_AXIS_RANGE_LIMITS = $00000000;
  FACTORY_TEST_ENUM_END = $00000001;
end;

// Constants for enum GIMBAL_AXIS_CALIBRATION_REQUIRED
type
  GIMBAL_AXIS_CALIBRATION_REQUIRED = record
const
  GIMBAL_AXIS_CALIBRATION_REQUIRED_UNKNOWN = $00000000;
  GIMBAL_AXIS_CALIBRATION_REQUIRED_TRUE = $00000001;
  GIMBAL_AXIS_CALIBRATION_REQUIRED_FALSE = $00000002;
  GIMBAL_AXIS_CALIBRATION_REQUIRED_ENUM_END = $00000003;
end;

// Constants for enum GOPRO_HEARTBEAT_STATUS
type
  GOPRO_HEARTBEAT_STATUS = record
const
  GOPRO_HEARTBEAT_STATUS_DISCONNECTED = $00000000;
  GOPRO_HEARTBEAT_STATUS_INCOMPATIBLE = $00000001;
  GOPRO_HEARTBEAT_STATUS_CONNECTED_POWER_OFF = $00000002;
  GOPRO_HEARTBEAT_STATUS_CONNECTED_POWER_ON = $00000003;
  GOPRO_HEARTBEAT_STATUS_RECORDING = $00000004;
  GOPRO_HEARTBEAT_STATUS_ERR_OVERTEMP = $00000005;
  GOPRO_HEARTBEAT_STATUS_ERR_STORAGE = $00000006;
  GOPRO_HEARTBEAT_STATUS_ENUM_END = $00000007;
end;

// Constants for enum GOPRO_SET_RESPONSE_RESULT
type
  GOPRO_SET_RESPONSE_RESULT = record
const
  GOPRO_SET_RESPONSE_RESULT_FAILURE = $00000000;
  GOPRO_SET_RESPONSE_RESULT_SUCCESS = $00000001;
  GOPRO_SET_RESPONSE_RESULT_ENUM_END = $00000002;
end;

// Constants for enum GOPRO_COMMAND
type
  GOPRO_COMMAND = record
const
  GOPRO_COMMAND_POWER = $00000000;
  GOPRO_COMMAND_CAPTURE_MODE = $00000001;
  GOPRO_COMMAND_SHUTTER = $00000002;
  GOPRO_COMMAND_BATTERY = $00000003;
  GOPRO_COMMAND_MODEL = $00000004;
  GOPRO_COMMAND_REQUEST_FAILED = $000000FE;
  GOPRO_COMMAND_ENUM_END = $000000FF;
end;

// Constants for enum LED_CONTROL_PATTERN
type
  LED_CONTROL_PATTERN = record
const
  LED_CONTROL_PATTERN_OFF = $00000000;
  LED_CONTROL_PATTERN_FIRMWAREUPDATE = $00000001;
  LED_CONTROL_PATTERN_CUSTOM = $000000FF;
  LED_CONTROL_PATTERN_ENUM_END = $00000100;
end;

// Constants for enum EKF_STATUS_FLAGS
type
  EKF_STATUS_FLAGS = record
const
  EKF_STATUS_FLAGS_EKF_ATTITUDE = $00000001;
  EKF_STATUS_FLAGS_EKF_VELOCITY_HORIZ = $00000002;
  EKF_STATUS_FLAGS_EKF_VELOCITY_VERT = $00000004;
  EKF_STATUS_FLAGS_EKF_POS_HORIZ_REL = $00000008;
  EKF_STATUS_FLAGS_EKF_POS_HORIZ_ABS = $00000010;
  EKF_STATUS_FLAGS_EKF_POS_VERT_ABS = $00000020;
  EKF_STATUS_FLAGS_EKF_POS_VERT_AGL = $00000040;
  EKF_STATUS_FLAGS_EKF_CONST_POS_MODE = $00000080;
  EKF_STATUS_FLAGS_EKF_PRED_POS_HORIZ_REL = $00000100;
  EKF_STATUS_FLAGS_EKF_PRED_POS_HORIZ_ABS = $00000200;
  EKF_STATUS_FLAGS_ENUM_END = $00000201;
end;

// Constants for enum PID_TUNING_AXIS
type
  PID_TUNING_AXIS = record
const
  PID_TUNING_AXIS_PID_TUNING_ROLL = $00000001;
  PID_TUNING_AXIS_PID_TUNING_PITCH = $00000002;
  PID_TUNING_AXIS_PID_TUNING_YAW = $00000003;
  PID_TUNING_AXIS_PID_TUNING_ACCZ = $00000004;
  PID_TUNING_AXIS_PID_TUNING_STEER = $00000005;
  PID_TUNING_AXIS_ENUM_END = $00000006;
end;

// Constants for enum MAG_CAL_STATUS
type
  MAG_CAL_STATUS = record
const
  MAG_CAL_STATUS_MAG_CAL_NOT_STARTED = $00000000;
  MAG_CAL_STATUS_MAG_CAL_WAITING_TO_START = $00000001;
  MAG_CAL_STATUS_MAG_CAL_RUNNING_STEP_ONE = $00000002;
  MAG_CAL_STATUS_MAG_CAL_RUNNING_STEP_TWO = $00000003;
  MAG_CAL_STATUS_MAG_CAL_SUCCESS = $00000004;
  MAG_CAL_STATUS_MAG_CAL_FAILED = $00000005;
  MAG_CAL_STATUS_ENUM_END = $00000006;
end;

// Constants for enum MAV_REMOTE_LOG_DATA_BLOCK_COMMANDS
type
  MAV_REMOTE_LOG_DATA_BLOCK_COMMANDS = record
const
  MAV_REMOTE_LOG_DATA_BLOCK_COMMANDS_MAV_REMOTE_LOG_DATA_BLOCK_STOP = $7FFFFFFD;
  MAV_REMOTE_LOG_DATA_BLOCK_COMMANDS_MAV_REMOTE_LOG_DATA_BLOCK_START = $7FFFFFFE;
  MAV_REMOTE_LOG_DATA_BLOCK_COMMANDS_ENUM_END = $7FFFFFFF;
end;

// Constants for enum MAV_REMOTE_LOG_DATA_BLOCK_STATUSES
type
  MAV_REMOTE_LOG_DATA_BLOCK_STATUSES = record
const
  MAV_REMOTE_LOG_DATA_BLOCK_STATUSES_MAV_REMOTE_LOG_DATA_BLOCK_NACK = $00000000;
  MAV_REMOTE_LOG_DATA_BLOCK_STATUSES_MAV_REMOTE_LOG_DATA_BLOCK_ACK = $00000001;
  MAV_REMOTE_LOG_DATA_BLOCK_STATUSES_ENUM_END = $00000002;
end;

// Constants for enum MAV_AUTOPILOT
type
  MAV_AUTOPILOT = record
const
  MAV_AUTOPILOT_GENERIC = $00000000;
  MAV_AUTOPILOT_PIXHAWK = $00000001;
  MAV_AUTOPILOT_SLUGS = $00000002;
  MAV_AUTOPILOT_ARDUPILOTMEGA = $00000003;
  MAV_AUTOPILOT_OPENPILOT = $00000004;
  MAV_AUTOPILOT_GENERIC_WAYPOINTS_ONLY = $00000005;
  MAV_AUTOPILOT_GENERIC_WAYPOINTS_AND_SIMPLE_NAVIGATION_ONLY = $00000006;
  MAV_AUTOPILOT_GENERIC_MISSION_FULL = $00000007;
  MAV_AUTOPILOT_INVALID = $00000008;
  MAV_AUTOPILOT_PPZ = $00000009;
  MAV_AUTOPILOT_UDB = $0000000A;
  MAV_AUTOPILOT_FP = $0000000B;
  MAV_AUTOPILOT_PX4 = $0000000C;
  MAV_AUTOPILOT_SMACCMPILOT = $0000000D;
  MAV_AUTOPILOT_AUTOQUAD = $0000000E;
  MAV_AUTOPILOT_ARMAZILA = $0000000F;
  MAV_AUTOPILOT_AEROB = $00000010;
  MAV_AUTOPILOT_ASLUAV = $00000011;
  MAV_AUTOPILOT_ENUM_END = $00000012;
end;

// Constants for enum MAV_TYPE
type
  MAV_TYPE = record
const
  MAV_TYPE_GENERIC = $00000000;
  MAV_TYPE_FIXED_WING = $00000001;
  MAV_TYPE_QUADROTOR = $00000002;
  MAV_TYPE_COAXIAL = $00000003;
  MAV_TYPE_HELICOPTER = $00000004;
  MAV_TYPE_ANTENNA_TRACKER = $00000005;
  MAV_TYPE_GCS = $00000006;
  MAV_TYPE_AIRSHIP = $00000007;
  MAV_TYPE_FREE_BALLOON = $00000008;
  MAV_TYPE_ROCKET = $00000009;
  MAV_TYPE_GROUND_ROVER = $0000000A;
  MAV_TYPE_SURFACE_BOAT = $0000000B;
  MAV_TYPE_SUBMARINE = $0000000C;
  MAV_TYPE_HEXAROTOR = $0000000D;
  MAV_TYPE_OCTOROTOR = $0000000E;
  MAV_TYPE_TRICOPTER = $0000000F;
  MAV_TYPE_FLAPPING_WING = $00000010;
  MAV_TYPE_KITE = $00000011;
  MAV_TYPE_ONBOARD_CONTROLLER = $00000012;
  MAV_TYPE_VTOL_DUOROTOR = $00000013;
  MAV_TYPE_VTOL_QUADROTOR = $00000014;
  MAV_TYPE_VTOL_RESERVED1 = $00000015;
  MAV_TYPE_VTOL_RESERVED2 = $00000016;
  MAV_TYPE_VTOL_RESERVED3 = $00000017;
  MAV_TYPE_VTOL_RESERVED4 = $00000018;
  MAV_TYPE_VTOL_RESERVED5 = $00000019;
  MAV_TYPE_GIMBAL = $0000001A;
  MAV_TYPE_ADSB = $0000001B;
  MAV_TYPE_ENUM_END = $0000001C;
end;

// Constants for enum FIRMWARE_VERSION_TYPE
type
  FIRMWARE_VERSION_TYPE = record
const
  FIRMWARE_VERSION_TYPE_DEV = $00000000;
  FIRMWARE_VERSION_TYPE_ALPHA = $00000040;
  FIRMWARE_VERSION_TYPE_BETA = $00000080;
  FIRMWARE_VERSION_TYPE_RC = $000000C0;
  FIRMWARE_VERSION_TYPE_OFFICIAL = $000000FF;
  FIRMWARE_VERSION_TYPE_ENUM_END = $00000100;
end;

// Constants for enum MAV_MODE_FLAG
type
  MAV_MODE_FLAG = record
const
  MAV_MODE_FLAG_CUSTOM_MODE_ENABLED = $00000001;
  MAV_MODE_FLAG_TEST_ENABLED = $00000002;
  MAV_MODE_FLAG_AUTO_ENABLED = $00000004;
  MAV_MODE_FLAG_GUIDED_ENABLED = $00000008;
  MAV_MODE_FLAG_STABILIZE_ENABLED = $00000010;
  MAV_MODE_FLAG_HIL_ENABLED = $00000020;
  MAV_MODE_FLAG_MANUAL_INPUT_ENABLED = $00000040;
  MAV_MODE_FLAG_SAFETY_ARMED = $00000080;
  MAV_MODE_FLAG_ENUM_END = $00000081;
end;

// Constants for enum MAV_MODE_FLAG_DECODE_POSITION
type
  MAV_MODE_FLAG_DECODE_POSITION = record
const
  MAV_MODE_FLAG_DECODE_POSITION_CUSTOM_MODE = $00000001;
  MAV_MODE_FLAG_DECODE_POSITION_TEST = $00000002;
  MAV_MODE_FLAG_DECODE_POSITION_AUTO = $00000004;
  MAV_MODE_FLAG_DECODE_POSITION_GUIDED = $00000008;
  MAV_MODE_FLAG_DECODE_POSITION_STABILIZE = $00000010;
  MAV_MODE_FLAG_DECODE_POSITION_HIL = $00000020;
  MAV_MODE_FLAG_DECODE_POSITION_MANUAL = $00000040;
  MAV_MODE_FLAG_DECODE_POSITION_SAFETY = $00000080;
  MAV_MODE_FLAG_DECODE_POSITION_ENUM_END = $00000081;
end;

// Constants for enum MAV_GOTO
type
  MAV_GOTO = record
const
  MAV_GOTO_DO_HOLD = $00000000;
  MAV_GOTO_DO_CONTINUE = $00000001;
  MAV_GOTO_HOLD_AT_CURRENT_POSITION = $00000002;
  MAV_GOTO_HOLD_AT_SPECIFIED_POSITION = $00000003;
  MAV_GOTO_ENUM_END = $00000004;
end;

// Constants for enum MAV_MODE
type
  MAV_MODE = record
const
  MAV_MODE_PREFLIGHT = $00000000;
  MAV_MODE_MANUAL_DISARMED = $00000040;
  MAV_MODE_TEST_DISARMED = $00000042;
  MAV_MODE_STABILIZE_DISARMED = $00000050;
  MAV_MODE_GUIDED_DISARMED = $00000058;
  MAV_MODE_AUTO_DISARMED = $0000005C;
  MAV_MODE_MANUAL_ARMED = $000000C0;
  MAV_MODE_TEST_ARMED = $000000C2;
  MAV_MODE_STABILIZE_ARMED = $000000D0;
  MAV_MODE_GUIDED_ARMED = $000000D8;
  MAV_MODE_AUTO_ARMED = $000000DC;
  MAV_MODE_ENUM_END = $000000DD;
end;

// Constants for enum MAV_STATE
type
  MAV_STATE = record
const
  MAV_STATE_UNINIT = $00000000;
  MAV_STATE_BOOT = $00000001;
  MAV_STATE_CALIBRATING = $00000002;
  MAV_STATE_STANDBY = $00000003;
  MAV_STATE_ACTIVE = $00000004;
  MAV_STATE_CRITICAL = $00000005;
  MAV_STATE_EMERGENCY = $00000006;
  MAV_STATE_POWEROFF = $00000007;
  MAV_STATE_ENUM_END = $00000008;
end;

// Constants for enum MAV_COMPONENT
type
  MAV_COMPONENT = record
const
  MAV_COMPONENT_MAV_COMP_ID_ALL = $00000000;
  MAV_COMPONENT_MAV_COMP_ID_CAMERA = $00000064;
  MAV_COMPONENT_MAV_COMP_ID_SERVO1 = $0000008C;
  MAV_COMPONENT_MAV_COMP_ID_SERVO2 = $0000008D;
  MAV_COMPONENT_MAV_COMP_ID_SERVO3 = $0000008E;
  MAV_COMPONENT_MAV_COMP_ID_SERVO4 = $0000008F;
  MAV_COMPONENT_MAV_COMP_ID_SERVO5 = $00000090;
  MAV_COMPONENT_MAV_COMP_ID_SERVO6 = $00000091;
  MAV_COMPONENT_MAV_COMP_ID_SERVO7 = $00000092;
  MAV_COMPONENT_MAV_COMP_ID_SERVO8 = $00000093;
  MAV_COMPONENT_MAV_COMP_ID_SERVO9 = $00000094;
  MAV_COMPONENT_MAV_COMP_ID_SERVO10 = $00000095;
  MAV_COMPONENT_MAV_COMP_ID_SERVO11 = $00000096;
  MAV_COMPONENT_MAV_COMP_ID_SERVO12 = $00000097;
  MAV_COMPONENT_MAV_COMP_ID_SERVO13 = $00000098;
  MAV_COMPONENT_MAV_COMP_ID_SERVO14 = $00000099;
  MAV_COMPONENT_MAV_COMP_ID_GIMBAL = $0000009A;
  MAV_COMPONENT_MAV_COMP_ID_LOG = $0000009B;
  MAV_COMPONENT_MAV_COMP_ID_ADSB = $0000009C;
  MAV_COMPONENT_MAV_COMP_ID_MAPPER = $000000B4;
  MAV_COMPONENT_MAV_COMP_ID_MISSIONPLANNER = $000000BE;
  MAV_COMPONENT_MAV_COMP_ID_PATHPLANNER = $000000C3;
  MAV_COMPONENT_MAV_COMP_ID_IMU = $000000C8;
  MAV_COMPONENT_MAV_COMP_ID_IMU_2 = $000000C9;
  MAV_COMPONENT_MAV_COMP_ID_IMU_3 = $000000CA;
  MAV_COMPONENT_MAV_COMP_ID_GPS = $000000DC;
  MAV_COMPONENT_MAV_COMP_ID_UDP_BRIDGE = $000000F0;
  MAV_COMPONENT_MAV_COMP_ID_UART_BRIDGE = $000000F1;
  MAV_COMPONENT_MAV_COMP_ID_SYSTEM_CONTROL = $000000FA;
  MAV_COMPONENT_ENUM_END = $000000FB;
end;

// Constants for enum MAV_SYS_STATUS_SENSOR
type
  MAV_SYS_STATUS_SENSOR = record
const
  MAV_SYS_STATUS_SENSOR__3D_GYRO = $00000001;
  MAV_SYS_STATUS_SENSOR__3D_ACCEL = $00000002;
  MAV_SYS_STATUS_SENSOR__3D_MAG = $00000004;
  MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE = $00000008;
  MAV_SYS_STATUS_SENSOR_DIFFERENTIAL_PRESSURE = $00000010;
  MAV_SYS_STATUS_SENSOR_GPS = $00000020;
  MAV_SYS_STATUS_SENSOR_OPTICAL_FLOW = $00000040;
  MAV_SYS_STATUS_SENSOR_VISION_POSITION = $00000080;
  MAV_SYS_STATUS_SENSOR_LASER_POSITION = $00000100;
  MAV_SYS_STATUS_SENSOR_EXTERNAL_GROUND_TRUTH = $00000200;
  MAV_SYS_STATUS_SENSOR_ANGULAR_RATE_CONTROL = $00000400;
  MAV_SYS_STATUS_SENSOR_ATTITUDE_STABILIZATION = $00000800;
  MAV_SYS_STATUS_SENSOR_YAW_POSITION = $00001000;
  MAV_SYS_STATUS_SENSOR_Z_ALTITUDE_CONTROL = $00002000;
  MAV_SYS_STATUS_SENSOR_XY_POSITION_CONTROL = $00004000;
  MAV_SYS_STATUS_SENSOR_MOTOR_OUTPUTS = $00008000;
  MAV_SYS_STATUS_SENSOR_RC_RECEIVER = $00010000;
  MAV_SYS_STATUS_SENSOR__3D_GYRO2 = $00020000;
  MAV_SYS_STATUS_SENSOR__3D_ACCEL2 = $00040000;
  MAV_SYS_STATUS_SENSOR__3D_MAG2 = $00080000;
  MAV_SYS_STATUS_SENSOR_MAV_SYS_STATUS_GEOFENCE = $00100000;
  MAV_SYS_STATUS_SENSOR_MAV_SYS_STATUS_AHRS = $00200000;
  MAV_SYS_STATUS_SENSOR_MAV_SYS_STATUS_TERRAIN = $00400000;
  MAV_SYS_STATUS_SENSOR_ENUM_END = $00400001;
end;

// Constants for enum MAV_FRAME
type
  MAV_FRAME = record
const
  MAV_FRAME_GLOBAL = $00000000;
  MAV_FRAME_LOCAL_NED = $00000001;
  MAV_FRAME_MISSION = $00000002;
  MAV_FRAME_GLOBAL_RELATIVE_ALT = $00000003;
  MAV_FRAME_LOCAL_ENU = $00000004;
  MAV_FRAME_GLOBAL_INT = $00000005;
  MAV_FRAME_GLOBAL_RELATIVE_ALT_INT = $00000006;
  MAV_FRAME_LOCAL_OFFSET_NED = $00000007;
  MAV_FRAME_BODY_NED = $00000008;
  MAV_FRAME_BODY_OFFSET_NED = $00000009;
  MAV_FRAME_GLOBAL_TERRAIN_ALT = $0000000A;
  MAV_FRAME_GLOBAL_TERRAIN_ALT_INT = $0000000B;
  MAV_FRAME_ENUM_END = $0000000C;
end;

// Constants for enum MAVLINK_DATA_STREAM_TYPE
type
  MAVLINK_DATA_STREAM_TYPE = record
const
  MAVLINK_DATA_STREAM_TYPE_MAVLINK_DATA_STREAM_IMG_JPEG = $00000001;
  MAVLINK_DATA_STREAM_TYPE_MAVLINK_DATA_STREAM_IMG_BMP = $00000002;
  MAVLINK_DATA_STREAM_TYPE_MAVLINK_DATA_STREAM_IMG_RAW8U = $00000003;
  MAVLINK_DATA_STREAM_TYPE_MAVLINK_DATA_STREAM_IMG_RAW32U = $00000004;
  MAVLINK_DATA_STREAM_TYPE_MAVLINK_DATA_STREAM_IMG_PGM = $00000005;
  MAVLINK_DATA_STREAM_TYPE_MAVLINK_DATA_STREAM_IMG_PNG = $00000006;
  MAVLINK_DATA_STREAM_TYPE_ENUM_END = $00000007;
end;

// Constants for enum FENCE_ACTION
type
  FENCE_ACTION = record
const
  FENCE_ACTION_NONE = $00000000;
  FENCE_ACTION_GUIDED = $00000001;
  FENCE_ACTION_REPORT = $00000002;
  FENCE_ACTION_GUIDED_THR_PASS = $00000003;
  FENCE_ACTION_ENUM_END = $00000004;
end;

// Constants for enum FENCE_BREACH
type
  FENCE_BREACH = record
const
  FENCE_BREACH_NONE = $00000000;
  FENCE_BREACH_MINALT = $00000001;
  FENCE_BREACH_MAXALT = $00000002;
  FENCE_BREACH_BOUNDARY = $00000003;
  FENCE_BREACH_ENUM_END = $00000004;
end;

// Constants for enum MAV_MOUNT_MODE
type
  MAV_MOUNT_MODE = record
const
  MAV_MOUNT_MODE_RETRACT = $00000000;
  MAV_MOUNT_MODE_NEUTRAL = $00000001;
  MAV_MOUNT_MODE_MAVLINK_TARGETING = $00000002;
  MAV_MOUNT_MODE_RC_TARGETING = $00000003;
  MAV_MOUNT_MODE_GPS_POINT = $00000004;
  MAV_MOUNT_MODE_ENUM_END = $00000005;
end;

// Constants for enum MAV_DATA_STREAM
type
  MAV_DATA_STREAM = record
const
  MAV_DATA_STREAM_ALL = $00000000;
  MAV_DATA_STREAM_RAW_SENSORS = $00000001;
  MAV_DATA_STREAM_EXTENDED_STATUS = $00000002;
  MAV_DATA_STREAM_RC_CHANNELS = $00000003;
  MAV_DATA_STREAM_RAW_CONTROLLER = $00000004;
  MAV_DATA_STREAM_POSITION = $00000006;
  MAV_DATA_STREAM_EXTRA1 = $0000000A;
  MAV_DATA_STREAM_EXTRA2 = $0000000B;
  MAV_DATA_STREAM_EXTRA3 = $0000000C;
  MAV_DATA_STREAM_ENUM_END = $0000000D;
end;

// Constants for enum MAV_ROI
type
  MAV_ROI = record
const
  MAV_ROI_NONE = $00000000;
  MAV_ROI_WPNEXT = $00000001;
  MAV_ROI_WPINDEX = $00000002;
  MAV_ROI_LOCATION = $00000003;
  MAV_ROI_TARGET = $00000004;
  MAV_ROI_ENUM_END = $00000005;
end;

// Constants for enum MAV_CMD_ACK
type
  MAV_CMD_ACK = record
const
  MAV_CMD_ACK_OK = $00000001;
  MAV_CMD_ACK_ERR_FAIL = $00000002;
  MAV_CMD_ACK_ERR_ACCESS_DENIED = $00000003;
  MAV_CMD_ACK_ERR_NOT_SUPPORTED = $00000004;
  MAV_CMD_ACK_ERR_COORDINATE_FRAME_NOT_SUPPORTED = $00000005;
  MAV_CMD_ACK_ERR_COORDINATES_OUT_OF_RANGE = $00000006;
  MAV_CMD_ACK_ERR_X_LAT_OUT_OF_RANGE = $00000007;
  MAV_CMD_ACK_ERR_Y_LON_OUT_OF_RANGE = $00000008;
  MAV_CMD_ACK_ERR_Z_ALT_OUT_OF_RANGE = $00000009;
  MAV_CMD_ACK_ENUM_END = $0000000A;
end;

// Constants for enum MAV_PARAM_TYPE
type
  MAV_PARAM_TYPE = record
const
  MAV_PARAM_TYPE_UINT8 = $00000001;
  MAV_PARAM_TYPE_INT8 = $00000002;
  MAV_PARAM_TYPE_UINT16 = $00000003;
  MAV_PARAM_TYPE_INT16 = $00000004;
  MAV_PARAM_TYPE_UINT32 = $00000005;
  MAV_PARAM_TYPE_INT32 = $00000006;
  MAV_PARAM_TYPE_UINT64 = $00000007;
  MAV_PARAM_TYPE_INT64 = $00000008;
  MAV_PARAM_TYPE_REAL32 = $00000009;
  MAV_PARAM_TYPE_REAL64 = $0000000A;
  MAV_PARAM_TYPE_ENUM_END = $0000000B;
end;

// Constants for enum MAV_RESULT
type
  MAV_RESULT = record
const
  MAV_RESULT_ACCEPTED = $00000000;
  MAV_RESULT_TEMPORARILY_REJECTED = $00000001;
  MAV_RESULT_DENIED = $00000002;
  MAV_RESULT_UNSUPPORTED = $00000003;
  MAV_RESULT_FAILED = $00000004;
  MAV_RESULT_ENUM_END = $00000005;
end;

// Constants for enum MAV_MISSION_RESULT
type
  MAV_MISSION_RESULT = record
const
  MAV_MISSION_RESULT_MAV_MISSION_ACCEPTED = $00000000;
  MAV_MISSION_RESULT_MAV_MISSION_ERROR = $00000001;
  MAV_MISSION_RESULT_MAV_MISSION_UNSUPPORTED_FRAME = $00000002;
  MAV_MISSION_RESULT_MAV_MISSION_UNSUPPORTED = $00000003;
  MAV_MISSION_RESULT_MAV_MISSION_NO_SPACE = $00000004;
  MAV_MISSION_RESULT_MAV_MISSION_INVALID = $00000005;
  MAV_MISSION_RESULT_MAV_MISSION_INVALID_PARAM1 = $00000006;
  MAV_MISSION_RESULT_MAV_MISSION_INVALID_PARAM2 = $00000007;
  MAV_MISSION_RESULT_MAV_MISSION_INVALID_PARAM3 = $00000008;
  MAV_MISSION_RESULT_MAV_MISSION_INVALID_PARAM4 = $00000009;
  MAV_MISSION_RESULT_MAV_MISSION_INVALID_PARAM5_X = $0000000A;
  MAV_MISSION_RESULT_MAV_MISSION_INVALID_PARAM6_Y = $0000000B;
  MAV_MISSION_RESULT_MAV_MISSION_INVALID_PARAM7 = $0000000C;
  MAV_MISSION_RESULT_MAV_MISSION_INVALID_SEQUENCE = $0000000D;
  MAV_MISSION_RESULT_MAV_MISSION_DENIED = $0000000E;
  MAV_MISSION_RESULT_ENUM_END = $0000000F;
end;

// Constants for enum MAV_SEVERITY
type
  MAV_SEVERITY = record
const
  MAV_SEVERITY_EMERGENCY = $00000000;
  MAV_SEVERITY_ALERT = $00000001;
  MAV_SEVERITY_CRITICAL = $00000002;
  MAV_SEVERITY_ERROR = $00000003;
  MAV_SEVERITY_WARNING = $00000004;
  MAV_SEVERITY_NOTICE = $00000005;
  MAV_SEVERITY_INFO = $00000006;
  MAV_SEVERITY_DEBUG = $00000007;
  MAV_SEVERITY_ENUM_END = $00000008;
end;

// Constants for enum MAV_POWER_STATUS
type
  MAV_POWER_STATUS = record
const
  MAV_POWER_STATUS_BRICK_VALID = $00000001;
  MAV_POWER_STATUS_SERVO_VALID = $00000002;
  MAV_POWER_STATUS_USB_CONNECTED = $00000004;
  MAV_POWER_STATUS_PERIPH_OVERCURRENT = $00000008;
  MAV_POWER_STATUS_PERIPH_HIPOWER_OVERCURRENT = $00000010;
  MAV_POWER_STATUS_CHANGED = $00000020;
  MAV_POWER_STATUS_ENUM_END = $00000021;
end;

// Constants for enum SERIAL_CONTROL_DEV
type
  SERIAL_CONTROL_DEV = record
const
  SERIAL_CONTROL_DEV_TELEM1 = $00000000;
  SERIAL_CONTROL_DEV_TELEM2 = $00000001;
  SERIAL_CONTROL_DEV_GPS1 = $00000002;
  SERIAL_CONTROL_DEV_GPS2 = $00000003;
  SERIAL_CONTROL_DEV_SHELL = $0000000A;
  SERIAL_CONTROL_DEV_ENUM_END = $0000000B;
end;

// Constants for enum SERIAL_CONTROL_FLAG
type
  SERIAL_CONTROL_FLAG = record
const
  SERIAL_CONTROL_FLAG_REPLY = $00000001;
  SERIAL_CONTROL_FLAG_RESPOND = $00000002;
  SERIAL_CONTROL_FLAG_EXCLUSIVE = $00000004;
  SERIAL_CONTROL_FLAG_BLOCKING = $00000008;
  SERIAL_CONTROL_FLAG_MULTI = $00000010;
  SERIAL_CONTROL_FLAG_ENUM_END = $00000011;
end;

// Constants for enum MAV_DISTANCE_SENSOR
type
  MAV_DISTANCE_SENSOR = record
const
  MAV_DISTANCE_SENSOR_LASER = $00000000;
  MAV_DISTANCE_SENSOR_ULTRASOUND = $00000001;
  MAV_DISTANCE_SENSOR_ENUM_END = $00000002;
end;

// Constants for enum MAV_PROTOCOL_CAPABILITY
type
  MAV_PROTOCOL_CAPABILITY = record
const
  MAV_PROTOCOL_CAPABILITY_MISSION_FLOAT = $00000001;
  MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT = $00000002;
  MAV_PROTOCOL_CAPABILITY_MISSION_INT = $00000004;
  MAV_PROTOCOL_CAPABILITY_COMMAND_INT = $00000008;
  MAV_PROTOCOL_CAPABILITY_PARAM_UNION = $00000010;
  MAV_PROTOCOL_CAPABILITY_FTP = $00000020;
  MAV_PROTOCOL_CAPABILITY_SET_ATTITUDE_TARGET = $00000040;
  MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_LOCAL_NED = $00000080;
  MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_GLOBAL_INT = $00000100;
  MAV_PROTOCOL_CAPABILITY_TERRAIN = $00000200;
  MAV_PROTOCOL_CAPABILITY_SET_ACTUATOR_TARGET = $00000400;
  MAV_PROTOCOL_CAPABILITY_FLIGHT_TERMINATION = $00000800;
  MAV_PROTOCOL_CAPABILITY_COMPASS_CALIBRATION = $00001000;
  MAV_PROTOCOL_CAPABILITY_ENUM_END = $00001001;
end;

// Constants for enum MAV_ESTIMATOR_TYPE
type
  MAV_ESTIMATOR_TYPE = record
const
  MAV_ESTIMATOR_TYPE_NAIVE = $00000001;
  MAV_ESTIMATOR_TYPE_VISION = $00000002;
  MAV_ESTIMATOR_TYPE_VIO = $00000003;
  MAV_ESTIMATOR_TYPE_GPS = $00000004;
  MAV_ESTIMATOR_TYPE_GPS_INS = $00000005;
  MAV_ESTIMATOR_TYPE_ENUM_END = $00000006;
end;

// Constants for enum MAV_BATTERY_TYPE
type
  MAV_BATTERY_TYPE = record
const
  MAV_BATTERY_TYPE_UNKNOWN = $00000000;
  MAV_BATTERY_TYPE_LIPO = $00000001;
  MAV_BATTERY_TYPE_LIFE = $00000002;
  MAV_BATTERY_TYPE_LION = $00000003;
  MAV_BATTERY_TYPE_NIMH = $00000004;
  MAV_BATTERY_TYPE_ENUM_END = $00000005;
end;

// Constants for enum MAV_BATTERY_FUNCTION
type
  MAV_BATTERY_FUNCTION = record
const
  MAV_BATTERY_FUNCTION_UNKNOWN = $00000000;
  MAV_BATTERY_FUNCTION_ALL = $00000001;
  MAV_BATTERY_FUNCTION_PROPULSION = $00000002;
  MAV_BATTERY_FUNCTION_AVIONICS = $00000003;
  MAV_BATTERY_FUNCTION_MAV_BATTERY_TYPE_PAYLOAD = $00000004;
  MAV_BATTERY_FUNCTION_ENUM_END = $00000005;
end;

// Constants for enum ADSB_ALTITUDE_TYPE
type
  ADSB_ALTITUDE_TYPE = record
const
  ADSB_ALTITUDE_TYPE_PRESSURE_QNH = $00000000;
  ADSB_ALTITUDE_TYPE_GEOMETRIC = $00000001;
  ADSB_ALTITUDE_TYPE_ENUM_END = $00000002;
end;

// Constants for enum ADSB_EMITTER_TYPE
type
  ADSB_EMITTER_TYPE = record
const
  ADSB_EMITTER_TYPE_NO_INFO = $00000000;
  ADSB_EMITTER_TYPE_LIGHT = $00000001;
  ADSB_EMITTER_TYPE_SMALL = $00000002;
  ADSB_EMITTER_TYPE_LARGE = $00000003;
  ADSB_EMITTER_TYPE_HIGH_VORTEX_LARGE = $00000004;
  ADSB_EMITTER_TYPE_HEAVY = $00000005;
  ADSB_EMITTER_TYPE_HIGHLY_MANUV = $00000006;
  ADSB_EMITTER_TYPE_ROTOCRAFT = $00000007;
  ADSB_EMITTER_TYPE_UNASSIGNED = $00000008;
  ADSB_EMITTER_TYPE_GLIDER = $00000009;
  ADSB_EMITTER_TYPE_LIGHTER_AIR = $0000000A;
  ADSB_EMITTER_TYPE_PARACHUTE = $0000000B;
  ADSB_EMITTER_TYPE_ULTRA_LIGHT = $0000000C;
  ADSB_EMITTER_TYPE_UNASSIGNED2 = $0000000D;
  ADSB_EMITTER_TYPE_UAV = $0000000E;
  ADSB_EMITTER_TYPE_SPACE = $0000000F;
  ADSB_EMITTER_TYPE_UNASSGINED3 = $00000010;
  ADSB_EMITTER_TYPE_EMERGENCY_SURFACE = $00000011;
  ADSB_EMITTER_TYPE_SERVICE_SURFACE = $00000012;
  ADSB_EMITTER_TYPE_POINT_OBSTACLE = $00000013;
  ADSB_EMITTER_TYPE_ENUM_END = $00000014;
end;

// Constants for enum ADSB_FLAGS
type
  ADSB_FLAGS = record
const
  ADSB_FLAGS_VALID_COORDS = $00000001;
  ADSB_FLAGS_VALID_ALTITUDE = $00000002;
  ADSB_FLAGS_VALID_HEADING = $00000004;
  ADSB_FLAGS_VALID_VELOCITY = $00000008;
  ADSB_FLAGS_VALID_CALLSIGN = $00000010;
  ADSB_FLAGS_VALID_SQUAWK = $00000020;
  ADSB_FLAGS_SIMULATED = $00000040;
  ADSB_FLAGS_ENUM_END = $00000041;
end;

type
// *********************************************************************//
// Declaration of structures, unions and aliases.
// *********************************************************************//
{$ALIGN 1}
  mavlink_sensor_offsets_t = record
    mag_declination: Single;
    raw_press: Integer;
    raw_temp: Integer;
    gyro_cal_x: Single;
    gyro_cal_y: Single;
    gyro_cal_z: Single;
    accel_cal_x: Single;
    accel_cal_y: Single;
    accel_cal_z: Single;
    mag_ofs_x: Smallint;
    mag_ofs_y: Smallint;
    mag_ofs_z: Smallint;
  end;

  mavlink_set_mag_offsets_t = record
    mag_ofs_x: Smallint;
    mag_ofs_y: Smallint;
    mag_ofs_z: Smallint;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_meminfo_t = record
    brkval: Word;
    freemem: Word;
  end;

  mavlink_ap_adc_t = record
    adc1: Word;
    adc2: Word;
    adc3: Word;
    adc4: Word;
    adc5: Word;
    adc6: Word;
  end;

  mavlink_digicam_configure_t = record
    extra_value: Single;
    shutter_speed: Word;
    target_system: Byte;
    target_component: Byte;
    mode: Byte;
    aperture: Byte;
    iso: Byte;
    exposure_type: Byte;
    command_id: Byte;
    engine_cut_off: Byte;
    extra_param: Byte;
  end;

  mavlink_digicam_control_t = record
    extra_value: Single;
    target_system: Byte;
    target_component: Byte;
    session: Byte;
    zoom_pos: Byte;
    zoom_step: Byte;
    focus_lock: Byte;
    shot: Byte;
    command_id: Byte;
    extra_param: Byte;
  end;

  mavlink_mount_configure_t = record
    target_system: Byte;
    target_component: Byte;
    mount_mode: Byte;
    stab_roll: Byte;
    stab_pitch: Byte;
    stab_yaw: Byte;
  end;

  mavlink_mount_control_t = record
    input_a: Integer;
    input_b: Integer;
    input_c: Integer;
    target_system: Byte;
    target_component: Byte;
    save_position: Byte;
  end;

  mavlink_mount_status_t = record
    pointing_a: Integer;
    pointing_b: Integer;
    pointing_c: Integer;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_fence_point_t = record
    lat: Single;
    lng: Single;
    target_system: Byte;
    target_component: Byte;
    idx: Byte;
    count: Byte;
  end;

  mavlink_fence_fetch_point_t = record
    target_system: Byte;
    target_component: Byte;
    idx: Byte;
  end;

  mavlink_fence_status_t = record
    breach_time: LongWord;
    breach_count: Word;
    breach_status: Byte;
    breach_type: Byte;
  end;

  mavlink_ahrs_t = record
    omegaIx: Single;
    omegaIy: Single;
    omegaIz: Single;
    accel_weight: Single;
    renorm_val: Single;
    error_rp: Single;
    error_yaw: Single;
  end;

  mavlink_simstate_t = record
    roll: Single;
    pitch: Single;
    yaw: Single;
    xacc: Single;
    yacc: Single;
    zacc: Single;
    xgyro: Single;
    ygyro: Single;
    zgyro: Single;
    lat: Integer;
    lng: Integer;
  end;

  mavlink_hwstatus_t = record
    Vcc: Word;
    I2Cerr: Byte;
  end;

  mavlink_radio_t = record
    rxerrors: Word;
    fixed: Word;
    rssi: Byte;
    remrssi: Byte;
    txbuf: Byte;
    noise: Byte;
    remnoise: Byte;
  end;

  mavlink_limits_status_t = record
    last_trigger: LongWord;
    last_action: LongWord;
    last_recovery: LongWord;
    last_clear: LongWord;
    breach_count: Word;
    LIMITS_STATE: Byte;
    mods_enabled: Byte;
    mods_required: Byte;
    mods_triggered: Byte;
  end;

  mavlink_wind_t = record
    direction: Single;
    speed: Single;
    speed_z: Single;
  end;

  mavlink_data16_t = record
    type_: Byte;
    len: Byte;
    data: array[0..15] of Byte;
  end;

  mavlink_data32_t = record
    type_: Byte;
    len: Byte;
    data: array[0..31] of Byte;
  end;

  mavlink_data64_t = record
    type_: Byte;
    len: Byte;
    data: array[0..63] of Byte;
  end;

  mavlink_data96_t = record
    type_: Byte;
    len: Byte;
    data: array[0..95] of Byte;
  end;

  mavlink_rangefinder_t = record
    distance: Single;
    voltage: Single;
  end;

  mavlink_airspeed_autocal_t = record
    vx: Single;
    vy: Single;
    vz: Single;
    diff_pressure: Single;
    EAS2TAS: Single;
    ratio: Single;
    state_x: Single;
    state_y: Single;
    state_z: Single;
    Pax: Single;
    Pby: Single;
    Pcz: Single;
  end;

  mavlink_rally_point_t = record
    lat: Integer;
    lng: Integer;
    alt: Smallint;
    break_alt: Smallint;
    land_dir: Word;
    target_system: Byte;
    target_component: Byte;
    idx: Byte;
    count: Byte;
    flags: Byte;
  end;

  mavlink_rally_fetch_point_t = record
    target_system: Byte;
    target_component: Byte;
    idx: Byte;
  end;

  mavlink_compassmot_status_t = record
    current: Single;
    CompensationX: Single;
    CompensationY: Single;
    CompensationZ: Single;
    throttle: Word;
    interference: Word;
  end;

  mavlink_ahrs2_t = record
    roll: Single;
    pitch: Single;
    yaw: Single;
    altitude: Single;
    lat: Integer;
    lng: Integer;
  end;

  mavlink_camera_status_t = record
    time_usec: Largeuint;
    p1: Single;
    p2: Single;
    p3: Single;
    p4: Single;
    img_idx: Word;
    target_system: Byte;
    cam_idx: Byte;
    event_id: Byte;
  end;

  mavlink_camera_feedback_t = record
    time_usec: Largeuint;
    lat: Integer;
    lng: Integer;
    alt_msl: Single;
    alt_rel: Single;
    roll: Single;
    pitch: Single;
    yaw: Single;
    foc_len: Single;
    img_idx: Word;
    target_system: Byte;
    cam_idx: Byte;
    flags: Byte;
  end;

  mavlink_battery2_t = record
    voltage: Word;
    current_battery: Smallint;
  end;

  mavlink_ahrs3_t = record
    roll: Single;
    pitch: Single;
    yaw: Single;
    altitude: Single;
    lat: Integer;
    lng: Integer;
    v1: Single;
    v2: Single;
    v3: Single;
    v4: Single;
  end;

  mavlink_autopilot_version_request_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_remote_log_data_block_t = record
    seqno: LongWord;
    target_system: Byte;
    target_component: Byte;
    data: array[0..199] of Byte;
  end;

  mavlink_remote_log_block_status_t = record
    seqno: LongWord;
    target_system: Byte;
    target_component: Byte;
    status: Byte;
  end;

  mavlink_led_control_t = record
    target_system: Byte;
    target_component: Byte;
    instance: Byte;
    pattern: Byte;
    custom_len: Byte;
    custom_bytes: array[0..23] of Byte;
  end;

  mavlink_mag_cal_progress_t = record
    direction_x: Single;
    direction_y: Single;
    direction_z: Single;
    compass_id: Byte;
    cal_mask: Byte;
    cal_status: Byte;
    attempt: Byte;
    completion_pct: Byte;
    completion_mask: array[0..9] of Byte;
  end;

  mavlink_mag_cal_report_t = record
    fitness: Single;
    ofs_x: Single;
    ofs_y: Single;
    ofs_z: Single;
    diag_x: Single;
    diag_y: Single;
    diag_z: Single;
    offdiag_x: Single;
    offdiag_y: Single;
    offdiag_z: Single;
    compass_id: Byte;
    cal_mask: Byte;
    cal_status: Byte;
    autosaved: Byte;
  end;

  mavlink_ekf_status_report_t = record
    velocity_variance: Single;
    pos_horiz_variance: Single;
    pos_vert_variance: Single;
    compass_variance: Single;
    terrain_alt_variance: Single;
    flags: Word;
  end;

  mavlink_pid_tuning_t = record
    desired: Single;
    achieved: Single;
    FF: Single;
    P: Single;
    I: Single;
    D: Single;
    axis: Byte;
  end;

  mavlink_gimbal_report_t = record
    delta_time: Single;
    delta_angle_x: Single;
    delta_angle_y: Single;
    delta_angle_z: Single;
    delta_velocity_x: Single;
    delta_velocity_y: Single;
    delta_velocity_z: Single;
    joint_roll: Single;
    joint_el: Single;
    joint_az: Single;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_gimbal_control_t = record
    demanded_rate_x: Single;
    demanded_rate_y: Single;
    demanded_rate_z: Single;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_gimbal_reset_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_gimbal_axis_calibration_progress_t = record
    calibration_axis: Byte;
    calibration_progress: Byte;
    calibration_status: Byte;
  end;

  mavlink_gimbal_set_home_offsets_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_gimbal_home_offset_calibration_result_t = record
    calibration_result: Byte;
  end;

  mavlink_gimbal_set_factory_parameters_t = record
    magic_1: LongWord;
    magic_2: LongWord;
    magic_3: LongWord;
    serial_number_pt_1: LongWord;
    serial_number_pt_2: LongWord;
    serial_number_pt_3: LongWord;
    assembly_year: Word;
    target_system: Byte;
    target_component: Byte;
    assembly_month: Byte;
    assembly_day: Byte;
    assembly_hour: Byte;
    assembly_minute: Byte;
    assembly_second: Byte;
  end;

  mavlink_gimbal_factory_parameters_loaded_t = record
    dummy: Byte;
  end;

  mavlink_gimbal_erase_firmware_and_config_t = record
    knock: LongWord;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_gimbal_perform_factory_tests_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_gimbal_report_factory_tests_progress_t = record
    test: Byte;
    test_section: Byte;
    test_section_progress: Byte;
    test_status: Byte;
  end;

  mavlink_gimbal_request_axis_calibration_status_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_gimbal_report_axis_calibration_status_t = record
    yaw_requires_calibration: Byte;
    pitch_requires_calibration: Byte;
    roll_requires_calibration: Byte;
  end;

  mavlink_gimbal_request_axis_calibration_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_gopro_heartbeat_t = record
    status: Byte;
  end;

  mavlink_gopro_get_request_t = record
    target_system: Byte;
    target_component: Byte;
    cmd_id: Byte;
  end;

  mavlink_gopro_get_response_t = record
    cmd_id: Byte;
    value: Byte;
  end;

  mavlink_gopro_set_request_t = record
    target_system: Byte;
    target_component: Byte;
    cmd_id: Byte;
    value: Byte;
  end;

  mavlink_gopro_set_response_t = record
    cmd_id: Byte;
    result: Byte;
  end;

  mavlink_rpm_t = record
    rpm1: Single;
    rpm2: Single;
  end;

  mavlink_heartbeat_t = record
    custom_mode: LongWord;
    type_: Byte;
    autopilot: Byte;
    base_mode: Byte;
    system_status: Byte;
    mavlink_version: Byte;
  end;

  mavlink_sys_status_t = record
    onboard_control_sensors_present: LongWord;
    onboard_control_sensors_enabled: LongWord;
    onboard_control_sensors_health: LongWord;
    load: Word;
    voltage_battery: Word;
    current_battery: Smallint;
    drop_rate_comm: Word;
    errors_comm: Word;
    errors_count1: Word;
    errors_count2: Word;
    errors_count3: Word;
    errors_count4: Word;
    battery_remaining: Byte;
  end;

  mavlink_system_time_t = record
    time_unix_usec: Largeuint;
    time_boot_ms: LongWord;
  end;

  mavlink_ping_t = record
    time_usec: Largeuint;
    seq: LongWord;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_change_operator_control_t = record
    target_system: Byte;
    control_request: Byte;
    version: Byte;
    passkey: array[0..24] of Byte;
  end;

  mavlink_change_operator_control_ack_t = record
    gcs_system_id: Byte;
    control_request: Byte;
    ack: Byte;
  end;

  mavlink_auth_key_t = record
    key: array[0..31] of Byte;
  end;

  mavlink_set_mode_t = record
    custom_mode: LongWord;
    target_system: Byte;
    base_mode: Byte;
  end;

  mavlink_param_request_read_t = record
    param_index: Smallint;
    target_system: Byte;
    target_component: Byte;
    param_id: array[0..15] of Byte;
  end;

  mavlink_param_request_list_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_param_value_t = record
    param_value: Single;
    param_count: Word;
    param_index: Word;
    param_id: array[0..15] of Byte;
    param_type: Byte;
  end;

  mavlink_param_set_t = record
    param_value: Single;
    target_system: Byte;
    target_component: Byte;
    param_id: array[0..15] of Byte;
    param_type: Byte;
  end;

  mavlink_gps_raw_int_t = record
    time_usec: Largeuint;
    lat: Integer;
    lon: Integer;
    alt: Integer;
    eph: Word;
    epv: Word;
    vel: Word;
    cog: Word;
    fix_type: Byte;
    satellites_visible: Byte;
  end;

  mavlink_gps_status_t = record
    satellites_visible: Byte;
    satellite_prn: array[0..19] of Byte;
    satellite_used: array[0..19] of Byte;
    satellite_elevation: array[0..19] of Byte;
    satellite_azimuth: array[0..19] of Byte;
    satellite_snr: array[0..19] of Byte;
  end;

  mavlink_scaled_imu_t = record
    time_boot_ms: LongWord;
    xacc: Smallint;
    yacc: Smallint;
    zacc: Smallint;
    xgyro: Smallint;
    ygyro: Smallint;
    zgyro: Smallint;
    xmag: Smallint;
    ymag: Smallint;
    zmag: Smallint;
  end;

  mavlink_raw_imu_t = record
    time_usec: Largeuint;
    xacc: Smallint;
    yacc: Smallint;
    zacc: Smallint;
    xgyro: Smallint;
    ygyro: Smallint;
    zgyro: Smallint;
    xmag: Smallint;
    ymag: Smallint;
    zmag: Smallint;
  end;

  mavlink_raw_pressure_t = record
    time_usec: Largeuint;
    press_abs: Smallint;
    press_diff1: Smallint;
    press_diff2: Smallint;
    temperature: Smallint;
  end;

  mavlink_scaled_pressure_t = record
    time_boot_ms: LongWord;
    press_abs: Single;
    press_diff: Single;
    temperature: Smallint;
  end;

  mavlink_attitude_t = record
    time_boot_ms: LongWord;
    roll: Single;
    pitch: Single;
    yaw: Single;
    rollspeed: Single;
    pitchspeed: Single;
    yawspeed: Single;
  end;

  mavlink_attitude_quaternion_t = record
    time_boot_ms: LongWord;
    q1: Single;
    q2: Single;
    q3: Single;
    q4: Single;
    rollspeed: Single;
    pitchspeed: Single;
    yawspeed: Single;
  end;

  mavlink_local_position_ned_t = record
    time_boot_ms: LongWord;
    x: Single;
    y: Single;
    z: Single;
    vx: Single;
    vy: Single;
    vz: Single;
  end;

  mavlink_global_position_int_t = record
    time_boot_ms: LongWord;
    lat: Integer;
    lon: Integer;
    alt: Integer;
    relative_alt: Integer;
    vx: Smallint;
    vy: Smallint;
    vz: Smallint;
    hdg: Word;
  end;

  mavlink_rc_channels_scaled_t = record
    time_boot_ms: LongWord;
    chan1_scaled: Smallint;
    chan2_scaled: Smallint;
    chan3_scaled: Smallint;
    chan4_scaled: Smallint;
    chan5_scaled: Smallint;
    chan6_scaled: Smallint;
    chan7_scaled: Smallint;
    chan8_scaled: Smallint;
    port: Byte;
    rssi: Byte;
  end;

  mavlink_rc_channels_raw_t = record
    time_boot_ms: LongWord;
    chan1_raw: Word;
    chan2_raw: Word;
    chan3_raw: Word;
    chan4_raw: Word;
    chan5_raw: Word;
    chan6_raw: Word;
    chan7_raw: Word;
    chan8_raw: Word;
    port: Byte;
    rssi: Byte;
  end;

  mavlink_servo_output_raw_t = record
    time_usec: LongWord;
    servo1_raw: Word;
    servo2_raw: Word;
    servo3_raw: Word;
    servo4_raw: Word;
    servo5_raw: Word;
    servo6_raw: Word;
    servo7_raw: Word;
    servo8_raw: Word;
    port: Byte;
  end;

  mavlink_mission_request_partial_list_t = record
    start_index: Smallint;
    end_index: Smallint;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_mission_write_partial_list_t = record
    start_index: Smallint;
    end_index: Smallint;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_mission_item_t = record
    param1: Single;
    param2: Single;
    param3: Single;
    param4: Single;
    x: Single;
    y: Single;
    z: Single;
    seq: Word;
    command: Word;
    target_system: Byte;
    target_component: Byte;
    frame: Byte;
    current: Byte;
    autocontinue: Byte;
  end;

  mavlink_mission_request_t = record
    seq: Word;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_mission_set_current_t = record
    seq: Word;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_mission_current_t = record
    seq: Word;
  end;

  mavlink_mission_request_list_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_mission_count_t = record
    count: Word;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_mission_clear_all_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_mission_item_reached_t = record
    seq: Word;
  end;

  mavlink_mission_ack_t = record
    target_system: Byte;
    target_component: Byte;
    type_: Byte;
  end;

  mavlink_set_gps_global_origin_t = record
    latitude: Integer;
    longitude: Integer;
    altitude: Integer;
    target_system: Byte;
  end;

  mavlink_gps_global_origin_t = record
    latitude: Integer;
    longitude: Integer;
    altitude: Integer;
  end;

  mavlink_param_map_rc_t = record
    param_value0: Single;
    scale: Single;
    param_value_min: Single;
    param_value_max: Single;
    param_index: Smallint;
    target_system: Byte;
    target_component: Byte;
    param_id: array[0..15] of Byte;
    parameter_rc_channel_index: Byte;
  end;

  mavlink_safety_set_allowed_area_t = record
    p1x: Single;
    p1y: Single;
    p1z: Single;
    p2x: Single;
    p2y: Single;
    p2z: Single;
    target_system: Byte;
    target_component: Byte;
    frame: Byte;
  end;

  mavlink_safety_allowed_area_t = record
    p1x: Single;
    p1y: Single;
    p1z: Single;
    p2x: Single;
    p2y: Single;
    p2z: Single;
    frame: Byte;
  end;

  mavlink_attitude_quaternion_cov_t = record
    time_boot_ms: LongWord;
    q: Single;
    rollspeed: Single;
    pitchspeed: Single;
    yawspeed: Single;
    covariance: Single;
  end;

  mavlink_nav_controller_output_t = record
    nav_roll: Single;
    nav_pitch: Single;
    alt_error: Single;
    aspd_error: Single;
    xtrack_error: Single;
    nav_bearing: Smallint;
    target_bearing: Smallint;
    wp_dist: Word;
  end;

  mavlink_global_position_int_cov_t = record
    time_utc: Largeuint;
    time_boot_ms: LongWord;
    lat: Integer;
    lon: Integer;
    alt: Integer;
    relative_alt: Integer;
    vx: Single;
    vy: Single;
    vz: Single;
    covariance: Single;
    estimator_type: Byte;
  end;

  mavlink_local_position_ned_cov_t = record
    time_utc: Largeuint;
    time_boot_ms: LongWord;
    x: Single;
    y: Single;
    z: Single;
    vx: Single;
    vy: Single;
    vz: Single;
    covariance: Single;
    estimator_type: Byte;
  end;

  mavlink_rc_channels_t = record
    time_boot_ms: LongWord;
    chan1_raw: Word;
    chan2_raw: Word;
    chan3_raw: Word;
    chan4_raw: Word;
    chan5_raw: Word;
    chan6_raw: Word;
    chan7_raw: Word;
    chan8_raw: Word;
    chan9_raw: Word;
    chan10_raw: Word;
    chan11_raw: Word;
    chan12_raw: Word;
    chan13_raw: Word;
    chan14_raw: Word;
    chan15_raw: Word;
    chan16_raw: Word;
    chan17_raw: Word;
    chan18_raw: Word;
    chancount: Byte;
    rssi: Byte;
  end;

  mavlink_request_data_stream_t = record
    req_message_rate: Word;
    target_system: Byte;
    target_component: Byte;
    req_stream_id: Byte;
    start_stop: Byte;
  end;

  mavlink_data_stream_t = record
    message_rate: Word;
    stream_id: Byte;
    on_off: Byte;
  end;

  mavlink_manual_control_t = record
    x: Smallint;
    y: Smallint;
    z: Smallint;
    r: Smallint;
    buttons: Word;
    target: Byte;
  end;

  mavlink_rc_channels_override_t = record
    chan1_raw: Word;
    chan2_raw: Word;
    chan3_raw: Word;
    chan4_raw: Word;
    chan5_raw: Word;
    chan6_raw: Word;
    chan7_raw: Word;
    chan8_raw: Word;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_mission_item_int_t = record
    param1: Single;
    param2: Single;
    param3: Single;
    param4: Single;
    x: Integer;
    y: Integer;
    z: Single;
    seq: Word;
    command: Word;
    target_system: Byte;
    target_component: Byte;
    frame: Byte;
    current: Byte;
    autocontinue: Byte;
  end;

  mavlink_vfr_hud_t = record
    airspeed: Single;
    groundspeed: Single;
    alt: Single;
    climb: Single;
    heading: Smallint;
    throttle: Word;
  end;

  mavlink_command_int_t = record
    param1: Single;
    param2: Single;
    param3: Single;
    param4: Single;
    x: Integer;
    y: Integer;
    z: Single;
    command: Word;
    target_system: Byte;
    target_component: Byte;
    frame: Byte;
    current: Byte;
    autocontinue: Byte;
  end;

  mavlink_command_long_t = record
    param1: Single;
    param2: Single;
    param3: Single;
    param4: Single;
    param5: Single;
    param6: Single;
    param7: Single;
    command: Word;
    target_system: Byte;
    target_component: Byte;
    confirmation: Byte;
  end;

  mavlink_command_ack_t = record
    command: Word;
    result: Byte;
  end;

  mavlink_manual_setpoint_t = record
    time_boot_ms: LongWord;
    roll: Single;
    pitch: Single;
    yaw: Single;
    thrust: Single;
    mode_switch: Byte;
    manual_override_switch: Byte;
  end;

  mavlink_set_attitude_target_t = record
    time_boot_ms: LongWord;
    q: Single;
    body_roll_rate: Single;
    body_pitch_rate: Single;
    body_yaw_rate: Single;
    thrust: Single;
    target_system: Byte;
    target_component: Byte;
    type_mask: Byte;
  end;

  mavlink_attitude_target_t = record
    time_boot_ms: LongWord;
    q: Single;
    body_roll_rate: Single;
    body_pitch_rate: Single;
    body_yaw_rate: Single;
    thrust: Single;
    type_mask: Byte;
  end;

  mavlink_set_position_target_local_ned_t = record
    time_boot_ms: LongWord;
    x: Single;
    y: Single;
    z: Single;
    vx: Single;
    vy: Single;
    vz: Single;
    afx: Single;
    afy: Single;
    afz: Single;
    yaw: Single;
    yaw_rate: Single;
    type_mask: Word;
    target_system: Byte;
    target_component: Byte;
    coordinate_frame: Byte;
  end;

  mavlink_position_target_local_ned_t = record
    time_boot_ms: LongWord;
    x: Single;
    y: Single;
    z: Single;
    vx: Single;
    vy: Single;
    vz: Single;
    afx: Single;
    afy: Single;
    afz: Single;
    yaw: Single;
    yaw_rate: Single;
    type_mask: Word;
    coordinate_frame: Byte;
  end;

  mavlink_set_position_target_global_int_t = record
    time_boot_ms: LongWord;
    lat_int: Integer;
    lon_int: Integer;
    alt: Single;
    vx: Single;
    vy: Single;
    vz: Single;
    afx: Single;
    afy: Single;
    afz: Single;
    yaw: Single;
    yaw_rate: Single;
    type_mask: Word;
    target_system: Byte;
    target_component: Byte;
    coordinate_frame: Byte;
  end;

  mavlink_position_target_global_int_t = record
    time_boot_ms: LongWord;
    lat_int: Integer;
    lon_int: Integer;
    alt: Single;
    vx: Single;
    vy: Single;
    vz: Single;
    afx: Single;
    afy: Single;
    afz: Single;
    yaw: Single;
    yaw_rate: Single;
    type_mask: Word;
    coordinate_frame: Byte;
  end;

  mavlink_local_position_ned_system_global_offset_t = record
    time_boot_ms: LongWord;
    x: Single;
    y: Single;
    z: Single;
    roll: Single;
    pitch: Single;
    yaw: Single;
  end;

  mavlink_hil_state_t = record
    time_usec: Largeuint;
    roll: Single;
    pitch: Single;
    yaw: Single;
    rollspeed: Single;
    pitchspeed: Single;
    yawspeed: Single;
    lat: Integer;
    lon: Integer;
    alt: Integer;
    vx: Smallint;
    vy: Smallint;
    vz: Smallint;
    xacc: Smallint;
    yacc: Smallint;
    zacc: Smallint;
  end;

  mavlink_hil_controls_t = record
    time_usec: Largeuint;
    roll_ailerons: Single;
    pitch_elevator: Single;
    yaw_rudder: Single;
    throttle: Single;
    aux1: Single;
    aux2: Single;
    aux3: Single;
    aux4: Single;
    mode: Byte;
    nav_mode: Byte;
  end;

  mavlink_hil_rc_inputs_raw_t = record
    time_usec: Largeuint;
    chan1_raw: Word;
    chan2_raw: Word;
    chan3_raw: Word;
    chan4_raw: Word;
    chan5_raw: Word;
    chan6_raw: Word;
    chan7_raw: Word;
    chan8_raw: Word;
    chan9_raw: Word;
    chan10_raw: Word;
    chan11_raw: Word;
    chan12_raw: Word;
    rssi: Byte;
  end;

  mavlink_optical_flow_t = record
    time_usec: Largeuint;
    flow_comp_m_x: Single;
    flow_comp_m_y: Single;
    ground_distance: Single;
    flow_x: Smallint;
    flow_y: Smallint;
    sensor_id: Byte;
    quality: Byte;
  end;

  mavlink_global_vision_position_estimate_t = record
    usec: Largeuint;
    x: Single;
    y: Single;
    z: Single;
    roll: Single;
    pitch: Single;
    yaw: Single;
  end;

  mavlink_vision_position_estimate_t = record
    usec: Largeuint;
    x: Single;
    y: Single;
    z: Single;
    roll: Single;
    pitch: Single;
    yaw: Single;
  end;

  mavlink_vision_speed_estimate_t = record
    usec: Largeuint;
    x: Single;
    y: Single;
    z: Single;
  end;

  mavlink_vicon_position_estimate_t = record
    usec: Largeuint;
    x: Single;
    y: Single;
    z: Single;
    roll: Single;
    pitch: Single;
    yaw: Single;
  end;

  mavlink_highres_imu_t = record
    time_usec: Largeuint;
    xacc: Single;
    yacc: Single;
    zacc: Single;
    xgyro: Single;
    ygyro: Single;
    zgyro: Single;
    xmag: Single;
    ymag: Single;
    zmag: Single;
    abs_pressure: Single;
    diff_pressure: Single;
    pressure_alt: Single;
    temperature: Single;
    fields_updated: Word;
  end;

  mavlink_optical_flow_rad_t = record
    time_usec: Largeuint;
    integration_time_us: LongWord;
    integrated_x: Single;
    integrated_y: Single;
    integrated_xgyro: Single;
    integrated_ygyro: Single;
    integrated_zgyro: Single;
    time_delta_distance_us: LongWord;
    distance: Single;
    temperature: Smallint;
    sensor_id: Byte;
    quality: Byte;
  end;

  mavlink_hil_sensor_t = record
    time_usec: Largeuint;
    xacc: Single;
    yacc: Single;
    zacc: Single;
    xgyro: Single;
    ygyro: Single;
    zgyro: Single;
    xmag: Single;
    ymag: Single;
    zmag: Single;
    abs_pressure: Single;
    diff_pressure: Single;
    pressure_alt: Single;
    temperature: Single;
    fields_updated: LongWord;
  end;

  mavlink_sim_state_t = record
    q1: Single;
    q2: Single;
    q3: Single;
    q4: Single;
    roll: Single;
    pitch: Single;
    yaw: Single;
    xacc: Single;
    yacc: Single;
    zacc: Single;
    xgyro: Single;
    ygyro: Single;
    zgyro: Single;
    lat: Single;
    lon: Single;
    alt: Single;
    std_dev_horz: Single;
    std_dev_vert: Single;
    vn: Single;
    ve: Single;
    vd: Single;
  end;

  mavlink_radio_status_t = record
    rxerrors: Word;
    fixed: Word;
    rssi: Byte;
    remrssi: Byte;
    txbuf: Byte;
    noise: Byte;
    remnoise: Byte;
  end;

  mavlink_file_transfer_protocol_t = record
    target_network: Byte;
    target_system: Byte;
    target_component: Byte;
    payload: array[0..250] of Byte;
  end;

  mavlink_timesync_t = record
    tc1: Int64;
    ts1: Int64;
  end;

  mavlink_hil_gps_t = record
    time_usec: Largeuint;
    lat: Integer;
    lon: Integer;
    alt: Integer;
    eph: Word;
    epv: Word;
    vel: Word;
    vn: Smallint;
    ve: Smallint;
    vd: Smallint;
    cog: Word;
    fix_type: Byte;
    satellites_visible: Byte;
  end;

  mavlink_hil_optical_flow_t = record
    time_usec: Largeuint;
    integration_time_us: LongWord;
    integrated_x: Single;
    integrated_y: Single;
    integrated_xgyro: Single;
    integrated_ygyro: Single;
    integrated_zgyro: Single;
    time_delta_distance_us: LongWord;
    distance: Single;
    temperature: Smallint;
    sensor_id: Byte;
    quality: Byte;
  end;

  mavlink_hil_state_quaternion_t = record
    time_usec: Largeuint;
    attitude_quaternion: Single;
    rollspeed: Single;
    pitchspeed: Single;
    yawspeed: Single;
    lat: Integer;
    lon: Integer;
    alt: Integer;
    vx: Smallint;
    vy: Smallint;
    vz: Smallint;
    ind_airspeed: Word;
    true_airspeed: Word;
    xacc: Smallint;
    yacc: Smallint;
    zacc: Smallint;
  end;

  mavlink_scaled_imu2_t = record
    time_boot_ms: LongWord;
    xacc: Smallint;
    yacc: Smallint;
    zacc: Smallint;
    xgyro: Smallint;
    ygyro: Smallint;
    zgyro: Smallint;
    xmag: Smallint;
    ymag: Smallint;
    zmag: Smallint;
  end;

  mavlink_log_request_list_t = record
    start: Word;
    end_: Word;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_log_entry_t = record
    time_utc: LongWord;
    size: LongWord;
    id: Word;
    num_logs: Word;
    last_log_num: Word;
  end;

  mavlink_log_request_data_t = record
    ofs: LongWord;
    count: LongWord;
    id: Word;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_log_data_t = record
    ofs: LongWord;
    id: Word;
    count: Byte;
    data: array[0..89] of Byte;
  end;

  mavlink_log_erase_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_log_request_end_t = record
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_gps_inject_data_t = record
    target_system: Byte;
    target_component: Byte;
    len: Byte;
    data: array[0..109] of Byte;
  end;

  mavlink_gps2_raw_t = record
    time_usec: Largeuint;
    lat: Integer;
    lon: Integer;
    alt: Integer;
    dgps_age: LongWord;
    eph: Word;
    epv: Word;
    vel: Word;
    cog: Word;
    fix_type: Byte;
    satellites_visible: Byte;
    dgps_numch: Byte;
  end;

  mavlink_power_status_t = record
    Vcc: Word;
    Vservo: Word;
    flags: Word;
  end;

  mavlink_serial_control_t = record
    baudrate: LongWord;
    timeout: Word;
    device: Byte;
    flags: Byte;
    count: Byte;
    data: array[0..69] of Byte;
  end;

  mavlink_gps_rtk_t = record
    time_last_baseline_ms: LongWord;
    tow: LongWord;
    baseline_a_mm: Integer;
    baseline_b_mm: Integer;
    baseline_c_mm: Integer;
    accuracy: LongWord;
    iar_num_hypotheses: Integer;
    wn: Word;
    rtk_receiver_id: Byte;
    rtk_health: Byte;
    rtk_rate: Byte;
    nsats: Byte;
    baseline_coords_type: Byte;
  end;

  mavlink_gps2_rtk_t = record
    time_last_baseline_ms: LongWord;
    tow: LongWord;
    baseline_a_mm: Integer;
    baseline_b_mm: Integer;
    baseline_c_mm: Integer;
    accuracy: LongWord;
    iar_num_hypotheses: Integer;
    wn: Word;
    rtk_receiver_id: Byte;
    rtk_health: Byte;
    rtk_rate: Byte;
    nsats: Byte;
    baseline_coords_type: Byte;
  end;

  mavlink_scaled_imu3_t = record
    time_boot_ms: LongWord;
    xacc: Smallint;
    yacc: Smallint;
    zacc: Smallint;
    xgyro: Smallint;
    ygyro: Smallint;
    zgyro: Smallint;
    xmag: Smallint;
    ymag: Smallint;
    zmag: Smallint;
  end;

  mavlink_data_transmission_handshake_t = record
    size: LongWord;
    width: Word;
    height: Word;
    packets: Word;
    type_: Byte;
    payload: Byte;
    jpg_quality: Byte;
  end;

  mavlink_encapsulated_data_t = record
    seqnr: Word;
    data: array[0..252] of Byte;
  end;

  mavlink_distance_sensor_t = record
    time_boot_ms: LongWord;
    min_distance: Word;
    max_distance: Word;
    current_distance: Word;
    type_: Byte;
    id: Byte;
    orientation: Byte;
    covariance: Byte;
  end;

  mavlink_terrain_request_t = record
    mask: Largeuint;
    lat: Integer;
    lon: Integer;
    grid_spacing: Word;
  end;

  mavlink_terrain_data_t = record
    lat: Integer;
    lon: Integer;
    grid_spacing: Word;
    data: array[0..15] of Smallint;
    gridbit: Byte;
  end;

  mavlink_terrain_check_t = record
    lat: Integer;
    lon: Integer;
  end;

  mavlink_terrain_report_t = record
    lat: Integer;
    lon: Integer;
    terrain_height: Single;
    current_height: Single;
    spacing: Word;
    pending: Word;
    loaded: Word;
  end;

  mavlink_scaled_pressure2_t = record
    time_boot_ms: LongWord;
    press_abs: Single;
    press_diff: Single;
    temperature: Smallint;
  end;

  mavlink_att_pos_mocap_t = record
    time_usec: Largeuint;
    q: Single;
    x: Single;
    y: Single;
    z: Single;
  end;

  mavlink_set_actuator_control_target_t = record
    time_usec: Largeuint;
    controls: Single;
    group_mlx: Byte;
    target_system: Byte;
    target_component: Byte;
  end;

  mavlink_actuator_control_target_t = record
    time_usec: Largeuint;
    controls: Single;
    group_mlx: Byte;
  end;

  mavlink_scaled_pressure3_t = record
    time_boot_ms: LongWord;
    press_abs: Single;
    press_diff: Single;
    temperature: Smallint;
  end;

  mavlink_battery_status_t = record
    current_consumed: Integer;
    energy_consumed: Integer;
    temperature: Smallint;
    voltages: array[0..9] of Word;
    current_battery: Smallint;
    id: Byte;
    battery_function: Byte;
    type_: Byte;
    battery_remaining: Byte;
  end;

  mavlink_autopilot_version_t = record
    capabilities: Largeuint;
    uid: Largeuint;
    flight_sw_version: LongWord;
    middleware_sw_version: LongWord;
    os_sw_version: LongWord;
    board_version: LongWord;
    vendor_id: Word;
    product_id: Word;
    flight_custom_version: array[0..7] of Byte;
    middleware_custom_version: array[0..7] of Byte;
    os_custom_version: array[0..7] of Byte;
  end;

  mavlink_landing_target_t = record
    time_usec: Largeuint;
    angle_x: Single;
    angle_y: Single;
    distance: Single;
    size_x: Single;
    size_y: Single;
    target_num: Byte;
    frame: Byte;
  end;

  mavlink_vibration_t = record
    time_usec: Largeuint;
    vibration_x: Single;
    vibration_y: Single;
    vibration_z: Single;
    clipping_0: LongWord;
    clipping_1: LongWord;
    clipping_2: LongWord;
  end;

  mavlink_home_position_t = record
    latitude: Integer;
    longitude: Integer;
    altitude: Integer;
    x: Single;
    y: Single;
    z: Single;
    q: Single;
    approach_x: Single;
    approach_y: Single;
    approach_z: Single;
  end;

  mavlink_set_home_position_t = record
    latitude: Integer;
    longitude: Integer;
    altitude: Integer;
    x: Single;
    y: Single;
    z: Single;
    q: Single;
    approach_x: Single;
    approach_y: Single;
    approach_z: Single;
    target_system: Byte;
  end;

  mavlink_adsb_vehicle_t = record
    ICAO_address: LongWord;
    lat: Integer;
    lon: Integer;
    altitude: Integer;
    heading: Word;
    hor_velocity: Word;
    ver_velocity: Smallint;
    flags: Word;
    squawk: Word;
    altitude_type: Byte;
    callsign: array[0..8] of Byte;
    emitter_type: Byte;
    tslc: Byte;
  end;

  mavlink_v2_extension_t = record
    message_type: Word;
    target_network: Byte;
    target_system: Byte;
    target_component: Byte;
    payload: array[0..248] of Byte;
  end;

  mavlink_memory_vect_t = record
    address: Word;
    ver: Byte;
    type_: Byte;
    value: array[0..31] of Byte;
  end;

  mavlink_debug_vect_t = record
    time_usec: Largeuint;
    x: Single;
    y: Single;
    z: Single;
    name: array[0..9] of Byte;
  end;

  mavlink_named_value_float_t = record
    time_boot_ms: LongWord;
    value: Single;
    name: array[0..9] of Byte;
  end;

  mavlink_named_value_int_t = record
    time_boot_ms: LongWord;
    value: Integer;
    name: array[0..9] of Byte;
  end;

  mavlink_statustext_t = record
    severity: Byte;
    text: array[0..49] of Byte;
  end;

  mavlink_debug_t = record
    time_boot_ms: LongWord;
    value: Single;
    ind: Byte;
  end;

type
  THelpers = class
    msg_data_PARAM_VALUE:mavlink_param_value_t;
    msg_data_HEARTBEAT:mavlink_heartbeat_t;
    procedure packet_msg_data_set(packet: System.TArray<System.Byte>; msg_id:UInt8; data_length:UInt8);
    procedure packet_msg_data_get(msg_id:UInt16; data_set:pointer);
    function crc_accumulate(b:byte; crc: UInt16):UInt16;
    function crc_calculate(pBuffer: System.TArray<System.Byte>; length:integer):UInt16;
  private

  public

end;

implementation

procedure THelpers.packet_msg_data_set(packet:System.TArray<System.Byte>; msg_id:UInt8; data_length:UInt8);
var
  packet_data:System.TArray<System.Byte>;
begin

  case msg_id of

    MAVLINK_MSG_ID.MAVLINK_MSG_ID_PARAM_VALUE:
    begin
      SetLength(packet_data, data_length);
      packet_data:= Copy(packet,6,data_length);
      CopyRecord(@msg_data_PARAM_VALUE, packet_data, TypeInfo(mavlink_param_value_t));
    end;

    MAVLINK_MSG_ID.MAVLINK_MSG_ID_HEARTBEAT:
    begin
      SetLength(packet_data, data_length);
      packet_data:= Copy(packet,6,data_length);
      CopyRecord(@msg_data_HEARTBEAT, packet_data, TypeInfo(mavlink_heartbeat_t));
    end;
  end;

end;

procedure THelpers.packet_msg_data_get(msg_id:UInt16; data_set:pointer);
begin

  case msg_id of

    MAVLINK_MSG_ID.MAVLINK_MSG_ID_PARAM_VALUE:
    begin
      data_set:= @msg_data_PARAM_VALUE;
    end;

    MAVLINK_MSG_ID.MAVLINK_MSG_ID_HEARTBEAT:
    begin
      data_set:= @msg_data_HEARTBEAT;
    end;

  end;
end;

function THelpers.crc_accumulate(b:byte; crc: UInt16):UInt16;
var
  ch:byte;
begin
  ch := byte(b xor byte(crc and $00ff));
  ch := byte(ch xor (ch shl 4));
  result:= UInt16((crc shr 8) xor (ch shl 8) xor (ch shl 3) xor (ch shr 4));
end;

function THelpers.crc_calculate(pBuffer: System.TArray<System.Byte>; length:integer):UInt16;
var
  crcTmp: UInt16;
  i:integer;
begin
  if (length < 1) then
  begin
    Result:= $ffff;
  end;
  crcTmp := X25_INIT_CRC;

  for i := 1 to (length - 1) do // skips header
  begin
    crcTmp := crc_accumulate(pBuffer[i], crcTmp);
  end;

  result:= crcTmp;
end;

end.
