20 lines
462 B
Python
Raw Permalink Normal View History

2019-07-06 23:27:26 +01:00
from pymodbus.client.sync import ModbusSerialClient
import RS485Ext
import time
2019-07-08 09:28:33 +01:00
ser=RS485Ext.RS485Ext(port='/dev/ttyAMA0', baudrate=9600, stopbits=1)
2019-07-06 23:27:26 +01:00
client = ModbusSerialClient(method='rtu')
client.socket = ser
client.connect()
try:
2019-07-08 19:50:37 +01:00
result = client.write_register(address=0x9c48, unit=4, value=0x000F)
2019-07-08 09:28:33 +01:00
# result = client.write_coil(address=0x0000, unit=4, value=1)
2019-07-06 23:27:26 +01:00
print(result)
except Exception as e:
print("ERROR: %s" % str(e))
client.close()