Skip to content

Types & Values

Every value you read or write is a native Python type.

Bank family to Python type

Bank family Python type Example
X, Y, C, T, CT, SC bool True
DS, DD, DH, TD, CTD, SD, XD, YD int 42, 0x1234
DF float 3.14
TXT str "A"

A TXT address holds one byte. pyclickplc reads the byte as its cp1252 character and writes a character as its cp1252 byte. The byte 0x80 is "€". Python's cp1252 codec has no character for the bytes 0x81, 0x8D, 0x8F, 0x90 and 0x9D. pyclickplc reads each of them as the control character with the same number, such as "\x81".

No raw Modbus registers — the client handles packing and unpacking automatically.

Read return shapes

Single-index reads return a bare value:

ds1 = await plc.ds[1]  # int

Range reads return a ModbusResponse, a dict keyed by canonical normalized addresses:

values = await plc.ds.read(1, 3)
# {"DS1": 100, "DS2": 200, "DS3": 300}

values["ds1"]  # 100 — lookups are case-insensitive

Write validation

Writes are validated before being sent to the PLC:

  • Type mismatch — writing str to DS raises ValueError.
  • Out of range — writing a value outside the range of the bank's data type raises ValueError.
  • Not writable — some addresses (certain SC/SD) are read-only and raise ValueError.

See also