Skip to content

DEV-1338: decode a Shimmer3's alt accel as a big-endian int16 - #25

Merged
JongChern merged 2 commits into
mainfrom
DEV-1338_swift_alt_accel
Nov 4, 2026
Merged

JongChern merged 2 commits into
mainfrom
DEV-1338_swift_alt_accel

Conversation

@marknolan

Copy link
Copy Markdown
Member

What

HighGAccelSensor.processData decoded channels 0x14-0x16 as i12MSB on every hardware.

  • Shimmer3R: correct. These channels carry the ADXL371's 12-bit value, left-justified in a big-endian word.
  • Shimmer3: wrong. The same IDs carry the MPU9x50/ICM-20948's own accelerometer as a plain big-endian int16 (log-and-stream-common docs/SHIMMER3_STREAMING_DATA_FORMAT.md §5). It was read at 1/16 of its value: -300 came out as -19.

The fix decodes them as i16MSB when HardwareVersion is Shimmer3, the same per-hardware branch GyroSensor uses. Shimmer3R is unchanged.

Test

SensorTest.testSensorHighGAccelDecodePerGeneration covers both generations: Shimmer3R resting counts (1, -5, -10) and Shimmer3 int16 values (-300, 1234, -16384).

Not built or run locally: there is no Swift toolchain on Windows, so this PR's CI run is the first time the code compiles and the test runs.

Context

This is the same defect fixed in the web SDK (ShimmerResearch/shimmer-web-sdk#211). The log-and-stream-common HIL decoder had the related Shimmer3R byte-order bug (ShimmerResearch/log-and-stream-common#197). Java, C# and shimmer-host-core decode the Shimmer3R correctly, and give a Shimmer3 no width for these IDs at all.

🤖 Generated with Claude Code

marknolan and others added 2 commits October 25, 2026 06:55
HighGAccelSensor decoded channels 0x14-0x16 as i12MSB on every hardware.
That is right for a Shimmer3R (the ADXL371's 12-bit value, left-justified).
A Shimmer3 sends its MPU9x50/ICM-20948 accelerometer on those IDs as a
plain big-endian int16 (log-and-stream-common
SHIMMER3_STREAMING_DATA_FORMAT.md section 5), so it read at a sixteenth
of its value. Decode it as i16MSB on Shimmer3, mirroring GyroSensor's
per-hardware branch. Shimmer3R is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…there

The int16 decode keys off HighGAccelSensor's HardwareVersion, but
createSensors() rebuilt that sensor only for a Shimmer3R. On a Shimmer3
it kept the UNKNOWN default (or a Shimmer3R's from an earlier
connection), so the 12-bit decode still ran on a real device. The
Shimmer3 branch now builds it with the device's hardware version.

A Shimmer3 also got a calibrated value, from the ADXL371 defaults that
nothing replaces on that generation. The Java API defines this channel
as raw only, since no calibration for it is stored anywhere, so this
API now calibrates it on a Shimmer3R only.

testSensorHighGAccelCalibratedOnlyOnShimmer3R covers the second change.
The createSensors() line is not covered: Shimmer3Protocol cannot be
constructed in a test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JongChern
JongChern merged commit 5ed478e into main Nov 4, 2026
1 check 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