-
Notifications
You must be signed in to change notification settings - Fork 986
Serial forwarder demo doesnt work with write single register #2660
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
Comments
please add a debug log (using the pymodbus call) so we can see what happens. The serial forwarder should forward the requests and pass the responses, however this is a very limited forwarder a real forwarder works at frame level and passes frames back and forth. We have for a long time wanted to make a real forwarder but never had the time to do so. |
calling the datastore during execute is correct and will not always return zero but the current value. |
pull requests are always welcome. it do looks as if the "if" in get values are wrong. |
Here is the log, which shows the data traffic, when the I have put empty lines to the points, where I believe is happening something interesting.
There is a log for the same request, but with the In this particular action, the requested state is
|
looks as if it works as it should without the "if". |
One last problem, which I just found out. Sometimes it takes more time for the inverter to apply the updated value. I added sleep of 1 second, as a temporary solution.
This issue will be highly dependent on the target device. |
ok. Feel free to submit a pull request. |
The sleep is wrong, because if the device was connected directly the app would get the result of the write not a following read. In the remote datastore the write (set values) returns with the result, this result should be returned and the get values should be bypassed. |
Absolutely agree, its event mentioned in the original description. Unfortunately I dont know the project well enough to write such change. Is it easy enough, to share within this discussion ? I believe such change would be much better, than any other changes mentioned before. |
It is only changes in the file you already patched, writing the changes here instead of just merging and updated file, would be kind of doble work. You do not need to know a lot about the project, you have all the information needed in one file. |
Getting response of WriteSingleRegister is read correctly. Problem described at <pymodbus-dev#2660>
Steps to reproduce
serial_forwarder
from https://github.com/pymodbus-dev/pymodbus/blob/dev/examples/contrib/serial_forwarder.pymodbus
command towrite_single_register
- for Goodwe inverterRTU
is okTCP
side is corruptedEvidences
RTU
side is as expected, enable (on) the switch0xf7 0x6 0xb9 0xec 0x0 0x1 0xb8 0x35
0xf7 0x6 0xb9 0xec 0x0 0x1 0xb8 0x35
0x0 0x1
starting on the 5th byteTCP
side is corrupted, as the packet is encoded like0x82 0xcc 0x0 0x0 0x0 0x6 0xf7 0x6 0xb9 0xec 0x0 0x1
0x82 0xcc 0x0 0x0 0x0 0x6 0xf7 0x6 0xb9 0xec 0x0 0x0
0x0 0x1
in request, two bytes from the end of the packet0x0 0x0
in the response, the last two bytesThe reason (in the code), why
pymodbus
works like this is in the code, where the condition makes to alwaysreturn [0]
.pymodbus/pymodbus/datastore/remote.py
Lines 34 to 41 in b4cecc3
Datastore is called during the execution of the
execute
inWriteSingleRegisterRequest
object.pymodbus/pymodbus/pdu/register_message.py
Lines 181 to 194 in b4cecc3
Due to the condition above, the returned value after the
WriteSingleRegisterRequest
is always0
and this will fail the command in the management application.What is the correct way to fix this issue ? I have removed the condition for the test and the command is now executed successfully. Unfortunately I dont think, this is correct, because the program now executes the command to write the register value, then read its state back. AFAIK this shouldnt be necessary and the current state of the register is contained in the response on the
RTU
side.Am I missing something, or is it a bug ?
The text was updated successfully, but these errors were encountered: