Modbus Hex-Variablen lesen und schreiben

Was ich mit IPS machen möchte: Mit IPS über Modbus per TCP/IP Werte übergeben und die Antwort in eine Variable schreiben.

  1. Auslesen
    rem Variablenname V00128 = Fühler KWL CO2 - 1
    a) modpoll -m tcp -a 180 -t4:hex -r 1 -0 -1 -o 2.0 192.22.71.75 0x7630 0x3031 0x3238 0x0000
    Angabe der Variable V00128 in Hex: V0 01 28 Terminierung
    b) modpoll -m tcp -a 180 -t4:hex -r 1 -c 6 -0 -1 -o 2.0 192.22.71.75

Verwendete Parameter:
-m ascii Modbus ASCII protocol
-a # Slave address (1-255 for serial, 0-255 for TCP, 1 is default)
-r # Start reference (1-65536, 100 is default)
-c # Number of values to read (1-125, 1 is default)
-t 4:hex 16-bit output (holding) register data type with hex display
-0 First reference is 0 (PDU addressing) instead 1
-o # Time-out in seconds (0.01 - 10.0, 1.0 s is default)
-1 Poll only once only, otherwise every poll rate interval

Ergebnis nach Aufruf von b) ist der Variablenwert in HEX als Array:
– Polling slave…
[1]: 0x7630
[2]: 0x3030
[3]: 0x3030
[4]: 0x3D00
[5]: 0x0000
[6]: 0x0000

  1. Schreiben
    Schreibe Wert 3 in Variable V00102 terminierung mit 0
    modpoll -m tcp -a 180 -t4:hex -r 1 -0 -1 -o 2.0 10.8.20.39 0x7630 0x3031 0x3032 0x3d33 0x0000
    IP V0 01 02 Wert 3 Terminierung mit 0x0000
    Was muss ich dazu in IPS / PHP schreiben?

Parameter-Übersicht:

General options:
-m ascii Modbus ASCII protocol
-m rtu Modbus RTU protocol (default if SERIALPORT contains \ or COM)
-m tcp MODBUS/TCP protocol (default otherwise)
-m enc Encapsulated Modbus RTU over TCP
-a # Slave address (1-255 for serial, 0-255 for TCP, 1 is default)
-r # Start reference (1-65536, 100 is default)
-c # Number of values to read (1-125, 1 is default)
-t 0 Discrete output (coil) data type
-t 1 Discrete input data type
-t 3 16-bit input register data type
-t 3:hex 16-bit input register data type with hex display
-t 3:int 32-bit integer data type in input register table
-t 3:mod 32-bit module 10000 data type in input register table
-t 3:float 32-bit float data type in input register table
-t 4 16-bit output (holding) register data type (default)
-t 4:hex 16-bit output (holding) register data type with hex display
-t 4:int 32-bit integer data type in output (holding) register table
-t 4:mod 32-bit module 10000 type in output (holding) register table
-t 4:float 32-bit float data type in output (holding) register table
-i Slave operates on big-endian 32-bit integers
-f Slave operates on big-endian 32-bit floats
-e Use Daniel/Enron single register 32-bit mode
-0 First reference is 0 (PDU addressing) instead 1
-1 Poll only once only, otherwise every poll rate interval
-l Poll rate in ms, (1000 is default)
-o # Time-out in seconds (0.01 - 10.0, 1.0 s is default)
Options for MODBUS/TCP:
-p # TCP port number (502 is default)
Options for Modbus ASCII and Modbus RTU:
-b # Baudrate (e.g. 9600, 19200, …) (19200 is default)
-d # Databits (7 or 8 for ASCII protocol, 8 for RTU)
-s # Stopbits (1 or 2, 1 is default)
-p none No parity
-p even Even parity (default)
-p odd Odd parity
-4 # RS-485 mode, RTS on while transmitting and another # ms after