Closed GoogleCodeExporter closed 9 years ago
Hello,
I agree that the behaviour should be what you are expecting.
I've just pushed a new version with a new unit-test that tries to reproduce
your problem.
Can you please try to get it and run:
python functest_modbus_rtu.py RtuTestQueries.testWriteMultipleCoilsIssue23
Does the test pass? In my case, it is ok and the queries seems to be what you
are expecting.
Did you notice similar issue on other function codes?
Best
luc
Original comment by luc.jean@gmail.com
on 11 Oct 2011 at 9:20
Hello,
Thanks for the quick reaction. I did the test connecting two of my serial ports
one to each other. The request now looks how it should be, however the test
failed. The output is following:
Hello
RtuMaster COM6 is opened
RtuServer COM1 is opened
-> 10-15-0-0-0-32-4-204-204-204-204-75-150
-->10-15-0-0-0-32-4-204
handle request failed: Invalid CRC in request
<--129-4
-->204-204-204-75-150
handle request failed: Invalid CRC in request
<--129-4
<- 129-4-129-4
Emodbus_tk.modbus_rtu.RtuServer has stopped
======================================================================
ERROR: testWriteMultipleCoilsIssue23 (__main__.RtuTestQueries)
Write the values of a multiple coils and check that it is correctly written
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Documents and Settings\Petar\Desktop\functest_modbus.py", line 287, in testWriteMultipleCoilsIssue23
result = self.master.execute(10, modbus_tk.defines.WRITE_MULTIPLE_COILS, 0,output_value=[0, 0, 1, 1]*8)
File "C:\Documents and Settings\Petar\Desktop\modbus_tk\utils.py", line 26, in new
raise excpt
ModbusInvalidResponseError: Response address 129 is different from request
address 10
----------------------------------------------------------------------
Ran 1 test in 1.203s
FAILED (errors=1)
---
One more thing: unittest.sys.argv is somehow not valid for me, so I used only
"sys.argv" instead.
I forget to mention, I use Python 2.7
Original comment by petar.e...@gmail.com
on 11 Oct 2011 at 12:04
OK it seems that there is a "blank" on the serial link and that it causes the
rtu server to see 2 different queries.
Can you try to increase the serial timeout by changing the value of
server._serial.interCharTimeout and server._serial.timeout
I've pushed a new version when timeout is set to 5*to rather that 1.5*to (which
seems wrong). May be it is noot enough?
Tell me if it fix the issue.
Best
luc
Original comment by luc.jean@gmail.com
on 12 Oct 2011 at 6:07
So, I did some tests with my own code. I played a bit wit the two
aforementioned parameters and found out, that the best working solution is:
self._serial.interCharTimeout = 1.5 * self._t0 #Line 148
self._serial.timeout = 10 * self._t0 #Line 149
If .timeout is above 5 and less than 10, it's still working, but from time to
time it's splitting again some queries.
I've just tested with FC5, FC6 and FC16 commands and they are working fine too.
BR
Petar
Original comment by petar.e...@gmail.com
on 12 Oct 2011 at 7:32
Hello Petar,
I am ok to increase this timeout to 10*to.
I will commit and publish a new version soon.
Thanks for feedback and your contribution to modbus-tk.
Best
luc
Original comment by luc.jean@gmail.com
on 12 Oct 2011 at 7:46
modbus-tk 0.4.2 has been released and fix the problem
Original comment by luc.jean@gmail.com
on 12 Oct 2011 at 8:30
Original issue reported on code.google.com by
petar.e...@gmail.com
on 11 Oct 2011 at 8:27