Repository navigation
Conversation
The simulator sends one MSP_SIMULATOR frame per simulator frame. One command per 100 Hz serial run caps a port at 100 commands a second, and above that the frames queue up and INAV flies on ever older data. With the simulator active each run now takes up to four, so a run stays bounded.
|
ⓘ 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 QodoDrain up to four MSP commands per serial run during HITL
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #12177 251 targets built. Find your board's
|
Code Review by Qodo
1.
|
…once A UART still sending the previous reply would drop the next one, and a USB host that stopped reading makes every reply wait out its timeout: in both cases the run now ends after one command, as before.
What happens
In HITL the simulator plugin sends one
MSP_SIMULATORframe per simulator frame. The serial task runs at 100 Hz andmspSerialProcessOnePort()answers one command per run, so a port takes at most 100 commands a second, shared withanything else that talks to it (a ground station behind a serial mux, debug polling). Above that the frames queue up
in the port's buffer and each one reaches INAV later than the one before: the attitude, sensors and GPS INAV flies on
grow older until the buffer is full.
Measured on a TBS Lucid H7 Wing over USB with X-Plane 11 and a 1.2 m fixed-wing model, with 20 other MSP requests a
second on the same port:
behind the simulator's, and the aircraft crashed after take-off.
apart, and at take-off INAV's attitude stayed at its ground value for about 5 s while the aircraft rotated. The
aircraft was lost on the runway and the plugin dropped the link.
matching the simulator's at every sample of a 10 Hz log; five flights completed.
The fix
While
SIMULATOR_MODE_HITLis set,mspSerialProcessOnePort()goes on to the next received command instead ofstopping after the first, up to four per run: 400 commands a second, a frame per simulator frame up to about 300 fps
with room for the other requests. It goes on only while the last reply went out at once: the transmit buffer is free
and the run has lasted less than 1 ms. A command with a post-process function (a reboot, for example) still ends the
run as before. Outside HITL nothing changes.
What else this touches:
the simulator's stop frame or a reboot, so after an unclean simulator exit it stays on until the next boot.
lack of room.
command, the same worst case as one command per run.
command: the plugin flags GPS data at 10 Hz, and four consecutive frames can only hold two of them below about 30
simulator frames a second, where one command per run already keeps up.
Testing
version (cap, transmit check and 1 ms budget): 115 to 120 frames a second, GPS gaps up to 114 ms, INAV's attitude
0 ms behind the simulator's, circuit flown and landed.
mavlink_unittest(one command per run outside HITL; in HITL four per run and therest on the next run; one per run while the transmit buffer is busy; one per run after a slow reply). All pass
(624/624).
KAKUTEF7HDV +64 B, TBS_LUCID_H7_WING +64 B; RAM and ITCM unchanged on all of them.
Not tested: other boards and USB stacks, a UART instead of USB, simulators other than X-Plane.