Compare commits
1 Commits
forecaster
...
lüftungsan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b00d622aa |
BIN
modbus_registers/_modbus_register_template.xlsx
Normal file
BIN
modbus_registers/_modbus_register_template.xlsx
Normal file
Binary file not shown.
BIN
modbus_registers/ventilation_modbus_registers.xlsx
Normal file
BIN
modbus_registers/ventilation_modbus_registers.xlsx
Normal file
Binary file not shown.
18
test.py
Normal file
18
test.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from pymodbus.client import ModbusTcpClient
|
||||
import struct
|
||||
|
||||
MODBUS_IP="10.0.0.40"
|
||||
client=ModbusTcpClient(MODBUS_IP, port=502)
|
||||
client.connect()
|
||||
|
||||
try:
|
||||
rr = client.read_input_registers(30, count=3, slave=1)
|
||||
print("Raw 30..32:", rr.registers)
|
||||
|
||||
def as_int16(x):
|
||||
return struct.unpack(">h", struct.pack(">H", x))[0]
|
||||
|
||||
for i, raw in enumerate(rr.registers, start=30):
|
||||
print(i, "raw", raw, "int16", as_int16(raw), "scaled", as_int16(raw)/10.0)
|
||||
finally:
|
||||
client.close()
|
||||
Reference in New Issue
Block a user