Skip to content

suunto_eonsteel: Don't report a zero ceiling as a deco stop with a valid NDL - #155

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

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

Conversation

@metman-oss

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

Copy link
Copy Markdown

Stops the EON Steel/Core parser from reporting a zero ceiling as a deco stop when the same sample has a valid NDL. Subsurface currently shows an NDL of zero for every event between two samples of these dives.

What changes

  • sample_ceiling() used to report every Ceiling field as a DC_DECO_DECOSTOP sample, including a zero ceiling outside of deco (time 0, depth 0). In the EON sample groups the ceiling follows NoDecTime, so this deco stop arrived right after the NDL sample. Subsurface's sample_cb() treats a deco stop as the end of the no-deco limit and keeps an NDL of zero, which it then uses for the samples it creates for events between two regular samples.
  • sample_ceiling() now only stores the ceiling, and the new sample_deco_stop() reports it once the whole sample group has been parsed (from traverse_samples()). It skips a zero ceiling when the group has a valid NDL. A positive ceiling is reported as before (with the assumed one-minute stop), and so is a zero ceiling without a valid NDL, which clears the deco state at the end of deco.
  • This restores the NDL precedence of the original dynamic sample parsing (upstream libdivecomputer edbdea0) for a zero ceiling only. The zero deco stop without a valid NDL, the separate TTS callback and the duration of a positive-ceiling stop stay as they are.

Testing

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

    • no deco (NDL 100 min, zero ceiling): an NDL sample and no deco stop
    • deco (no NDL, 3 m ceiling): a 3 m deco stop
    • end of deco (no NDL, zero ceiling): a zero deco stop
    • a group with the ceiling before the NDL: an NDL sample and no deco stop

    Without this change it fails on the two "no deco stop" checks. 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 from a libdivecomputer log of a full download. Apart from the 14164 zero deco stops that are no longer reported, the sample output is identical before and after the change. Replaying Subsurface's handling of the NDL gives 1359 samples with an NDL of zero before the change, exactly the number in my imported log, and none after it. None of these dives had any deco, so the deco cases are covered by the synthetic test only.

This change and #154 both add a test to the same lines of test/Makefile.am. Whichever is merged second needs a small rebase, which I'm happy to do.

Once merged, Subsurface needs only a submodule update.

The change and test were written with Claude.

🤖 Generated with Claude Code

…lid NDL

sample_ceiling() reported every Ceiling field as a DC_DECO_DECOSTOP
sample, including a zero ceiling outside of deco. As the ceiling follows
the NoDecTime field in the sample groups of the EON Steel/Core, the deco
stop arrived right after the NDL sample. Subsurface takes a deco stop as
the end of the no-deco limit and keeps an NDL of zero for every sample
it creates for an event between two samples. In 50 EON Core dives
without any deco, 1359 such samples got an NDL of zero.

Collect the NDL and the ceiling of each sample group and report the deco
stop once the group has been parsed. Skip it when the ceiling is zero
and the group has a valid NDL, which already says that there is no deco
obligation. A positive ceiling, and a zero ceiling without a valid NDL
at the end of deco, are still reported as before. Upstream
libdivecomputer likewise reports a deco stop only without a valid NDL.

Add a synthetic test that covers no deco, deco, the end of deco and a
group with the ceiling before the NDL.

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 retains NDL and ceiling values while parsing each sample, then reports deco stops after parsing. A new registered test checks the emitted values for four NDL and ceiling combinations.

Changes

Suunto EON Steel deco-stop handling

Layer / File(s) Summary
Per-sample deco-stop reporting
src/suunto_eonsteel_parser.c
The parser stores NDL and valid ceiling values for each sample. After parsing, it skips deco-stop output when the ceiling is absent or when a zero ceiling accompanies a valid NDL. Otherwise, it emits a stop with a duration of 60 seconds for a nonzero ceiling or zero seconds for a zero ceiling.
Synthetic parser test
test/test_suunto_eonsteel_deco.c, test/Makefile.am
A new test builds synthetic sample data and checks four NDL and ceiling cases, including reordered fields. The test is added to the build and test lists.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: mikeller, torvalds

Merge Risk: Minimal · up to 2da1e

The change stops zero ceilings from being reported as deco stops when a valid NDL is present. No merge-blocking risk is identified, and the change is small and easily reversible.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the primary behavior change: the parser no longer reports a zero ceiling as a deco stop when the sample has a valid NDL. The raw summary confirms this: sample_deco_stop emits no deco s…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the primary behavior change: the parser no longer reports a zero ceiling as a deco stop when the sample has a valid NDL. The raw summary confirms this: sample_deco_stop emits no deco sample when the ceiling is zero and a valid NDL is present. The title is specific and matches the changeset and the PR objectives.

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: c2377c29-7c8e-4bdb-8553-6cca775cfac5
Commits

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

Files selected for processing: 3

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

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

@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.

Please keep this changeset focused on restoring upstream’s NDL precedence: when a sample group contains valid NDL and an explicit zero ceiling, report the NDL without emitting a zero stop, regardless of field order.

Please don’t restore the upstream EON logic wholesale. When NDL is unavailable, keep the explicit zero-ceiling callback so Subsurface can clear the previous deco state. Leave the fork’s separate TTS callback and positive-ceiling stop duration unchanged here; any changes to those belong in separate changesets.

Please keep regression coverage for both cases: valid NDL with a zero ceiling, and a zero ceiling with no valid NDL. If valid NDL resumes directly after a positive ceiling, Subsurface can retain the previous stop duration. That needs separate importer coverage and should not be worked around by emitting a zero stop that resets the carried NDL.

@metman-oss

Copy link
Copy Markdown
Author

Thanks for the review. As far as I can tell, the change already does what you describe, so I may have phrased the description badly. Point by point:

  • NDL precedence regardless of field order: sample_deco_stop() runs once the whole sample group has been parsed and skips the deco stop only when the ceiling is zero and the same group has a valid NDL (info->ceiling == 0 && info->ndl >= 0). The test checks this for both field orders: "no deco" has the ceiling after the NDL, "reordered" has it before.
  • Zero ceiling without a valid NDL: still reported as a zero deco stop, so Subsurface can clear the deco state as introduced in Extend the libdivecomputer interfaces subsurface#1632. This is the "end of deco" case of the test.
  • TTS and positive ceilings: sample_tts() and its separate DC_SAMPLE_TTS callback are unchanged, and a positive ceiling is still reported with the assumed 60 s stop ("deco" case). The only difference for a positive ceiling is that it is now reported at the end of the sample group, with the same values, rather than while the group is parsed. That is what makes the zero-ceiling decision independent of the field order. If you prefer, I can keep the positive-ceiling callback where it was and only defer the zero-ceiling case.
  • NDL resuming directly after a positive ceiling: not touched. No zero stop is emitted there to reset the carried NDL.

The sentence about upstream in the description only referred to the NDL precedence, not to the rest of the upstream deco logic. I have reworded it.

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

🤖 Generated with Claude Code

@mikeller

Copy link
Copy Markdown
Member

AI-drafted; reviewed by Michael.

You’re right: the patch already makes the distinction I asked for. It suppresses the zero stop when NDL is valid in either field order, keeps the zero-ceiling reset when NDL is unavailable, and leaves the separate TTS callback and positive-ceiling duration intact. The fixture covers both zero-ceiling cases, and the linked CI run passed on this commit. I’m not asking for a parser change on those points.

The stale duration when NDL resumes directly after a positive ceiling is a separate Subsurface importer issue. It shouldn’t be worked around by reintroducing a zero stop here.

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