mavlink icon indicating copy to clipboard operation
mavlink copied to clipboard

scripts: xml consistency check: updates

Open IamPete1 opened this issue 9 months ago • 6 comments

Two updates to the consistency checking scripts.

Firstly this skips checking deprecated items. This comes out about scratch, we save a couple of warnings but get a couple more because of items referencing deprecated enums.

ardupilotmega.xml: Message MOUNT_CONFIGURE field mount_mode enum MAV_MOUNT_MODE does not exist
ardupilotmega.xml: Message MOUNT_STATUS field mount_mode enum MAV_MOUNT_MODE does not exist

Secondly this adds a check for the min/max/step for MAV_CMD items. In particular where a item has a step size of 1 and min and max that are close together, this adds lots of warnings.

ardupilotmega.xml: Command MAV_CMD_DO_SPRAYER param 1 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_SOLO_BTN_PAUSE_CLICK param 1 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_SET_EKF_SOURCE_SET param 1 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_DO_START_MAG_CAL param 2 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_DO_START_MAG_CAL param 3 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_DO_START_MAG_CAL param 5 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_SET_FACTORY_TEST_MODE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_LOITER_TURNS param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_LOITER_TIME param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_CONTINUE_AND_CHANGE_ALT param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_LOITER_TO_ALT param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_LOITER_TO_ALT param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_FOLLOW param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_PATHPLANNING param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_PATHPLANNING param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_GUIDED_ENABLE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_CONDITION_YAW param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_CONDITION_YAW param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_SET_HOME param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_FLIGHTTERMINATION param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_PAUSE_CONTINUE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_SET_REVERSE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_CONTROL_VIDEO param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_CONTROL_VIDEO param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_SET_CAM_TRIGG_DIST param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_FENCE_ENABLE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_INVERTED_FLIGHT param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_AUTOTUNE_ENABLE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_SET_YAW_SPEED param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_ENGINE_CONTROL param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_ENGINE_CONTROL param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_SET_MISSION_CURRENT param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 5 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 6 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 7 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_SET_SENSOR_OFFSETS param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_COMPONENT_ARM_DISARM param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_ILLUMINATOR_ON_OFF param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_SET_MESSAGE_INTERVAL param 7 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_REQUEST_MESSAGE param 7 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_STORAGE_FORMAT param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_STORAGE_FORMAT param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_RESET_CAMERA_SETTINGS param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_TRIGGER_CONTROL param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_TRIGGER_CONTROL param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_CONTROL_HIGH_LATENCY param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_CONDITION_GATE param 2 min, max close and increment of 1, should there be a enum?
development.xml: Command MAV_CMD_DO_UPGRADE param 2 min, max close and increment of 1, should there be a enum?

Lots of them are things like 0 to disable and 1 to enable, so they could share some generic enums.

IamPete1 avatar Feb 16 '25 20:02 IamPete1

Added check for display bitmask with no enum per: https://github.com/ArduPilot/mavlink/pull/383#issuecomment-2664212322

ardupilotmega.xml: Message MAG_CAL_PROGRESS field cal_mask is marked display="bitmask" with no enum
common.xml: Message HIL_ACTUATOR_CONTROLS field flags is marked display="bitmask" with no enum
common.xml: Message TERRAIN_REQUEST field mask is marked display="bitmask" with no enum
common.xml: Message MAG_CAL_REPORT field cal_mask is marked display="bitmask" with no enum
common.xml: Message HIGH_LATENCY2 field custom_mode is marked display="bitmask" with no enum
common.xml: Message BUTTON_CHANGE field state is marked display="bitmask" with no enum
common.xml: Message GIMBAL_DEVICE_INFORMATION field custom_cap_flags is marked display="bitmask" with no enum
common.xml: Message ESC_INFO field info is marked display="bitmask" with no enum
common.xml: Message ACTUATOR_OUTPUT_STATUS field active is marked display="bitmask" with no enum

IamPete1 avatar Feb 18 '25 00:02 IamPete1

Looks good.

Rule for enums is that we don't bother if there are less than four values. That said, a true/false enum might be useful, in particular because it ensures a precise value is used, rather than assuming something in a range. I am exploring the appetite for this in https://github.com/mavlink/mavlink/pull/2242

With respect to the other enums let's see what falls out - it might be that we adjust the rule to catch the "more than 3 options" case.

hamishwillee avatar Mar 20 '25 06:03 hamishwillee

Rule for enums is that we don't bother if there are less than four values. That said, a true/false enum might be useful, in particular because it ensures a precise value is used, rather than assuming something in a range. I am exploring the appetite for this in #2242

The motivation behind this effort is to allow programmatically generated user interfaces. A UI for sending a MAVLink command for example. If there is a no enum I have to show a number entry box, I can apply the min/max/increment to that number if provided. The user then has to work out what number they should enter based on the description. However, if there is a enum I can generate a radio button each with its own description and allow the user to select one, the user doesn't need to know what number is sent in the background. If the enum is marked as a bitmask I can generate checkboxes and allow the user to select multiple.

IamPete1 avatar Mar 26 '25 22:03 IamPete1

Hmmm. Very reasonable. I guess we'll do it then.

hamishwillee avatar Mar 27 '25 04:03 hamishwillee

Re-based, output is now:

ardupilotmega.xml: Enum: RALLY_FLAGS should be a marked as bitmask?
common.xml: Enum: MAV_ODID_OPERATOR_ID_TYPE has only 1 items?
common.xml: Enum: MAV_EVENT_ERROR_REASON has only 1 items?
common.xml: Enum: MAV_EVENT_CURRENT_SEQUENCE_FLAGS has only 1 items?
ardupilotmega.xml: Message MOUNT_CONFIGURE field mount_mode enum MAV_MOUNT_MODE does not exist
ardupilotmega.xml: Message MOUNT_STATUS field mount_mode enum MAV_MOUNT_MODE does not exist
common.xml: Message HIL_CONTROLS field mode enum MAV_MODE does not exist
common.xml: Message HIL_ACTUATOR_CONTROLS field mode display="bitmask" is deprecated
common.xml: Message HIL_ACTUATOR_CONTROLS field flags display="bitmask" is deprecated
storm32.xml: Message MLRS_RADIO_LINK_STATS field flags display="bitmask" is deprecated
ardupilotmega.xml: Command MAV_CMD_DO_SPRAYER param 1 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_SOLO_BTN_PAUSE_CLICK param 1 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_SET_EKF_SOURCE_SET param 1 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_DO_START_MAG_CAL param 2 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_DO_START_MAG_CAL param 3 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_DO_START_MAG_CAL param 5 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Command MAV_CMD_SET_FACTORY_TEST_MODE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_LOITER_TURNS param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_LOITER_TIME param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_CONTINUE_AND_CHANGE_ALT param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_LOITER_TO_ALT param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_LOITER_TO_ALT param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_FOLLOW param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_PATHPLANNING param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_PATHPLANNING param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_GUIDED_ENABLE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_CONDITION_YAW param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_CONDITION_YAW param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_SET_HOME param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_FLIGHTTERMINATION param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_PAUSE_CONTINUE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_SET_REVERSE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_CONTROL_VIDEO param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_CONTROL_VIDEO param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_SET_CAM_TRIGG_DIST param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_FENCE_ENABLE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_INVERTED_FLIGHT param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_AUTOTUNE_ENABLE param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_NAV_SET_YAW_SPEED param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_ENGINE_CONTROL param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_ENGINE_CONTROL param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_SET_MISSION_CURRENT param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 4 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 5 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 6 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_CALIBRATION param 7 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_SET_SENSOR_OFFSETS param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_COMPONENT_ARM_DISARM param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_ILLUMINATOR_ON_OFF param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_SET_MESSAGE_INTERVAL param 7 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_REQUEST_MESSAGE param 7 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_STORAGE_FORMAT param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_STORAGE_FORMAT param 3 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_RESET_CAMERA_SETTINGS param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_TRIGGER_CONTROL param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_DO_TRIGGER_CONTROL param 2 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_CONTROL_HIGH_LATENCY param 1 min, max close and increment of 1, should there be a enum?
common.xml: Command MAV_CMD_CONDITION_GATE param 2 min, max close and increment of 1, should there be a enum?
development.xml: Command MAV_CMD_DO_UPGRADE param 2 min, max close and increment of 1, should there be a enum?
ardupilotmega.xml: Enum: MAV_MODE_GIMBAL is unused
ardupilotmega.xml: Enum: GIMBAL_AXIS_CALIBRATION_REQUIRED is unused
ardupilotmega.xml: Enum: GOPRO_RESOLUTION is unused
ardupilotmega.xml: Enum: GOPRO_FRAME_RATE is unused
ardupilotmega.xml: Enum: GOPRO_FIELD_OF_VIEW is unused
ardupilotmega.xml: Enum: GOPRO_VIDEO_SETTINGS_FLAGS is unused
ardupilotmega.xml: Enum: GOPRO_PHOTO_RESOLUTION is unused
ardupilotmega.xml: Enum: GOPRO_PROTUNE_WHITE_BALANCE is unused
ardupilotmega.xml: Enum: GOPRO_PROTUNE_COLOUR is unused
ardupilotmega.xml: Enum: GOPRO_PROTUNE_GAIN is unused
ardupilotmega.xml: Enum: GOPRO_PROTUNE_SHARPNESS is unused
ardupilotmega.xml: Enum: GOPRO_PROTUNE_EXPOSURE is unused
ardupilotmega.xml: Enum: GOPRO_CHARGING is unused
ardupilotmega.xml: Enum: GOPRO_MODEL is unused
ardupilotmega.xml: Enum: GOPRO_BURST_RATE is unused
ardupilotmega.xml: Enum: LED_CONTROL_PATTERN is unused
ardupilotmega.xml: Enum: PLANE_MODE is unused
ardupilotmega.xml: Enum: COPTER_MODE is unused
ardupilotmega.xml: Enum: SUB_MODE is unused
ardupilotmega.xml: Enum: ROVER_MODE is unused
ardupilotmega.xml: Enum: TRACKER_MODE is unused
AVSSUAS.xml: Enum: MAV_AVSS_COMMAND_FAILURE_REASON is unused
AVSSUAS.xml: Enum: AVSS_M300_OPERATION_MODE is unused
AVSSUAS.xml: Enum: AVSS_HORSEFLY_OPERATION_MODE is unused
common.xml: Enum: FIRMWARE_VERSION_TYPE is unused
common.xml: Enum: COMP_METADATA_TYPE is unused
common.xml: Enum: MAV_ARM_AUTH_DENIED_REASON is unused
common.xml: Enum: MAV_FTP_ERR is unused
common.xml: Enum: MAV_FTP_OPCODE is unused
matrixpilot.xml: Enum: MAV_PREFLIGHT_STORAGE_ACTION is unused
minimal.xml: Enum: MAV_MODE_FLAG_DECODE_POSITION is unused
storm32.xml: Enum: MAV_STORM32_TUNNEL_PAYLOAD_TYPE is unused
ualberta.xml: Enum: UALBERTA_AUTOPILOT_MODE is unused
ualberta.xml: Enum: UALBERTA_NAV_MODE is unused
ualberta.xml: Enum: UALBERTA_PILOT_MODE is unused

Lots of unused enums and lots of commands that should use the new boolean enum.

IamPete1 avatar Jun 15 '25 15:06 IamPete1

Lots of commands that should use the new boolean enum.

Yeah, this has triggered me to try and unblock https://github.com/mavlink/mavlink/pull/2242

Lots of unused enums and

These are often used, just not necessarily directly assigned in an enum. We need to look at them at a case by case basis, and perhaps add exclusions in the report (?)

For example:

common.xml: Enum: MAV_ARM_AUTH_DENIED_REASON - this is an additional failure reason for https://mavlink.io/en/messages/common.html#MAV_CMD_ARM_AUTHORIZATION_REQUEST

common.xml: Enum: COMP_METADATA_TYPE - is used in the XML file returned by Used in https://mavlink.io/en/messages/common.html#COMP_METADATA - the definition is needed in the file.

common.xml: Enum: MAV_FTP_ERR is unused As per https://mavlink.io/en/messages/common.html#MAV_FTP_ERR these are error codes used in FTP. The protocol is opaque so these codes aren't assigned directly to a field, but the number is useful if you're coding an FTP solution.

I'm sure some of the others are similar.

hamishwillee avatar Jun 18 '25 01:06 hamishwillee