Skip to content

DEV-1163 Read the Shimmer3R LN accel range from the SD header - #215

Merged
JongChern merged 1 commit into
masterfrom
DEV-1163_shimmer3r_sd_ln_accel_range
Oct 20, 2026
Merged

JongChern merged 1 commit into
masterfrom
DEV-1163_shimmer3r_sd_ln_accel_range

Conversation

@JongChern

Copy link
Copy Markdown
Contributor

Summary

The Shimmer3R branch of ShimmerSDLog.ProcessSDLogHeader never called SetLNAccelRange, so GetLNAccelRange() reported ±2g for every Shimmer3R SD log whatever range the low-noise accel (LSM6DSV) was recorded at. The range is in config setup byte 3 (header byte 11), bits 7:6. The fix reads it there, before the LN calibration block is parsed.

Effect before this fix

  • Header carries a populated LN calibration block: it was used as-is, so the calibrated numbers were right. Only the reported range was wrong.
  • Block is blank (all 0x00, or a -1 sensitivity): RetrieveKinematicCalibrationParametersFromPacket falls back to the default sensitivity for LNAccelRange. That was always the ±2g value (1672), so LN values came out 2×, 4× or 8× too small at ±4g, ±8g or ±16g.

The Java parser had the same defect. It is fixed in ShimmerResearch/Shimmer-Advance-API#499 and ShimmerResearch/Shimmer-Java-Android-API#322.

Testing

New ShimmerSDLogLnAccelRangeTest (added to ShimmerUnitTests.csproj) builds Shimmer3R SD files by hand and checks three things:

  • the range is read for all four values, and a blank block falls back to that range's default sensitivity;
  • a blank block at ±16g calibrates 2090 counts to 10.0 m/s², where the old code gave 1.25;
  • a custom header calibration is used.

All three fail without the fix. The full ShimmerAPITest.sln suite (31 tests) passes with MSBuild and VSTest, as in CI.

Shimmer-Labview-API wraps this API and picks the fix up on its next rebuild.

🤖 Generated with Claude Code

The Shimmer3R branch of ProcessSDLogHeader never called
SetLNAccelRange, so GetLNAccelRange() reported +/-2g for every SD log.
The range is in header byte 11, bits 7:6.

A populated LN calibration block in the header was used as-is, so those
numbers were right. A blank block (all 0x00, or -1 sensitivity) fell
back to the default for LNAccelRange, the +/-2g sensitivity, so LN
values came out 2x, 4x or 8x too small at +/-4g, +/-8g or +/-16g.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JongChern
JongChern requested review from MAzalya and a balanced review from Copilot October 8, 2026 03:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation matches the header format and is covered across all supported ranges and calibration paths.

0 open findings

What changed in this PR

Fixes Shimmer3R SD-log parsing so LN accelerometer range and fallback calibration match the recorded configuration.

Changes:

  • Parses LN range from header byte 11.
  • Adds coverage for all ranges, blank calibration, and custom calibration.
  • Registers the new tests.

Sibling check: Java fixes are referenced; no duplicate C# SD parser requires updating.

File Description
ShimmerAPI/​ShimmerAPI/​ShimmerSDLog.cs Reads the Shimmer3R LN range before calibration parsing.
ShimmerAPI/​ShimmerUnitTests/​ShimmerSDLogLnAccelRangeTest.cs Tests range parsing and calibration behavior.
ShimmerAPI/​ShimmerUnitTests/​ShimmerUnitTests.csproj Includes the new test file.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@JongChern
JongChern requested a lite review from Copilot October 15, 2026 05:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The reviewed changes address the parsing defect and include comprehensive regression coverage.

0 open findings

🧠 Review effort: Lite

@JongChern
JongChern merged commit cd91336 into master Oct 20, 2026
4 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