Skip to content

suunto_eonsteel: Report the tank count and keep imperial tanks - #154

Open
metman-oss wants to merge 1 commit into
subsurface:Subsurface-DS9from
metman-oss:fix/eonsteel-tank-count
Open

metman-oss wants to merge 1 commit into
subsurface:Subsurface-DS9from
metman-oss:fix/eonsteel-tank-count

Conversation

@metman-oss

@metman-oss metman-oss commented Nov 29, 2026 •

Copy link
Copy Markdown

Fixes the missing tank size and fill pressure when importing dives from a Suunto EON Steel/Core, as reported in subsurface/subsurface#5170.

What changes

  • add_gas_type() marks DC_FIELD_TANK_COUNT as available but never set cache.TANK_COUNT, so dc_field_get() reported zero tanks. Subsurface then never asks for DC_FIELD_TANK and uses its default cylinder instead of the size and fill pressure the dive computer stores for every gas. TANK_COUNT is now set together with GASMIX_COUNT, as every gas has a tank entry. Upstream libdivecomputer also reports the number of gases as the tank count.
  • For DC_FIELD_TANK, suunto_eonsteel_parser_get_field() applied the imperial detection (fractional size with a fill pressure) and then called dc_field_get(), which overwrote volume, workpressure and type from the cache again. It now calls dc_field_get() first and applies the imperial detection afterwards.

Testing

  • New synthetic test test/test_suunto_eonsteel_tanks.c (no device data). It builds a minimal SBEM dive file with two gases and checks:

    • the gas mix and tank counts (2 and 2)
    • a metric tank: 15 l, 200 bar
    • an imperial tank: AL80, 11.1 l at 206.8 bar

    Without this change it fails on the tank count and on the imperial type. I built and ran it with MSVC (contrib/msvc/libdivecomputer.vcxproj, x64 Release). The autotools make distcheck run is left to CI.

  • Real logs: 50 EON Core dives, taken from a libdivecomputer log of a full download. Before, DC_FIELD_TANK_COUNT was 0 for every dive. Now each dive reports one tank whose size and fill pressure match the raw Gas.TankSize and Gas.TankFillPressure values (27 × 12 l, 23 × 15 l, all 200 bar). All tanks are metric, so the imperial path is covered by the synthetic test only.

The average ventilation value mentioned in the issue is not part of this change.

Once merged, Subsurface needs only a submodule update.

The change and test were written with Claude.

🤖 Generated with Claude Code

Fixes tank data in the Suunto EON Steel/Core parser.

  • Sets DC_FIELD_TANK_COUNT when adding a gas, alongside GASMIX_COUNT.
  • Calls dc_field_get() before tank-specific handling, so cached values no longer overwrite detected imperial tank type and measurements.
  • Adds synthetic test test_suunto_eonsteel_tanks for two gases and two tanks, one metric and one imperial.

add_gas_type() marks DC_FIELD_TANK_COUNT as available, but never sets
cache.TANK_COUNT. dc_field_get() therefore reports zero tanks, so
applications never ask for DC_FIELD_TANK. Subsurface then falls back to
its default cylinder and loses the tank size and fill pressure that the
EON Steel/Core stores for every gas. Set TANK_COUNT together with
GASMIX_COUNT, as every gas has a tank entry. Upstream libdivecomputer
also reports the number of gases as the tank count.

For DC_FIELD_TANK, suunto_eonsteel_parser_get_field() filled in the tank
and switched a fractional size with a fill pressure to imperial, but then
called dc_field_get(), which overwrote volume, workpressure and type from
the cache again. Call dc_field_get() first and apply the imperial
detection afterwards.

Add a synthetic test with a metric tank (15 l, 200 bar) and an imperial
one (AL80, 11.1 l at 206.8 bar). Without this change it fails on the tank
count and on the imperial type.

See subsurface/subsurface#5170

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: metasch-oss <rene.metasch@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Suunto EON Steel parser now counts each accepted gas as a tank and obtains tank fields through dc_field_get() before applying the existing metric-to-imperial adjustment. A new EON Core test checks gas-mix counts, tank counts, gas-mix indices, and tank properties.

Changes

Suunto EON Steel tank parsing

Layer / File(s) Summary
Tank parsing and validation
src/suunto_eonsteel_parser.c, test/test_suunto_eonsteel_tanks.c, test/Makefile.am
Accepted gases now increment TANK_COUNT. Tank fields are populated through dc_field_get() before the existing metric-to-imperial adjustment. The new test checks gas-mix and tank counts, gas-mix indices, and tank properties.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: mikeller, dirkhh

Merge Risk: Minimal · up to cd6cb

This change makes EON Steel/Core dives report tank counts and keeps imperial tank types and sizes. No concrete merge-blocking risk was established. CI should confirm the build and the new test.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "suunto_eonsteel: Report the tank count and keep imperial tanks" matches the main changes. The diff makes the parser report DC_FIELD_TANK_COUNT alongside GASMIX_COUNT, and it calls dc_field_…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "suunto_eonsteel: Report the tank count and keep imperial tanks" matches the main changes. The diff makes the parser report DC_FIELD_TANK_COUNT alongside GASMIX_COUNT, and it calls dc_field_get() before tank-specific adjustments so imperial tank detection is kept. The added synthetic test checks tank counts and imperial/metric tank values. The title is specific and concise and names both the primary change and the secondary fix.

Finishing Touches

Simplify code

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b338e6a1-afc7-40e0-af7b-b9e4effa85d8
Commits

Reviewing files that changed from the base of the PR and between dbf9fc7 and cd6cba2.

Files selected for processing: 3

  • src/suunto_eonsteel_parser.c
  • test/Makefile.am
  • test/test_suunto_eonsteel_tanks.c

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Recent review details

Additional comments: 1

src/suunto_eonsteel_parser.c: 1

1120-1120: Data Integrity & Integration

Report a tank count only when the tank can be retrieved.

add_gas_type now reports one tank for each accepted gas. DC_FIELD_TANK is initialized only by add_gas_size, which runs for a TankSize record. If a dive has a gas record without TankSize, the parser reports a tank count, but suunto_eonsteel_parser_get_field rejects the tank lookup with DC_STATUS_UNSUPPORTED. Before this change, such a gas reported no tank.

Confirm whether the EON Steel/Core format always includes Gas.TankSize for each gas. If it can omit that record, either publish the tank count only when DC_FIELD_TANK is initialized, or initialize tank lookup for that case from the available fields.

@mikeller mikeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AI-drafted; reviewed by Michael.

The tank-count change addresses the reported zero-tank result, and moving the imperial adjustment after dc_field_get() prevents the cache from overwriting it. I found no substantiated blocker in this change. I have not independently run the new test; the visible checks do not include an autotools test run.

@metman-oss

Copy link
Copy Markdown
Author

Thanks for the review. Regarding the test run: I enabled the workflows in my fork and pushed the commit of this PR as ci/pr154. All 10 build jobs pass, and make distcheck runs test_suunto_eonsteel_tanks successfully in all 7 jobs that run the tests, including the sanitizer job: https://github.com/metman-oss/libdc/actions/runs/46236838444

🤖 Generated with Claude Code

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