fix(driver-modbus-addressing): resolve High code-review finding (Driver.Modbus.Addressing-001)
The DL205 family-native branch routed every V-prefixed address through DirectLogicAddress.UserVMemoryToPdu, a plain octal-to-decimal decode. DL205/DL260 system V-memory (V40400 and up) is not a simple octal decode: the CPU relocates the system bank to Modbus PDU 0x2100. Octal-decoding V40400 produced 16640 (0x4100), the wrong register, so any tag addressing a system register through the grammar string silently read/wrote the wrong PLC memory. - Add DirectLogicAddress.VMemoryToPdu, which decodes the octal V-address, detects the system bank (octal >= V40400 == SystemVMemoryOctalBase) and relocates it through SystemVMemoryToPdu to PDU 0x2100; user-bank addresses keep the plain octal decode. - ModbusAddressParser's DL205 V branch now calls VMemoryToPdu instead of UserVMemoryToPdu. UserVMemoryToPdu is retained for user-bank-only callers. - Correct the ModbusFamilyParserTests V40400 assertion (16640 -> 0x2100) and add system-bank regression cases plus direct helper coverage. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -229,7 +229,9 @@ public static class ModbusAddressParser
|
||||
// SP → DiscreteInputs (special relays).
|
||||
if (text.StartsWith("V", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
offset = DirectLogicAddress.UserVMemoryToPdu(text);
|
||||
// VMemoryToPdu routes user vs system V-memory: the system bank (octal
|
||||
// >= V40400) is relocated to PDU 0x2100, NOT a plain octal decode.
|
||||
offset = DirectLogicAddress.VMemoryToPdu(text);
|
||||
region = ModbusRegion.HoldingRegisters;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user