Skip to content

shearwater_predator_parser: gate GTR-mode sidemount detection by log version - #144

Merged
mikeller merged 1 commit into
subsurface:Subsurface-DS9from
mikeller:feat/shearwater-gtrmode-logversion-gate-205
Oct 15, 2026
Merged

mikeller merged 1 commit into
subsurface:Subsurface-DS9from
mikeller:feat/shearwater-gtrmode-logversion-gate-205

Conversation

@mikeller

Copy link
Copy Markdown
Member

In LOG_RECORD_OPENING_4, the GTR (Gas Time Remaining) mode byte at
offset 29 was read unconditionally, while the adjacent AI (Air
Integration) mode byte at offset 28 is read only for logversion >= 7.
For logversion < 7 (pre-Perdix AI logs), offset 29 is not part of any
documented field and could contain arbitrary data, risking a spurious
DC_TANK_USAGE_SIDEMOUNT classification from popcount(gtrmode) >= 2.

Evidence for the gate:

  • Shearwater's "SRIAppLayer - Log File Formats" document (log upload
    protocol spec) describes GTR Mode's "prior to Log Version 13" value
    set (0 = disabled, 1 = T1, 2 = T2) as structurally identical to AI
    Mode's pre-13 value set, and GTR is explicitly computed from the T1/T2
    wireless air-integration transmitters, so it cannot be meaningful
    before AI support exists.
  • libdc's own code consistently gates every AI-dependent field
    (aimode at offset 28, dive-sample tank pressure, battery type
    reporting) with logversion >= 7, with the tank-pressure gate
    commented "introduced for Perdix AI".

No source states in so many words "GTR Mode introduced in log version
7"; the conclusion is inferred from the matching pre-13 value scheme
and GTR's dependency on AI transmitter data, which is the same
reasoning basis used for the existing aimode gate. Given that, this
change reuses the same logversion >= 7 condition that already guards
the aimode read, rather than inventing a separate threshold.

Behaviour is unchanged for logversion >= 7 (including all versions
that can actually produce a sidemount configuration, which needs the
multi-bit combinations introduced in version 13). Logs with
logversion < 7 (and the logversion == 0 default used before the
opening record is seen) no longer read offset 29 or assign
DC_TANK_USAGE_SIDEMOUNT from it.

No change to the popcount(gtrmode) >= 2 rule, tank indexing, or any
other backend.

…version

In LOG_RECORD_OPENING_4, the GTR (Gas Time Remaining) mode byte at
offset 29 was read unconditionally, while the adjacent AI (Air
Integration) mode byte at offset 28 is read only for logversion >= 7.
For logversion < 7 (pre-Perdix AI logs), offset 29 is not part of any
documented field and could contain arbitrary data, risking a spurious
DC_TANK_USAGE_SIDEMOUNT classification from popcount(gtrmode) >= 2.

Evidence for the gate:
- Shearwater's "SRIAppLayer - Log File Formats" document (log upload
  protocol spec) describes GTR Mode's "prior to Log Version 13" value
  set (0 = disabled, 1 = T1, 2 = T2) as structurally identical to AI
  Mode's pre-13 value set, and GTR is explicitly computed from the T1/T2
  wireless air-integration transmitters, so it cannot be meaningful
  before AI support exists.
- libdc's own code consistently gates every AI-dependent field
  (aimode at offset 28, dive-sample tank pressure, battery type
  reporting) with `logversion >= 7`, with the tank-pressure gate
  commented "introduced for Perdix AI".

No source states in so many words "GTR Mode introduced in log version
7"; the conclusion is inferred from the matching pre-13 value scheme
and GTR's dependency on AI transmitter data, which is the same
reasoning basis used for the existing aimode gate. Given that, this
change reuses the same `logversion >= 7` condition that already guards
the aimode read, rather than inventing a separate threshold.

Behaviour is unchanged for logversion >= 7 (including all versions
that can actually produce a sidemount configuration, which needs the
multi-bit combinations introduced in version 13). Logs with
logversion < 7 (and the logversion == 0 default used before the
opening record is seen) no longer read offset 29 or assign
DC_TANK_USAGE_SIDEMOUNT from it.

No change to the popcount(gtrmode) >= 2 rule, tank indexing, or any
other backend.

Signed-off-by: Michael Keller <github@ike.ch>
Copilot AI lite review requested due to automatic review settings October 13, 2026 04:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved blocking issues were identified.

0 open findings

🧠 Review effort: Lite

@mikeller
mikeller marked this pull request as ready for review October 13, 2026 11:28
@mikeller
mikeller merged commit 03e418c into subsurface:Subsurface-DS9 Oct 15, 2026
11 checks passed
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.

2 participants