Skip to content

Commit 6a6bd1e

Browse files
marknolanclaude
andcommitted
DEV-793 Fix midday/midnight-split regression from the raw byte-advance
0d65311 (adversarial-review finding 3) switched the sensor-data byte walk to the raw data-block size so the midday/midnight split recompute could not corrupt the variable-length LSM6DSV FIFO walk. But a split block appears in listOfDataBlocksInOrder as TWO entries whose recomputed sizes sum to the on-disk size - advancing by the raw size for each part counts the block twice, misaligning every subsequent block and eventually overrunning the payload buffer (ArrayIndexOutOfBoundsException in parseDataBlockData). Caught by ASM_PC_00005 Test_022, the only midday/midnight-straddling dataset in the suite; it was not part of the 0d65311 re-run set. The walk now advances split parts by their own recomputed share and unsplit blocks by the raw size (identical for unsplit fixed-packet blocks; raw remains the only valid measure for the unsplit LSM6DSV tagged FIFO). A split LSM6DSV block now fails loudly instead of silently misparsing - sample-count arithmetic cannot locate the split point in a tagged FIFO, and no such recording exists yet. Verified: Test_022 back to green against unchanged references. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 0d65311 commit 6a6bd1e

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

ShimmerDriver/src/main/java/com/shimmerresearch/verisense/payloaddesign/PayloadContentsDetailsV8orAbove.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,25 @@ public void parsePayloadSensorData() {
410410
if(dataBlockDetails.listOfSensorClassKeys.contains(sensorClassKey)) {
411411
verisenseDevice.parseDataBlockData(dataBlockDetails, byteBuffer, currentByteIndex, COMMUNICATION_TYPE.SD);
412412
}
413-
// RAW size: immune to midday/midnight split recomputation (see above)
414-
currentByteIndex += dataBlockDetails.getQtySensorDataBytesInDatablockRaw();
413+
// Advance by the on-disk bytes THIS list entry occupies. A midday/midnight-split
414+
// block appears as two consecutive entries whose recomputed sizes
415+
// (dataPacketSize*sampleCount) sum to the on-disk block size, so each part must
416+
// advance by its own share - advancing by the raw size for each part would count
417+
// the block twice and misalign every block after it. Unsplit blocks advance by
418+
// the raw size, which for the variable-length LSM6DSV tagged FIFO is the only
419+
// valid measure (its raw length includes tag/mag/timestamp entries that a
420+
// dataPacketSize*sampleCount recomputation cannot reproduce).
421+
if(dataBlockDetails.isFirstPartOfSplitDataBlock() || dataBlockDetails.isSecondPartOfSplitDataBlock()) {
422+
if(dataBlockDetails.datablockSensorId==DATABLOCK_SENSOR_ID.LSM6DSV) {
423+
// A split FIFO block cannot be byte-walked from sample counts; supporting
424+
// it needs a FIFO-entry-aware split. Fail loudly rather than misparse
425+
// every subsequent block (no such recording exists yet - see DEV-793).
426+
throw new IllegalStateException("Midday/midnight-split LSM6DSV FIFO data blocks are not supported by the byte-offset walk");
427+
}
428+
currentByteIndex += dataBlockDetails.qtySensorDataBytesInDatablock;
429+
} else {
430+
currentByteIndex += dataBlockDetails.getQtySensorDataBytesInDatablockRaw();
431+
}
415432

416433
dataBlockIndex++;
417434

0 commit comments

Comments
 (0)