Skip to content

decodeR11Raw reads two bytes early: slot-1 lanes start at inner 38 and 238 #89

Backlog

Description

@magnetarQ

At fbadb5b, decodeR11Raw (lib/src/live.dart) reads its two 50-sample channels at inner 36 and 236. On our WHOOP 4.0 they start at 38 and 238, so each value now mixes two samples. Issue #25 found the two 50-sample int32 channels; this is only about the start. (The correction there calls the original misreading a 2-byte phase error, but the start stayed at 36.)

Evidence (one WHOOP 4.0, firmware harvard 41.17.6.0, 22,420 R11 frames, all 1,924 bytes):

  • Historical v25 records carry an i32 first sample at inner 15. In 739 v25 records with an R11 frame of the same timestamp, it equals the R11 i32 at 38 in 739/739, and at 34, 36 and 40 in 0/739.
  • Reading at 36, the median difference between neighbouring samples is about 8.7 million; at 38 it is 133 (every 20th frame, first channel).
  • 734 of those 739 match v25's 24 deltas against every second sample at 38 exactly; the other 5 differ only by i16 clamping (v25: decode the optical samples and the sub-second field #87).
  • 238 follows from the second channel being back to back with the first; it then ends at 438, where the slot 2 descriptor starts.

The frame also has a 25-byte descriptor per slot: slot 1 at inner 13:38, slot 2 at 438:463, slot 3 at 863:888. The existing 436-byte minimum would need to become 438.

Not claimed: what the channels measure, or the LED/photodiode. Raw frames are not attached because they contain health data. A fix changes three numbers in the decoder, plus the synthetic test and the doc comment that use the old offsets; I can send a PR.

Found with AI assistance; checked on captures from our own strap.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions