mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
serial_protocol_compiled_in() in AP_SerialManager_default_protocol_check.cpp gates each serial port default protocol against the feature that provides it, but falls through to "true" for any protocol it does not name -- so a protocol added to the enum without a term there is silently treated as always-compiled-in, defeating the check for that protocol. Nothing in the C++ can notice that omission. Add check_serial_protocol_gates.py, which parses the SerialProtocol enumerators from AP_SerialManager.h and the protocols named by serial_protocol_compiled_in(), and requires every enumerator to be either gated there or listed in an explicit UNGATED register (with the reason). A new protocol in neither, or a stale name in the C++/register, is an error. The register also makes visible the protocols that have a feature but are not yet gated (GPS, Rangefinder, AirSpeed, AHRS, ...); gating those is a behaviour-neutral follow-up. Run it from pre-commit when the header, the check, or the script changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>