-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FC-16 Write Multiple Holding Registers fails #31
Comments
Adding zip illustrating the failure |
I have same problem. I use Eastron SDM120-Modbus. It uses 32bit float. |
@sgel83 hmm, actually mbusd supports multiple registers reading/writing (function codes 03 and 16) and it should work, but for specific devices your mileage may vary. I've checked your logs and see many lines with "tty: dropped bytes" message. That's quite unusual, are you sure mbusd is single master on the Modbus RTU network? @zmata it looks like your device doesn't respond to the request. Could you try to perform the same request using some other master RTU software directly connected to your device? |
Hi Victor, Thanks for taking a look at this. Here is a new log without the secondary master on the RS-485 network. The behavior of the app is still the same where it fails to write. I actually think it is similiar to zmata, as you will see in the wireshark trace it shows the gw is not responding. This shouldnt be the case though because if I stop mbusd and use pymodbus I can change the value using FC-16 without an issue. |
Hello @sgel83, thanks for the log files, I've checked .pcapng file and it looks like fc16 request is malformed: It seem the root cause of a problem is invalid Modbus/TCP length field, while actual encapsulated Modbus frame size is 9 bytes, the length field indicates it's only 6 bytes long. That looks quite odd. What kind of Modbus TCP master software you're using? |
Its an android app for a centralized ventilation system: https://play.google.com/store/apps/details?id=com.Amalva.c4_app According to the reviews it works but maybe thats how they keep the customer from using other gateways, they just look at the data size in the packet instead of modbus/tcp length header. Good catch. |
I use Simply Modbus TCP Master. It's free, and super useful. They also have Simply Modbus RTU, to test RTU devices. |
My log is from test with Simply Modbus TCP Master. |
@zmata, I think we have different issues though. My issues is the client app is misbehaving by not calculating the mbdata length correctly for the mbtcp length header. If I use pymodbus as a TCP client to write the same register message (but with the correct size in the length header) it is working.. @3cky Are you open to the idea of adding graceful handling of this type of situation where it reads the mbus data and calculates the length? Or do you think its too much of a performance hit? |
@sgel83 still thinking about the best way to handle this type of situation gracefully. There are some options, will look into them. |
@3cky Great, in the meantime I also emailed the manufacturer, and requested them to fix it. No feedback yet. |
Regarding my problem, that is definitelly another then one by @sgel83 From Loxone: From Simply Modbus TCP Master: It seems to be caused by "Low word first". But there isnt possibility to change it in the Loxone configuration. |
@zmata It seems that its possible to change the behavior of Simply Modbus TCP Slave, have you tried this? http://www.simplymodbus.ca/RTUSlaveManual8.htm You have 2 check boxes: "High byte first" http://www.simplymodbus.ca/FAQ.htm
I would reccomend trying all 4 combinations in the Slave program |
Hi, there is no problem with receiving in slave app, but in slave Energy Metter, and it's not possible to switch this setting in it. |
I made a fix, and tested it. It seems to be working but I am not a modbus expert so I think you should review it critcially. I made the following assumptions.
|
@sgel83 I've pushed some fixes into master, please update and test. |
My problem is another one, so I open new issue 33 |
Closing issue, the code change corrected this. Thanks again |
As per the ReadMe.md neither writing a single register or multiple registers are supported.
There is a statement:
"Please note all other function codes (including vendor-specific extensions) are supported on a "best-effort" basis and most likely will fail."
I would like to extend this to support writing multiple register requests, where do you feel the shortcomings are specifically?
Interestingly the problem I experience is writing a single register (Function Code 6) works but an app that I am trying to use the gateway with is writing a single register using Write Multiple Holding Registers (Function Code 16) and this fails.
The text was updated successfully, but these errors were encountered: