-
Notifications
You must be signed in to change notification settings - Fork 14
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
Response Generation Quantity Issue #3
Comments
Interesting, I don't have access to the Modbus standard right now, but I will look for it. I was basing this on descriptions from simply modbus: https://www.simplymodbus.ca/FC02.htm There you can see, that in response, there is only one byte to describe the amount of bytes: |
First, thank you for your response and all the work on this library! You are correct, the response packet is correctly generated for the size of each field. I should clarify the issue is solely with parsing a request in the response constructor. I'm using this as a reference for packet testing: https://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf In testing with a packet similar to this. If the request packet is generated with anything more than 255 in the third argument, it gets casted to 0.
Actually, looking at the Modbus Request Constructor, the address may be being interpreted as the quantity: Lines 13 to 17 in 7d5352a
So the read packets are interpreting the address as the quantity: Lines 48 to 51 in 9bd2ad4
Lines 59 to 61 in 9bd2ad4
I may look at tinkering with this and put in a pull request if you are interested. |
I will quickly look at it and try to prepare some test case for it. It seems not that complicated. I will try to make a PR (and mention you there), if I will have any problems with that, I will ask you for some help |
Ok, it just clicked for me - I understand what is the issue now. I will mark PR as ready when I will fix it |
Signed-off-by: Mateusz Mazur <mateusz.mazur@e.email>
Signed-off-by: Mateusz Mazur <mateusz.mazur@e.email>
Signed-off-by: Mateusz Mazur <mateusz.mazur@e.email>
@MatthewBoeding please take a look at PR #12 - it should resolve this issue, I have also added some more tests around that area. |
Signed-off-by: Mateusz Mazur <mateusz.mazur@e.email>
When parsing a request to generate a read coils response, the number of inputs is not parsed correctly. The bytes value should be a uint16_t instead of uint8_t. The standard requires 0x0000-0xFFFF. Currently, if you're value is 0x0000-0x00FF, you won't generate any value bytes.
Modbus/src/modbusResponse.cpp
Lines 46 to 51 in 9bd2ad4
You'll also need to change the value to be read:
The text was updated successfully, but these errors were encountered: