Skip to content

fix(params): decode ProcessData descriptor Length per Table B.6#12

Merged
w1ne merged 1 commit into
masterfrom
fix/pd-descriptor-spec-conformance
Jul 4, 2026
Merged

fix(params): decode ProcessData descriptor Length per Table B.6#12
w1ne merged 1 commit into
masterfrom
fix/pd-descriptor-spec-conformance

Conversation

@w1ne

@w1ne w1ne commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Part of a V1.1.5 spec-conformance audit. This is the one deviation that is safe to fix in isolation (it only affects decoding a device-reported descriptor — no wire-protocol/interop change).

Bug

The ProcessData In/Out descriptor (Direct Parameter Page 1, Figure B.5) carries Length in bits 0-4 only; bit 6 is SIO, bit 7 is BYTE. The decoder masked the whole byte (& 0x7F / /8), so:

  • a device that legally sets the SIO bit had its PD length corrupted (e.g. 0xC3 → 68 octets instead of 4);
  • BYTE=0 sub-byte lengths were truncated by integer division (e.g. 4-bit PD → 0 octets).

Fix

Mask Length to bits 0-4 and round bit lengths up to whole octets, per Table B.6. All existing byte-aligned descriptors decode identically; new test covers the SIO-bit and sub-byte cases.

Audit context (documented, not fixed here)

docs/IMPLEMENTATION_STATUS.md now records the full audit. Field encodings (MinCycleTime B.3, Direct Parameter B.1, M-seqCapability B.3, MC octet A.1/A.2) are conformant. Two co-designed deviations remain and need a coordinated master+device change (they'd break the on-wire model until both land):

  • startup/OPERATE transition should be MC=0xA2 (read MinCycleTime) then MasterCommand 0x99 "DeviceOperate" on the page channel — not a bare 0x0F;
  • ISDU I-Service nibble should be 0x9/0xA/0xB (read) / 0x1/0x2/0x3 (write) per Table A.12 — not 0x08/0x09.

14/14 ctest (incl. new Table B.6 test), strict compile, cppcheck green.

The ProcessData In/Out descriptor (Direct Parameter Page 1, Figure B.5)
carries Length in bits 0-4 only; bit 6 is SIO and bit 7 is BYTE. The
decoder masked the whole byte, so a device that legally sets the SIO bit
had its PD length corrupted, and BYTE=0 sub-byte lengths were truncated by
integer division instead of rounded up. Mask to bits 0-4 and round bit
lengths up to whole octets, matching Table B.6.

Also documents the V1.1.5 conformance audit in IMPLEMENTATION_STATUS.md:
field encodings are conformant; the startup/OPERATE-transition octets
(should be MC=0xA2 read then MasterCommand 0x99) and the ISDU I-Service
nibble (Table A.12) are known co-designed deviations from the device stack,
pending a coordinated change.

New parameter test covers SIO-bit and sub-byte descriptors. 14/14 ctest,
strict compile, and cppcheck green.
@w1ne w1ne merged commit 4053ea9 into master Jul 4, 2026
3 checks passed
@w1ne w1ne deleted the fix/pd-descriptor-spec-conformance branch July 4, 2026 21:03
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.

1 participant