Skip to content

Fix decoder bugs and add unit tests#42

Open
junzis wants to merge 2 commits intoopenskynetwork:masterfrom
junzis:fix/adsb-decoder-bugs
Open

Fix decoder bugs and add unit tests#42
junzis wants to merge 2 commits intoopenskynetwork:masterfrom
junzis:fix/adsb-decoder-bugs

Conversation

@junzis
Copy link

@junzis junzis commented Feb 15, 2026

Bug fixes (cross-validated against pyModeS, lib1090, dump1090):

  • Fix heading integer division in AirspeedHeadingMsg (360/1024 -> 360.0/1024.0)
  • Fix vertical rate availability check in VelocityOverGroundMsg and AirspeedHeadingMsg (check raw==0 before shift, old check was never true after <<6)
  • Fix geo-minus-baro availability check in AirspeedHeadingMsg (check raw==0 before multiply, old check produced -25 instead of unavailable)
  • Fix byte sign extension in AirborneOperationalStatusV1Msg capability/operational codes (mask with &0xFF before shift to prevent sign extension when byte >= 0x80)
  • Fix byte sign extension in EmergencyOrPriorityStatusMsg squawk decoding (msg[2]&0xFF, was producing squawk 7573 instead of correct 6513)
  • Fix NL function boundary in CPR decode for airborne and surface positions (clamp acos argument to [-1,1] to prevent NaN at high latitudes)
  • Fix PositionDecoder nulling last_pos on failed decode, breaking subsequent local decodes
  • Fix AirborneOperationalStatusV1Msg control flow: check subtype before parsing capability codes to avoid airborne parsing on surface messages

Tests added: 113 tests across 11 test classes covering all message types.

Bug fixes (cross-validated against pyModeS, lib1090, dump1090):

- Fix heading integer division in AirspeedHeadingMsg (360/1024 -> 360.0/1024.0)
- Fix vertical rate availability check in VelocityOverGroundMsg and AirspeedHeadingMsg
  (check raw==0 before shift, old check was never true after <<6)
- Fix geo-minus-baro availability check in AirspeedHeadingMsg
  (check raw==0 before multiply, old check produced -25 instead of unavailable)
- Fix byte sign extension in AirborneOperationalStatusV1Msg capability/operational codes
  (mask with &0xFF before shift to prevent sign extension when byte >= 0x80)
- Fix byte sign extension in EmergencyOrPriorityStatusMsg squawk decoding
  (msg[2]&0xFF, was producing squawk 7573 instead of correct 6513)
- Fix NL function boundary in CPR decode for airborne and surface positions
  (clamp acos argument to [-1,1] to prevent NaN at high latitudes)
- Fix PositionDecoder nulling last_pos on failed decode, breaking subsequent
  local decodes
- Fix AirborneOperationalStatusV1Msg control flow: check subtype before parsing
  capability codes to avoid airborne parsing on surface messages

Tests added: 113 tests across 11 test classes covering all message types.
- TCASResolutionAdvisoryMsg: fix msg[4] used instead of msg[3] for
  threat_identity high bits, add &0xFF masks on all shifted bytes
- SurfaceOperationalStatusV1Msg: add &0xFF masks to prevent sign
  extension, reorder subtype check before field parsing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant