Skip to content

Support S7 system datatypes (HW_*, CONN_*, OB_*, …): declare, read, and browse #10

@ale-rinaldi

Description

@ale-rinaldi

System datatypes (hardware identifiers, connection handles, OB/event refs)

Beside the ordinary process datatypes, an S7-1500 symbol table contains a family of system datatypes — hardware identifiers (HW_ANY, HW_IO, HW_IOSYSTEM, HW_SUBMODULE, HW_DEVICE, HW_MODULE, …), connection handles (CONN_ANY, CONN_OUC, CONN_RID), and OB / event / AOM references (OB_*, EVENT_*, AOM_IDENT, …). The library currently doesn't handle them anywhere.

On the wire they are plain integers (a numeric hardware/connection ID), so the C# reference driver treats each as an alias of a basic integer type.

Current state

  • Neither s7.typeinfo.Softdatatype (used by browse()) nor the SoftDataType table (softdatatype→DataType/size + the name→type dict in _s7commplus_*) define codes ≥ 144.
  • browse() therefore filters them out (they are not in SUPPORTED_SOFTDATATYPES); and even if surfaced they could not be decoded, since there is no entry for them in the read mapping.

C# reference mapping (thomas-v2/S7CommPlusDriver, LGPL-3.0 — ClientApi/PlcTags.cs TagFactory)

  • HW_*, CONN_ANY, CONN_OUCWORD (u16)
  • AOM_IDENT, EVENT_*, CONN_RIDDWORD (u32)
  • OB_*INT (i16)
  • PORT, RTM, DB_ANYUINT (u16)
  • REMOTEANY

(softdatatype codes are in the ~128–180 range, e.g. HW_ANY=144, HW_IO=149, CONN_OUC=170.)

Proposed work — two steps

Step 1 — declare + read.

  1. Add the system softdatatype codes to the Softdatatype / SoftDataType enums.
  2. Map each to its underlying integer wire type + size so read_symbolic() / read_tag() can decode them (a system tag returns its numeric ID).
  3. Unit tests with constructed PValue buffers, one per integer-width category.

Step 2 — surface in browse().
4. Add them to SUPPORTED_SOFTDATATYPES so the tree builder emits them as leaves.
5. Decide what data_type reports: the semantic type name (HW_ANY) or the underlying base type (Word). The C# driver keeps the semantic name for display while reading as the base int; reporting the base type is the least-invasive option, since the existing decode mapping then handles it unchanged.

Validation

Against a live S7-1500: with Step 2, the browse() symbol count reaches full parity with the C# reference symbol table; spot-read a handful of system tags and confirm the numeric ID matches a direct read_symbolic() by access-sequence.

Related: #4 (browse() currently emits process datatypes only).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions