Conversation
SBUS servo output is resolved with findSerialPortConfig(), which returns the first port that carries FUNCTION_SERVO_SERIAL. Assigning the function to a second port was accepted and reported back by the serial command, but that port was never opened. Reject such an assignment in the CLI instead of ignoring it silently. Fixes iNavFlight#11430
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoReject duplicate SBUS output assignments in the CLI
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can switch off images and animations for a plain-text comment |
The constraints list already covers the analogous telemetry rule. Adds the SERVO_SERIAL case, including that the second assignment used to be accepted silently without the port ever being opened.
Problem
Issue #11430: the reporter set
serial 0 4194304 0 0 0 0andserial 1 4194304 0 0 0 0to get SBUS servo output on two UARTs.serialprinted both lines back as valid, but only UART1 (serial 0) ever output SBUS. Nothing told the user that the second assignment does nothing.Cause
sbusServoInitialize()resolves the port withfindSerialPortConfig(FUNCTION_SERVO_SERIAL)(src/main/io/servo_sbus.c:59), which returns the first port in ascending order that carries the function (src/main/io/serial.c:214-224).cliSerial()copies the edited port configuration without checking the other ports (src/main/fc/cli.c:932), so a second SERVO_SERIAL assignment is stored and printed but never opened.Change
Adds
serialDuplicatedSinglePortFunctions()in serial.c, which returns the bits ofSERIAL_SINGLE_PORT_FUNCTIONS(currently onlyFUNCTION_SERVO_SERIAL) that the proposed port shares with any other port.cliSerial()calls it before applying the line and refuses with### ERROR: Function 4194304 is already assigned to another portwhen the result is non-zero. Only the port being edited is compared, so removing the function from a port still works.isSerialConfigValid()and the MSP handler are unchanged, so a saved configuration with two ports is not rewritten at boot.Test
Not run on hardware or SITL. Cause verified by reading src/main/io/servo_sbus.c:59 and src/main/io/serial.c:214-224. Upstream CI is waiting for maintainer approval: https://github.com/iNavFlight/inav/actions/runs/34513470612. No fork build exists for this branch.
Flash / RAM
Not measured yet. The upstream firmware CI has not been released for this PR, so no size report exists.
Docs
docs/Serial.md: the Constraints list now carries theSERVO_SERIALrule, next to the analogous telemetry one, including that a second assignment used to be accepted without the port ever being opened.