Enables support for custom function codes. Modbus specification allows
vendor specific function codes in the range 65-72 & 100-110 [1] and this
feature allows users to implement custom logic for those codes.
Additionally, since the Zephyr Modbus stack doesn't implement all defined
Modbus fcs this feature allows users to add support for codes outside the
basic register reading / writing functionality offered by Zephyr.
Custom function codes can be added on a per-interface basis and the handler
structures are allocated by the caller.
[1]: https://modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf
Signed-off-by: Henrik Lindblom <henrik.lindblom@vaisala.com>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.
The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.
NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
add user data for adu callback, which helps in passing
socket and relevant application parameters.
Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Let the core call the modbus_tx_adu() to make
the process more comprehensible.
Move tx-wait-for-rx handling outside of client code.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Prefix internal functions and structs with modbus_.
Use unit_id consistently instead of node_addr.
Fix mbm_ remainder and rename to mbc_.
Rename struct modbus_frame to modbus_adu since
ADU is closer to what the structure represents.
Let the compiler/linker do the job and
remove ifdef around mbc_validate_fc03fp_response().
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>