Phase 3 PR 47 -- DL205 V-memory octal-address helper #46

Merged
dohertj2 merged 1 commits from phase-3-pr47-dl205-vmemory into v2 2026-04-18 22:13:33 -04:00
Owner

Summary

Stacked on PR 46. Adds DirectLogicAddress helpers to translate DirectLOGIC octal V-addresses into 0-based Modbus PDU addresses.

  • UserVMemoryToPdu("V2000") = 0x0400 (octal-to-decimal) for user bank.
  • SystemVMemoryBasePdu / SystemVMemoryToPdu cover the system bank (V40400+) which does NOT follow simple octal conversion -- CPU relocates it to PDU 0x2100 in H2-ECOM100 absolute mode.
  • Rejects non-octal digits (8/9) with clear error (.NET has no int.Parse base-8 overload, so we walk digits manually).

Validation

  • 23/23 Modbus.Tests pass (V0…V17777 sweep, non-octal reject, whitespace/case tolerance, overflow)
  • 5/5 DL205 integration tests pass (HR[0x0400]=0x2000 for V2000, HR[0x2100]=0x4040 for V40400)

Test plan

  • User V-memory conversion matches the D2-USER-M appendix table exactly
  • System V-memory (V40400 → 0x2100) documented distinct from simple octal conversion
  • End-to-end read against pymodbus dl205 profile
## Summary Stacked on PR 46. Adds `DirectLogicAddress` helpers to translate DirectLOGIC octal V-addresses into 0-based Modbus PDU addresses. - `UserVMemoryToPdu("V2000")` = `0x0400` (octal-to-decimal) for user bank. - `SystemVMemoryBasePdu` / `SystemVMemoryToPdu` cover the system bank (V40400+) which does NOT follow simple octal conversion -- CPU relocates it to PDU `0x2100` in H2-ECOM100 absolute mode. - Rejects non-octal digits (8/9) with clear error (.NET has no `int.Parse` base-8 overload, so we walk digits manually). ## Validation - 23/23 Modbus.Tests pass (V0…V17777 sweep, non-octal reject, whitespace/case tolerance, overflow) - 5/5 DL205 integration tests pass (HR[0x0400]=0x2000 for V2000, HR[0x2100]=0x4040 for V40400) ## Test plan - [x] User V-memory conversion matches the D2-USER-M appendix table exactly - [x] System V-memory (V40400 → 0x2100) documented distinct from simple octal conversion - [x] End-to-end read against pymodbus dl205 profile
dohertj2 added 1 commit 2026-04-18 22:13:29 -04:00
Phase 3 PR 47 -- DL205 V-memory octal-address helper. Adds DirectLogicAddress static class with two entry points: UserVMemoryToPdu(string) parses a DirectLOGIC V-address (V-prefixed or bare, whitespace tolerated) as OCTAL and returns the 0-based Modbus PDU address. V2000 octal = decimal 1024 = PDU 0x0400, which is the canonical start of the user V-memory bank on DL205/DL260. SystemVMemoryBasePdu + SystemVMemoryToPdu(ushort offset) handle the system bank (V40400 and up) which does NOT follow the simple octal-to-decimal formula -- the CPU relocates the system bank to PDU 0x2100 in H2-ECOM100 absolute mode. A naive caller converting 40400 octal would land at PDU 0x4100 (decimal 16640) and miss the system registers entirely; the helper routes the correct 0x2100 base. Why this matters: DirectLOGIC operators think in OCTAL (the ladder-logic editor, the Productivity/Do-more UI, every AutomationDirect manual addresses V-memory octally) while the Modbus wire is DECIMAL. Integrators routinely copy V-addresses from the PLC documentation into client configs and read garbage because they treated V2000 as decimal 2000 (HR[2000] = 0 in the dl205 sim, zero in most PLCs). The helper makes the translation explicit per the D2-USER-M appendix + H2-ECOM-M \u00A76.5 references cited in docs/v2/dl205.md. Unit tests: UserVMemoryToPdu_converts_octal_V_prefix (V0, V1, V7, V10, V2000, V7777, V10000, V17777 -- the exact sweep documented in dl205.md), UserVMemoryToPdu_accepts_bare_or_prefixed_or_padded (case + whitespace tolerance), UserVMemoryToPdu_rejects_non_octal_digits (V8/V19/V2009 must throw ArgumentException with 'octal' in the message -- .NET has no base-8 int.Parse so we hand-walk digits to catch 8/9 instead of silently accepting them), UserVMemoryToPdu_rejects_empty_input, UserVMemoryToPdu_overflow_rejected (200000 octal = 0x10000 overflows ushort), SystemVMemoryBasePdu_is_0x2100_for_V40400, SystemVMemoryToPdu_offsets_within_bank, SystemVMemoryToPdu_rejects_overflow. 23/23 Modbus.Tests pass. Integration tests against dl205.json pymodbus profile: DL205_V2000_user_memory_resolves_to_PDU_0x0400_marker (reads HR[0x0400]=0x2000), DL205_V40400_system_memory_resolves_to_PDU_0x2100_marker (reads HR[0x2100]=0x4040). 5/5 DL205 integration tests pass. Caller opts into the helper per tag by calling DirectLogicAddress.UserVMemoryToPdu("V2000") as the ModbusTagDefinition Address -- no driver-wide "DL205 mode" flag needed, because users mix DL and non-DL tags in a single driver instance all the time. 2b5222f5db
dohertj2 merged commit 9e61873cc0 into v2 2026-04-18 22:13:33 -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#46