Closed pawelmarkowski closed 7 years ago
@pawelmarkowski , would you mind sharing your findings? Was it a problem with your setup?
no it was not a problem with setup. It still does not work ... interesting thing is that the device has address = 7505 with 32bit registry ... I found other 16bit address that works and I can read a data so I closed the ticket. It is strange that a pymodbus3 works fine.
Are you working with a real modbus device ? If yes can you please share the details/specs?
@pawelmarkowski the device talks only about serial interface but your code is for Modbus TCP, Is there a RTU-TCP gateway you are talking to ? But any how I will try to reproduce this issue with your code using the simulations and update.
Gateway, but I will confirm it on Monday.
Hello, sorry for 1 week delay :). I updated above link - device has modbus TCP interface.
I have the same problem with version '1.3.2'. The length of received package through sync TCP client is not correct.
Following is the logging information:
DEBUG:root:Read a holding register DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.transaction:send: 0x0 0x1 0x0 0x0 0x0 0x6 0x7e 0x3 0x9c 0x42 0x0 0x1 DEBUG:pymodbus.transaction:recv: 0x0 0x1 0x0 0x0 0x0 0x5 0x7e 0x3 0x2 0x0 DEBUG:pymodbus.transaction:0x0 0x1 0x0 0x0 0x0 0x5 0x7e 0x3 0x2 0x0 DEBUG:pymodbus.transaction:getting transaction 1 Modbus Error: [Input/Output] No Response received from the remote unit error 'ModbusIOException' object has no attribute 'registers'
DEBUG:pymodbus.transaction:Running transaction 2 DEBUG:pymodbus.transaction:send: 0x0 0x2 0x0 0x0 0x0 0x6 0x7e 0x3 0x9c 0x42 0x0 0x1 DEBUG:pymodbus.transaction:recv: 0x1 DEBUG:pymodbus.transaction:0x1 error 'len'
DEBUG:pymodbus.transaction:Running transaction 3 DEBUG:pymodbus.transaction:send: 0x0 0x3 0x0 0x0 0x0 0x6 0x7e 0x3 0x9c 0x42 0x0 0x1 DEBUG:pymodbus.transaction:recv: 0x0 0x2 0x0 0x0 0x0 0x5 0x7e 0x3 0x2 0x0 0x1 DEBUG:pymodbus.transaction:0x0 0x2 0x0 0x0 0x0 0x5 0x7e 0x3 0x2 0x0 0x1 DEBUG:pymodbus.factory:Factory Response[3] DEBUG:pymodbus.transaction:adding transaction 2 DEBUG:pymodbus.transaction:getting transaction 3 DEBUG:pymodbus.transaction:getting transaction 0 None error 'NoneType' object has no attribute 'registers'
The recv data in the first transaction was truncated into 2 transactions and caused all the following transaction to be incorrect even though the length is actually correct.
In addition, I managed to get the correct data by using pymodbus3 package instead.
@lixiangabcd08 In your case I see you are trying to read the absolute address (40002), Could you just pass the offset (0x1) as address and see if you can get the expected result?
@pawelmarkowski could you give a try with this branch and let me know if it works ?
https://github.com/riptideio/pymodbus/tree/217-fix-tcp-client or with this pymodbus-1.4.0rc1.tar.gz
@dhoomakethu thank you very much for your suggestion, but changing the base address doesn't work. Same problem persists. As I have said, there are some problems regarding the number of bytes in the first 2 received packages. From 3rd package onwards, the received package length becomes ok. But since it's synchronous, it doesn't work out very nicely.
@dhoomakethu By the way, the code works correctly when I initiate the ModbusTcpClient with library from pymodbus3 and use the read_input_registers function from pymodbus. So I believe there is some bug inside initiation of client code. Hope it helps debugging.
@lixiangabcd08 please see the comment above , please try the pymodbus from that branch or use the tar file to install pymodbus.
@pawelmarkowski could you give a try with this branch and let me know if it works ?
https://github.com/riptideio/pymodbus/tree/217-fix-tcp-client or with this pymodbus-1.4.0rc1.tar.gz
@dhoomakethu It works in your version. Only what I have to change is decoding. Data in the registry is stored in reverse order.
DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.transaction:send: 0x0 0x1 0x0 0x0 0x0 0x6 0x1 0x3 0x17 0x7a 0x0 0x2 DEBUG:pymodbus.transaction:recv: 0x0 0x1 0x0 0x0 0x0 0x7 0x1 0x3 0x4 0xfc 0xbb 0x45 0xc0 DEBUG:pymodbus.transaction:0x0 0x1 0x0 0x0 0x0 0x7 0x1 0x3 0x4 0xfc 0xbb 0x45 0xc0 DEBUG:pymodbus.factory:Factory Response[3] DEBUG:pymodbus.transaction:adding transaction 1 DEBUG:pymodbus.transaction:getting transaction 1 ReadRegisterResponse (2) [64699, 17856] 6175.59 DEBUG:pymodbus.transaction:Running transaction 2 DEBUG:pymodbus.transaction:send: 0x0 0x2 0x0 0x0 0x0 0x6 0x1 0x3 0x1d 0x51 0x0 0x1 DEBUG:pymodbus.transaction:recv: 0x0 0x2 0x0 0x0 0x0 0x7 0x1 0x3 0x4 0x45 0xc0 0xfc 0xbb DEBUG:pymodbus.transaction:0x0 0x2 0x0 0x0 0x0 0x7 0x1 0x3 0x4 0x45 0xc0 0xfc 0xbb DEBUG:pymodbus.factory:Factory Response[3] DEBUG:pymodbus.transaction:adding transaction 2 DEBUG:pymodbus.transaction:getting transaction 2 ReadRegisterResponse (2) [17856, 64699] -7778993684926939764378185074730860544.00
thank You!
@pawelmarkowski thanks for confirming, I will wait on @lixiangabcd08 to confirm so that I can push this to master and close the issue
@dhoomakethu I am very sorry that I am unable to verify it until next week:(
will be tracked with #221
@dhoomakethu Sorry for the late reply, I have tried your version. It does not solve the problem. However the error is a bit different now. Instead of receiving 10 packages in the first transaction, 1 package in the second transaction and 11 (correct number) packages in the rest of transactions, now I receive 10 package in every transaction.
Debugging infomation as followed: 169.254.82.110:502 DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.transaction:send: 0x0 0x1 0x0 0x0 0x0 0x6 0x7e 0x4 0x9d 0x7 0x0 0x1 DEBUG:pymodbus.transaction:recv: 0x0 0x1 0x0 0x0 0x0 0x5 0x7e 0x4 0x2 0x0 DEBUG:pymodbus.transaction:0x0 0x1 0x0 0x0 0x0 0x5 0x7e 0x4 0x2 0x0 DEBUG:pymodbus.transaction:getting transaction 1 Modbus Error: [Input/Output] No Response received from the remote unit
169.254.82.110:502 DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.transaction:send: 0x0 0x1 0x0 0x0 0x0 0x6 0x7e 0x4 0x9d 0x7 0x0 0x1 DEBUG:pymodbus.transaction:recv: 0x0 0x1 0x0 0x0 0x0 0x5 0x7e 0x4 0x2 0x0 DEBUG:pymodbus.transaction:0x0 0x1 0x0 0x0 0x0 0x5 0x7e 0x4 0x2 0x0 DEBUG:pymodbus.transaction:getting transaction 1 Modbus Error: [Input/Output] No Response received from the remote unit
And this TCP connection works fine with pymodbus3.
@lixiangabcd08 , Are you sure you are using the correct pymodbus version ? The behaviour you are observing is not expected , with the changes ModbusTCP client would now will receive up to 1024 bytes of data in one read. Please uninstall and install pymodbus again (the version with patch in this comment thread above ) and confirm. Thanks
@dhoomakethu Thank you for your reply! I believe I am using the correct pymodbus library since I have uninstall and install for a few time. The received modbus data from execution using the offical version and the version in this thread are different. And I only observe this behavior for one type of our TCP device while the other TCP devices work fine with pymodbus.
@lixiangabcd08 Thats interesting to know, could you please share the details of the device ? Also Are you getting correct response if using any other modbus packages (for e.g Modbus-tk ?)
@dhoomakethu The problematic device is SMA Solar PV inverter (STP 5000TL-20) with SunSpec Modbus Interface. For the same manufacturer, SMA cluster controller works fine with pymodbus. I have not tried Modbus-tk (I only have access to the inverter once a week), but QModMaster and pymodbus3 give corrects response. Appreciate all the effort you put in.
Thanks for the update, good to know it works with pymodbus3, I will have a look.
I have tried using pymodbus3 also, but i am getting the same error
I have added time.sleep function ant it has fixed.
Hello, I am checking out pymodbus.version '1.3.2' library and attached code does not work, but code copy in pymodbus3 works fine.
What did I do wrong?
DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.transaction:send: 0x0 0x1 0x0 0x0 0x0 0x6 0x1 0x3 0x1d 0x51 0x0 0x2 DEBUG:pymodbus.transaction:recv: 0x0 0x1 0x0 0x0 0x0 0xb 0x1 0x3 0x8 0x45 0xae 0x6f 0x8c DEBUG:pymodbus.transaction:0x0 0x1 0x0 0x0 0x0 0xb 0x1 0x3 0x8 0x45 0xae 0x6f 0x8c DEBUG:pymodbus.transaction:getting transaction 1 Traceback (most recent call last): Modbus Error: [Input/Output] No Response received from the remote unit File "/home/pawel/workspace/scripts/python/modbus/lumel.py", line 23, in
print(result.registers)
AttributeError: 'ModbusIOException' object has no attribute 'registers'
DEBUG:pymodbus3.transaction:Running transaction 1 DEBUG:pymodbus3.factory:Factory Response[3] DEBUG:pymodbus3.transaction:adding transaction 1 DEBUG:pymodbus3.transaction:getting transaction 1 ReadRegisterResponse (4) [17838, 28486, 16777, 24065] 0 2 register range 5581.91
Thanks for help.