Repository navigation
blackbox: fit a ninth optional P frame field - #12126
sensei-hacker merged 1 commit into
Conversation
A P frame logs up to 9 optional fields (vbat, amperage, mag x3, baro, pitot, surface, rssi), but writeInterframe() collected them in an 8-entry array and blackboxWriteTag8_8SVB() packed them under one 8-bit header. With all 9 present the ninth delta went past the end of the array on the stack, and its header bit was shifted out, so decoders, which read runs of these fields as groups of 8 and a lone ninth as a plain signed VB, lost sync on every P frame where rssi did not change. The array now holds 9, and the writer splits the fields into groups of 8 as decoders read them. Logs with 8 or fewer of these fields are unchanged. A unit test checks the bytes written for 0 to 17 fields.
|
ⓘ 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 QodoFix Blackbox P-frame encoding with nine optional fields
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
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 route each severity your way: inline, summary, both, or drop |
|
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 #12126 251 targets built. Find your board's
|
|
Decoder side, for logs already recorded with nine fields: iNavFlight/blackbox-tools#102. |
|
Thanks! |
INAV logs up to nine optional P fields (vbat, amperage, mag x3, baro, pitot, surface, rssi). Until iNavFlight/inav#12126 they went out as one TAG8_8SVB group whose header byte covers only eight, the ninth written only when non-zero; read as 8 + 1 every frame with a zero ninth value shifts, and a T-28 log with all nine kept 1 P frame of 194,549. For INAV logs with a run of exactly nine such fields, each P frame is measured with the ninth value present and absent, and the reading that ends on the next frame's marker is kept; ties are broken by how many following frames end on markers, then by the reading the log has needed so far, otherwise the frame is dropped. Same rules as blackbox-tools' decoder (iNavFlight/blackbox-tools#102). Two T-28 logs now give 196,557 and 198,334 frames, every field equal to blackbox_decode; other logs take the same path as before.
A P frame logs up to 9 optional fields: vbat, amperage, mag x3, baro, pitot, surface and rssi.
writeInterframe()collected them inint32_t deltas[8], andblackboxWriteTag8_8SVB()packs them under one 8-bit header. With all 9 present:deltas, on the stack, in every P frame;All 9 are there with VBAT, a current meter, a mag (logged by default,
blackbox MAG), a baro, a pitot (virtual included), a rangefinder (MSP included) and an RSSI source. My T-28 has all of them, and its logs decode about 3 % of iterations: 172,619 frames failed in a 3 minute log. It goes back to when the pitot delta was added, so maintenance-9.x has it too.The array now holds 9, and the writer splits a run longer than 8 into groups of 8, the way decoders read it, so a lone ninth field is a plain signed VB again. Logs with 8 or fewer of these fields are byte for byte the same, and existing decoders read the new ones without changes.
Until this is in,
blackbox -MAGandsave(or dropping any other of the nine) avoids it.Testing
TBS Lucid H7 Wing on my T-28, with all nine present (VBAT, current, an IST8310 logged with
blackbox MAG, a DPS310, the virtual pitot, an MSP rangefinder and RSSI), decoded with the current blackbox_decode, unchanged:The header is the same in both, nine fields with this encoding. With 8 or fewer the writer goes through the same code as before, as a single group.
A new unit test checks the bytes written for 0, 1, 3, 8, 9 and 17 fields; the 9 and 17 cases fail on maintenance-10.x.
Flash: MATEKF722SE +0 B, MATEKF405SE +80 B, KAKUTEF7/KAKUTEF7HDV +64 B, MATEKH743 +96 B; ITCM unchanged on KAKUTEF7 and KAKUTEF7HDV.
Logs already recorded with all 9 fields carry no marker for whether the ninth value is there, so a decoder could only recover them by trying each P frame both ways and keeping the reading that ends on the next frame marker. I can look at that in blackbox-tools if it's useful.