Skip to content

Commit 55beb89

Browse files
committed
Progress toward RS485 serial operation
1 parent 394bab2 commit 55beb89

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

serial_test.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
PORT_STOPBITS = 1
5959
PORT_BYTESIZE = 8
6060
PORT_PARITY = None
61-
PORT_BAUDRATE = 9600 # 19200 # 115200 # use slow serial to get some contention
61+
PORT_BAUDRATE = 300 # 9600 # 19200 # 115200 # use slow serial to get some contention
6262
PORT_TIMEOUT = 1.5
6363

6464
has_pyserial = False
@@ -154,8 +154,8 @@ async def server_start( port, unit ):
154154
logging.warning( "Starting Modbus Serial server for unit {unit} on {port} w/ {context}".format(
155155
unit=unit, port=port, context=context ))
156156

157-
#from pymodbus.server import ModbusSerialServer as modbus_server_rtu
158-
from .pymodbus_fixes import modbus_server_rtu
157+
from pymodbus.server import ModbusSerialServer as modbus_server_rtu
158+
#from .remote.pymodbus_fixes import modbus_server_rtu
159159
server = modbus_server_rtu(
160160
port = port,
161161
context = context,
@@ -185,7 +185,7 @@ async def server_start( port, unit ):
185185
servers[unit].start()
186186

187187
time.sleep(.5)
188-
'''
188+
189189
# Try the bare Serial client(s), and then the locking version. Should be identical.
190190
for cls in ModbusSerialClient, modbus_client_rtu:
191191
logging.info( "Testing Modbus/RTU Serial client: {cls.__name__}".format( cls=cls ))
@@ -200,12 +200,14 @@ async def server_start( port, unit ):
200200
rr2 = client.read_coils( 2, count=1, slave=2 )
201201
assert (( not rr2.isError() and rr2.bits[0] == True ) or
202202
( not rr1.isError() and rr1.bits[0] == False ))
203-
rr3 = client.read_coils( 2, count=1, slave=3 )
204-
assert rr3.isError()
203+
rr3 = None
204+
with suppress(pymodbus.exceptions.ModbusIOException):
205+
rr3 = client.read_coils( 2, count=1, slave=3 )
206+
assert rr3 is None
205207

206208
client.close()
207209
del client
208-
'''
210+
209211
# Now ensure we can pound away from multiple threads using the locking client.
210212
client = modbus_client_rtu(
211213
port = PORT_MASTER,

0 commit comments

Comments
 (0)