new test script and ENV script
This commit is contained in:
parent
bf12960dc4
commit
3fd0ed27b4
BIN
docs/nice-signals-with-fail-safe-resistors.png
Normal file
BIN
docs/nice-signals-with-fail-safe-resistors.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
2
snippets/ENV
Normal file
2
snippets/ENV
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export LD_LIBRARY_PATH=/home/pi/modbusmaster/pyserialext/
|
||||||
|
export PYTHONPATH=/home/pi/modbusmaster/pyserialext/
|
21
snippets/test6.py
Normal file
21
snippets/test6.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from pymodbus.client.sync import ModbusSerialClient
|
||||||
|
import RS485Ext
|
||||||
|
import time
|
||||||
|
|
||||||
|
ser=RS485Ext.RS485Ext(port='/dev/ttyAMA0', baudrate=1200, stopbits=2)
|
||||||
|
|
||||||
|
client = ModbusSerialClient(method='rtu')
|
||||||
|
client.socket = ser
|
||||||
|
client.connect()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
result = client.read_holding_registers(address=0x2000, count=2, unit=1)
|
||||||
|
print(result)
|
||||||
|
print(result.registers)
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: %s" % str(e))
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
client.close()
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user