review(Driver.Modbus.Addressing): fix misleading byte-order hint + drop dead overflow guard
Re-review at 7286d320. -010 (Low): TryParseByteOrder no longer lists REAL/DINT/UINT as type
codes (gave wrong 'field 2' advice -> second parse error); generic byte-order error instead.
-011 (Low): remove unreachable offsetWithinBank>ushort.MaxValue guard (DecodeOctalVAddress
caps at 0xFFFF). + TDD.
This commit is contained in:
@@ -117,11 +117,12 @@ public static class DirectLogicAddress
|
||||
|
||||
// System bank: the registers are contiguous from V40400, so the offset within the bank
|
||||
// is the plain decimal distance from the octal base, not another octal decode.
|
||||
var offsetWithinBank = octalValue - SystemVMemoryOctalBase;
|
||||
if (offsetWithinBank > ushort.MaxValue)
|
||||
throw new OverflowException(
|
||||
$"V-memory address '{vAddress}' is outside the addressable system bank");
|
||||
return SystemVMemoryToPdu((ushort)offsetWithinBank);
|
||||
// Driver.Modbus.Addressing-011: the subtraction result is provably <= 0xBEFF because
|
||||
// DecodeOctalVAddress already caps octalValue at 0xFFFF, so no overflow guard is needed
|
||||
// here. The real overflow guard (pdu > ushort.MaxValue) lives in SystemVMemoryToPdu and
|
||||
// is reachable only when that helper is called directly with a large explicit offset.
|
||||
var offsetWithinBank = (ushort)(octalValue - SystemVMemoryOctalBase);
|
||||
return SystemVMemoryToPdu(offsetWithinBank);
|
||||
}
|
||||
|
||||
// Bit-memory bases per DL260 user manual §I/O-configuration.
|
||||
|
||||
Reference in New Issue
Block a user