How to use function code 0x06 to read from register? #2066
-
I have a heatpump where the implementation of Modbus appear somewhat unconvential. Case is that for each register type (function code) the starting address is identical. For function code 0x06: I can write using the function code 0x06 by adding 0x0100 (256) to each register address. I can however not read the content of the registers under function code 0x06, as that requires using the write function to the lower address space and ignoring the write payload and rather take the response values and treat them as if I was using function code 0x03 or 0x04. How could I possibly read those addresses and process the response using the write function 0x06? appreciate anyone with deeper insight in pymodbus. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
There are a lot of devices that do not have shared address space, so you treat the 4 different blocks as individual address spaces. Please see the simulator datastore simulator documentation where this is explained. I am not sure I understand your problem, especially not the mix with write. Seems your device uses a different address to write than to read, that is somewhat very old fashioned, but works....you cannot read the "write address" you read the lower address and write the upper address...when writing the result should be in the lower address (depending on the type of register, e.g. set_temperature, write sets the temperature but read reads the actual temperature. This is not a pymodbus problem, but how to handle your device, and that is something you need to read in the manual of the device. |
Beta Was this translation helpful? Give feedback.
-
And just for the record 0x06 can pr definition not READ...it's a write function. |
Beta Was this translation helpful? Give feedback.
well at least it is not a pymodbus issue….and in HA it is a lot more than just adding a new input_type, it’s tweaking a fair amount of code.
It is probably easier to tweak the read request/response in pymodbus and keep HA unchanged. Or even easier, make a new library that sits between pymodbus and HA that does the tweaking you need…anyhow it is up to you.