Skip to content

DiveSystem: fix APOS5 record type detection for firmware 5.2.11+. - #132

Merged
mikeller merged 2 commits into
subsurface:Subsurface-DS9from
mikeller:feat/ratio-apos5-firmware-5211-#66
Sep 10, 2026
Merged

DiveSystem: fix APOS5 record type detection for firmware 5.2.11+.#132
mikeller merged 2 commits into
subsurface:Subsurface-DS9from
mikeller:feat/ratio-apos5-firmware-5211-#66

Conversation

@mikeller

@mikeller mikeller commented Sep 9, 2026

Copy link
Copy Markdown
Member

Cherry-picks two commits from jefdriesen's upstream libdivecomputer that fix dive import from Ratio iX3M devices running APOS5 firmware 5.2.11 or later, where all dives were imported with 0 m depth and 0 minutes duration.
Root cause: since firmware 5.2.11 the record type field is no longer a simple type byte. The higher bits are reused to carry tank-related information, so sample records no longer have type 0. The previous code checked type == REC_SAMPLE (0) and skipped everything else, producing empty profiles.
Fix: instead of checking for a known sample type, only treat type == REC_INFO (1) as a non-sample record. Everything else is parsed as a normal sample, regardless of what the higher bits contain. The second commit then actually interprets those higher bits to recover the extra pressure MSB for 300-bar tanks and the RF channel.
This supersedes the earlier workaround on this branch that aliased 0x8006 to REC_SAMPLE.
Fixes subsurface/subsurface#4961. Related: libdivecomputer/libdivecomputer#66, libdivecomputer/libdivecomputer#68.

Since APOS5 firmware 5.2.11, the record type field is no longer a simple
record type. The higher bits are re-used to store additional info. For
backwards compatibility, these new features are only present on the
sample records and at least one of the higher bits will be set to
indicate their presence. Hence the info record with the GPS coordinates
can still be detected with the legacy value 1.
Since APOS5 firmware 5.2.11, the higher bits store new tank related
information:

 - An extra 9th bit for the tank pressure data to support high pressure
   (300 bar) tanks without reduced resolution. The new firmware no
   longer sets the legacy 300 bar bit.

 - The transmitter RF channel. Currently unused because the transmitter
   index is still present to identify the active tank and is also
   available with older firmware versions.
Copilot AI lite review requested due to automatic review settings September 9, 2026 16:04

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.

🟡 Changes recommended

The new RF channel parsing is currently dead code (parsed into an unused variable), which should either be removed or properly plumbed through to avoid misleading/unfinished implementation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the DiveSystem iDive / Ratio iX3M parsing logic to correctly handle APOS5 firmware 5.2.11+ where the “record type” field is no longer a simple type value, preventing empty dive profiles (0 m depth / 0 min duration) during import.

Changes:

  • Treat only REC_INFO records as non-sample records; parse all other record types as samples to avoid skipping APOS5 sample records with additional bit flags.
  • Interpret APOS5 tank-related bits in the record type field to recover the pressure MSB (for extended pressure ranges).
File summaries
File Description
src/divesystem_idive_parser.c Updates APOS5 record-type handling to avoid skipping samples and adds parsing of tank-related bits for pressure MSB recovery.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 585 to +593
unsigned int pressure = data[offset + 49];
unsigned int DC_ATTR_UNUSED rfchannel = 0;

if (type & TANK_VALID) {
rfchannel = type & TANK_RFCHANNEL;
if (type & TANK_PRESSURE_MSB) {
pressure |= 0x100;
}
}
@mikeller
mikeller merged commit fa3abb6 into subsurface:Subsurface-DS9 Sep 10, 2026
9 of 10 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.

[Bug]: Ratio IX3M2 Tech+ Download Problem

3 participants