DiveSystem: fix APOS5 record type detection for firmware 5.2.11+. - #132
Merged
mikeller merged 2 commits intoSep 10, 2026
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
🟡 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_INFOrecords 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.