Task #146 — Modbus addressing: align type codes with Wonderware DASMBTCP + Ignition
Web verification (2026-04-25) against current vendor docs surfaced concrete grammar conflicts in the v1 suffix grammar shipped in #137. Hard cutover before the Admin UI rolls out widely so users don't paste `:I` from a Wonderware spreadsheet and silently get wrong-typed reads. Sources: - Wonderware DASMBTCP user guide https://cdn.logic-control.com/media/DASMBTCP.pdf - Ignition Modbus addressing (8.1) https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/opc-ua/opc-ua-drivers/modbus/modbus-addressing Type-code changes: | Code | Pre-#146 | Post-#146 | Vendor reference | |--------|----------|------------|------------------------------| | `:S` | (n/a) | Int16 | Wonderware DASMBTCP `S` | | `:US` | (n/a) | UInt16 | Ignition `HRUS` | | `:I` | Int16 | **Int32** | Wonderware `I` + Ignition `HRI` | | `:UI` | UInt16 | **UInt32** | Ignition `HRUI` | | `:I_64` | (n/a) | Int64 | Ignition `HRI_64` | | `:UI_64` | (n/a) | UInt64 | Ignition `HRUI_64` | | `:BCD_32`| (n/a) | BCD32 | Ignition `HRBCD_32` | Codes REMOVED (no clear vendor precedent + conflict with the new mapping): `:DI`, `:L`, `:UDI`, `:UL`, `:LI`, `:ULI`, `:LBCD`. Pre-#146 configs that use them get an "Unknown type code" diagnostic at parse time so users get a fast surface-level error rather than silent wrong-typed reads. Codes UNCHANGED (already vendor-aligned): `:BOOL`, `:F`, `:D`, `:BCD`, `:STR<n>`. Modicon 5/6-digit + mnemonic regions (HR/IR/C/DI) + bit suffix `.N` are also unchanged. Defaults: - Coils / DiscreteInputs → `BOOL` (unchanged) - HoldingRegisters / InputRegisters with no explicit type → Int16 (matches Ignition's bare `HR` default) Byte-order mnemonics (`:ABCD` / `:CDAB` / `:BADC` / `:DCBA`) are kept but documented as OtOpcUa-specific — they aren't in any major vendor's per-tag address string. Ignition uses a `-R` suffix per prefix; Wonderware configures word-order at the topic level. Tests: - 12 Type_Codes_Parse rows updated to assert the new mappings. - New Removed_Aliases_Are_Rejected (×7) confirms each pre-#146 alias now fails fast with "Unknown type code". - Worked_Example_Int16_Array uses the new `:S` code. - New Worked_Example_Int32_Array_Via_I_Code documents the `:I = Int32` vendor-alignment intent so a future "fix" doesn't accidentally regress. - Unknown_Type_Code_Rejected_With_Catalog updated to match the new error message ("Valid: BOOL, S, US, I, ..."). Docs: - docs/v2/modbus-addressing.md — table replaced with the post-#146 codes, each row cites its Wonderware / Ignition reference. New "Codes removed in #146" subsection documents the cutover. - docs/Driver.Modbus.Cli.md — example grammar list updated; explicit type-code reminder appended. 114 addressing tests + 231 driver tests still green. Solution build clean.
This commit is contained in:
@@ -15,7 +15,7 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.Modbus;
|
||||
/// spreadsheets from any of those tools without per-tag manual translation.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Examples:
|
||||
/// Examples (post-#146 type codes — verified against Wonderware DASMBTCP + Ignition):
|
||||
/// <list type="bullet">
|
||||
/// <item><c>40001</c> — HoldingRegisters[0], Int16 (default).</item>
|
||||
/// <item><c>400001</c> — HoldingRegisters[0], Int16 (6-digit form).</item>
|
||||
@@ -23,9 +23,9 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.Modbus;
|
||||
/// <item><c>40001:F</c> — Float32 starting at HR[0] (consumes HR[0..1]).</item>
|
||||
/// <item><c>40001:F:CDAB</c> — same with word-swap byte order.</item>
|
||||
/// <item><c>40001:STR20</c> — 20-char ASCII string.</item>
|
||||
/// <item><c>HR1:DI</c> — Int32 at HR[0] using mnemonic region.</item>
|
||||
/// <item><c>HR1:I</c> — Int32 at HR[0] using mnemonic region (Wonderware-aligned).</item>
|
||||
/// <item><c>40001:F:5</c> — Float32[5] array (consumes HR[0..9]).</item>
|
||||
/// <item><c>40001:I::10</c> — Int16[10] using default byte order (empty order field).</item>
|
||||
/// <item><c>40001:S::10</c> — Int16[10] using default byte order (empty order field).</item>
|
||||
/// <item><c>C100</c> — Coils[99] (mnemonic).</item>
|
||||
/// </list>
|
||||
/// </para>
|
||||
@@ -365,25 +365,37 @@ public static class ModbusAddressParser
|
||||
return true;
|
||||
}
|
||||
|
||||
// #146 — codes aligned with Wonderware DASMBTCP + Ignition Modbus driver after the
|
||||
// 2026-04-25 vendor-doc verification:
|
||||
// - `:I` is Int32 (Wonderware: "letter 'I' follow ... 32-bit signed quantity, two
|
||||
// consecutive registers"). Ignition's HRI is also Int32. The pre-#146 mapping
|
||||
// `:I` = Int16 silently produced wrong-typed data + offset-shifted neighbours when
|
||||
// a tag spreadsheet was pasted from another vendor.
|
||||
// - `:S` is the explicit Int16 code (Wonderware: "letter 'S' ... 16-bit signed").
|
||||
// - `:US` is UInt16 (Ignition: HRUS = "Unsigned Short").
|
||||
// - `:UI` is UInt32 (parallel to `:I` shape; matches Ignition HRUI).
|
||||
// - `:I_64` / `:UI_64` for 64-bit (Ignition HRI_64 / HRUI_64 underscore-N convention).
|
||||
// - `:BCD_32` for 32-bit BCD (Ignition HRBCD_32). The pre-#146 `:LBCD` is dropped.
|
||||
// - HR/IR with no explicit type still default to Int16 (matches Ignition `HR`).
|
||||
type = text.ToUpperInvariant() switch
|
||||
{
|
||||
"BOOL" => ModbusDataType.Bool,
|
||||
"I" => ModbusDataType.Int16,
|
||||
"UI" => ModbusDataType.UInt16,
|
||||
"DI" or "L" => ModbusDataType.Int32,
|
||||
"UDI" or "UL" => ModbusDataType.UInt32,
|
||||
"LI" => ModbusDataType.Int64,
|
||||
"ULI" => ModbusDataType.UInt64,
|
||||
"S" => ModbusDataType.Int16,
|
||||
"US" => ModbusDataType.UInt16,
|
||||
"I" => ModbusDataType.Int32,
|
||||
"UI" => ModbusDataType.UInt32,
|
||||
"I_64" => ModbusDataType.Int64,
|
||||
"UI_64" => ModbusDataType.UInt64,
|
||||
"F" => ModbusDataType.Float32,
|
||||
"D" => ModbusDataType.Float64,
|
||||
"BCD" => ModbusDataType.Bcd16,
|
||||
"LBCD" => ModbusDataType.Bcd32,
|
||||
"BCD_32" => ModbusDataType.Bcd32,
|
||||
_ => (ModbusDataType)(-1),
|
||||
};
|
||||
|
||||
if ((int)type == -1)
|
||||
{
|
||||
error = $"Unknown type code '{text}'. Valid: BOOL, I, UI, DI, L, UDI, UL, LI, ULI, F, D, BCD, LBCD, STR<n>";
|
||||
error = $"Unknown type code '{text}'. Valid: BOOL, S, US, I, UI, I_64, UI_64, F, D, BCD, BCD_32, STR<n>";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user