Closed ickedude closed 8 months ago
In the first example, there are several client errors:
0xff 0x10 0x0 0x0 0x0 0x1c 0x38
the slave is ff, but you have not defined that slave in your datastore. the function is 0x10, which do not exist. the starting address is 0x0, 0x0 which is normally not allowed the number of reqisters requested is HUGE 0x1c, 0x38
So any response at all is a surprise.
In the second example you use function code 0x06 which is "write single register" so there are no count....you set the value to 0x00, 0x00
I think you need to read up on the modbus protocol.
Regarding the offset of 1, that is very common on modbus devices, the modbus protocol specification do NOT make any assumption on how data is stored, so an offset of e.g. 17 would be just as legal. For a larger explanation please see the datastore simulator documentation, that contains a couple of drawing explaining the difference between the address in the request and in memory.
Closing this, as it seems more to be misunderstanding than a bug.
Sorry function 0x10 exist it is "write multiple registers" but you missed the "byte count" byte, which is just after the quantity.
The comments about addressing is still valid, address= 0x0, 0x0 on the network is not normal.
First of all thank you for the quick responses. You are totally right, it is not an issue and more information can be found in commit 741d6f0 as well as the mentioned specifaction section 4.4. MODBUS Addressing model.
The error was just to follow the documentation of the device vendor. So if the vendor is talking about the device is writing to register zero, than my assumption was to that I have to read from register zero and not from one.
For easy of mapping in your mind you can use zero_mode = True
for the slave context and follow the vendor documentation without off-by-one errors in your head.
Actually that parameter is on its way to the graveyard...I am not sure it still works.
From what I have tested yet it works perfectly fine, as it just does the +1 in getValues, setValues and validate of the slave context
Justas it is expected to work!
Versions
Pymodbus Specific
Description
It seems that modbus stores data starting at the wrong address: off-by-error!
Code and Logs
First example: Inspecting the below logged package starting address bytes (0) and compare to the logged setValue address (1).
Second example: starting address should be 2, but logged setValue address is 3 The strange thing here is that the client reports a register count of zero, wh