How to avoid common variables in HR and IR registers?
LiquidOcelot29 opened this issue · 1 comments
Hi
I've managed to run my Pico with that code. And it working well. But I want to ask for some help, because I've got device, that communicates by modbus RTU. And it's communication is some weird, because this device is a master. This device is still trying to read an Input Registers from a slave with an id of 1. The registers it reads are 1, 2 and 10. IR1 should have a fixed value of "2", IR2 should have a value of "5" and IR10 should have a value of "0". I have managed to establish that if a device with id 1 is connected, it starts transmitting (overwriting with function 0x10) the Holding Registers variables from address 0 to 20, and which I need for my HA.
I decided to use the Pico as a Modbus slave device using both UARTs for that. I noticed that by using the 0x10 function for a register, for example HR1 and writing some value (e.g. "123") this value rewrites itself to IR. Then all communication switchs off because the IR registers do not have the values required by the master to transmit data.
In summary, I would like to know:
- how to set and fix IR1, 2, 10 permanently with initial values (2, 5 and 0)
- how to avoid IR registers being overwritten by function 0x10
I hope I have explained exactly what I mean and what I have problems with. If there is something I don't understand, I will try to put it more simply.
Hi,
I don't quite understand what you need. However, this library is quite minimalist, the address space is shared among coils, inputs, and holding registers. To avoid overwriting coils or registers the master needs to write to different memory ranges.
For example, coils from address 0 to15 share the same memory space of the holding register at address 0, coils from address 16 to 31 share the same memory space of the holding register at address 1, son on and so forth.
Also, protecting specific memory addresses from being written is not part of the Modbus standard, so not supported.