write coil

This commit is contained in:
aarizona 2024-08-10 09:57:10 +03:00
parent 0136e173a1
commit 71e87c7034
1 changed files with 4 additions and 2 deletions

View File

@ -112,10 +112,10 @@ try:
if state == green_light: if state == green_light:
continue continue
state = green_light if green_light == False:
if state == False:
continue continue
state = green_light
counter += 1 counter += 1
# собираем предварительные данные # собираем предварительные данные
x = two_byte_convert(client.read_holding_registers(2332, 2, MODBUS_SLAVE_ID)) x = two_byte_convert(client.read_holding_registers(2332, 2, MODBUS_SLAVE_ID))
@ -152,6 +152,8 @@ try:
result = client.read_holding_registers(indent + s + k * d, k, MODBUS_SLAVE_ID) result = client.read_holding_registers(indent + s + k * d, k, MODBUS_SLAVE_ID)
print(s + d, "===", two_byte_convert(result) * 0.001) print(s + d, "===", two_byte_convert(result) * 0.001)
client.write_coil(0, !green_light, MODBUS_SLAVE_ID)
except Exception as e: except Exception as e:
print("error", e) print("error", e)