Modbus Controller (as Server): Support for Default Values in Unused Modbus Registers #3215
Unanswered
carlessole
asked this question in
Component enhancements
Replies: 1 comment
-
🏷️ I've automatically added the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Component name
Modbus Controller
Link to component documentation on our website
https://esphome.io/components/modbus_controller.html
Describe the enhancement
Sometimes, in a Modbus Server Device, its Modbus Map includes empty or unused registers reserved for future use.
For example, a device may expose data at the following addresses:
0–6
: Device info and configuration10–13
: Temperature data20–28
: Humidity dataSince a
Read Holding/Input Registers
request can span up to 125 registers in a single transaction (see Modbus spec - Function 0x03), some Modbus clients may attempt to read large blocks of contiguous addresses to reduce the requests amount.On this scenario, if a client sends a request like:
ESPHome responds with Exception Code
0x02
(Illegal Data Address), since some of the requested registers are not defined.The behavior is correct, but can limit interoperability with clients that expect to read blocks of data that may include gaps.
Proposed Solution
Introduce an optional configuration in the Modbus controller to define a default value for undefined registers up to a given address.
With this configuration, any Read Holding/Input Registers request for addresses <= max_reg_address_with_default_value will be accepted, and undefined registers within that range will return the specified default value (e.g., 0).
Use cases
Since a
Read Holding/Input Registers
request can span up to 125 registers in a single transaction (see Modbus spec - Function 0x03), some Modbus clients may attempt to read large blocks of contiguous addresses to reduce the requests amount.On this scenario, if a client sends a request like:
ESPHome responds with Exception Code
0x02
(Illegal Data Address), since some of the requested registers are not defined.The behavior is correct, but can limit interoperability with clients that expect to read blocks of data that may include gaps.
Anything else?
No response
Beta Was this translation helpful? Give feedback.
All reactions