Phase 3 PR 45 -- DL205 string byte-order quirk #44

Merged
dohertj2 merged 1 commits from phase-3-pr45-dl205-string-byte-order into v2 2026-04-18 22:12:16 -04:00
Owner

Summary

First of 5 stacked PRs landing the DL205/DL260 quirks documented in docs/v2/dl205.md. This one tackles the headline string-byte-order quirk.

  • Adds ModbusStringByteOrder { HighByteFirst, LowByteFirst } enum + StringByteOrder field on ModbusTagDefinition (default = standard Modbus packing).
  • DecodeRegister / EncodeRegister String branches respect per-tag byte order. LowByteFirst packs the first char in the low byte of each register -- the AutomationDirect DirectLOGIC pack-order.
  • Without the flag the driver decodes eHllo instead of Hello from HR[1040..1042] -- same wire bytes, different interpretation.

Validation

  • 56/56 Modbus.Tests pass
  • Integration test DL205_string_low_byte_first_decodes_Hello_from_HR1040 passes against the live pymodbus dl205 profile
  • Control assertion proves HighByteFirst != Hello on the same wire (flag is not a no-op)

Test plan

  • Unit tests for both byte orders (symmetric encode/decode)
  • Nul-truncation still honored under LowByteFirst
  • Integration test against pymodbus dl205 profile
  • Modbus driver full suite green (no regression)
## Summary First of 5 stacked PRs landing the DL205/DL260 quirks documented in docs/v2/dl205.md. This one tackles the headline string-byte-order quirk. - Adds `ModbusStringByteOrder { HighByteFirst, LowByteFirst }` enum + `StringByteOrder` field on `ModbusTagDefinition` (default = standard Modbus packing). - `DecodeRegister` / `EncodeRegister` String branches respect per-tag byte order. `LowByteFirst` packs the first char in the low byte of each register -- the AutomationDirect DirectLOGIC pack-order. - Without the flag the driver decodes `eHllo` instead of `Hello` from HR[1040..1042] -- same wire bytes, different interpretation. ## Validation - 56/56 Modbus.Tests pass - Integration test `DL205_string_low_byte_first_decodes_Hello_from_HR1040` passes against the live pymodbus dl205 profile - Control assertion proves `HighByteFirst != Hello` on the same wire (flag is not a no-op) ## Test plan - [x] Unit tests for both byte orders (symmetric encode/decode) - [x] Nul-truncation still honored under LowByteFirst - [x] Integration test against pymodbus dl205 profile - [x] Modbus driver full suite green (no regression)
dohertj2 added 1 commit 2026-04-18 22:12:04 -04:00
Phase 3 PR 45 -- DL205 string byte-order quirk (low-byte-first ASCII packing). Adds ModbusStringByteOrder enum {HighByteFirst, LowByteFirst} + StringByteOrder field on ModbusTagDefinition (default HighByteFirst, the standard Modbus convention). DecodeRegister + EncodeRegister String branches now respect per-tag byte order. Under LowByteFirst each register packs the first char in the low byte instead of the high byte -- the AutomationDirect DirectLOGIC DL205/DL260/DL350 family's headline string quirk. Without the flag the driver decodes 'eHllo' garbage from HR[1040..1042] even though wire bytes are identical. Unit tests: String_LowByteFirst_decodes_DL205_packed_Hello (5 chars across 3 regs with nul pad), String_LowByteFirst_decode_truncates_at_first_nul, String_LowByteFirst_encode_round_trips_with_decode (asserts exact DL205-documented byte sequence {0x65,0x48,0x6C,0x6C,0x00,0x6F} + symmetric encode->decode), String_HighByteFirst_and_LowByteFirst_differ_on_same_wire (control: same wire, different flag => different decode). 56/56 Modbus.Tests pass. Integration test: DL205StringQuirkTests.DL205_string_low_byte_first_decodes_Hello_from_HR1040 against the dl205.json pymodbus profile; reads HR[1040..1042] with both flags on the same tag map and asserts LowByteFirst='Hello' + HighByteFirst!='Hello'. Gated on MODBUS_SIM_PROFILE=dl205 since the standard profile doesn't seed HR[1040..1042]. Verified 2/2 integration tests pass against running pymodbus dl205 simulator. Baseline for PR 46 (BCD decoder), PR 47 (V-memory octal helper), PR 48 (CDAB float order), PR 49 (FC03/FC16 per-device caps) -- each lands its own DL205_<behavior> test class in tests/.../DL205/. cd19022d19
dohertj2 merged commit 635f67bb02 into v2 2026-04-18 22:12:16 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#44