Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subsys: add MODBUS subsystem #26516

Merged
merged 31 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
270d115
modbus: add MODBUS RTU subsystem
jfischer-no May 29, 2020
1c3c28c
CODEOWNERS: add codeowner for modbus
jfischer-no Mar 15, 2021
db0d22b
tests: add test for MODBUS RTU subsystem
jfischer-no Jun 24, 2020
afbd254
samples: add Modbus RTU server sample
jfischer-no Aug 17, 2020
7251ad4
samples: add Modbus RTU client sample
jfischer-no Aug 27, 2020
7dd18bf
doc: add Modbus RTU documentation
jfischer-no Jun 20, 2020
8721db7
modbus: add control for DE/nRE RS-485 transceiver signals
jfischer-no Dec 22, 2020
47c99ae
modbus: add DE/nRE gpios properties to samples and test
jfischer-no Dec 22, 2020
ec59d02
modbus: get interface index according to interface name
jfischer-no Dec 28, 2020
256ff7e
modbus: fix ASCII frame reception and add test for ASCII mode
jfischer-no Dec 28, 2020
e941c2c
modbus: reset buffer after reception
jfischer-no Feb 10, 2021
8becbb3
modbus: rename MODBUS RTU API to common MODBUS API
jfischer-no Mar 2, 2021
86879c9
modbus: remove RTU from configuration and headers
jfischer-no Mar 2, 2021
38f8315
modbus: rename mb_rtu_ to modbus_
jfischer-no Mar 2, 2021
51151f0
tests: modbus: remove _rtu_ from modbus test
jfischer-no Mar 2, 2021
5c015f0
modbus: use enum for MODBUS mode
jfischer-no Mar 1, 2021
87f748b
modbus: move MODBUS over serial line code to own file
jfischer-no Mar 3, 2021
d2eaf59
modbus: move serial line config outside context
jfischer-no Mar 3, 2021
d157027
modbus: make MODBUS support over serial line optional
jfischer-no Mar 3, 2021
0b99009
modbus: rename internal designations and do few minor fixups
jfischer-no Mar 3, 2021
766d36f
modbus: move some RX/TX ADU related code to the core
jfischer-no Mar 9, 2021
7752b88
modbus: return ETIMEDOUT on timeout instead of EIO
jfischer-no Mar 10, 2021
87d50a4
modbus: document return values of internal functions
jfischer-no Mar 10, 2021
828e468
modbus: rework interface configuration
jfischer-no Mar 10, 2021
2290543
modbus: add raw ADU support
jfischer-no Mar 10, 2021
bd6f51f
tests: modbus: add raw ADU support test
jfischer-no Mar 10, 2021
dc60733
samples: add MODBUS TCP server sample
jfischer-no Mar 10, 2021
6424f1e
samples: modbus: add TCP to serial line gateway
jfischer-no Mar 10, 2021
876a064
doc: modbus: update description and add TCP sample references
jfischer-no Mar 11, 2021
cb066a8
samples: rtu_server: rework LED configuration
jfischer-no Mar 17, 2021
cda8c30
modbus: rework RS-485 transceiver DE,RE GPIO configuration
jfischer-no Mar 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
/subsys/mgmt/mcumgr/smp_udp.c @aunsbjerg
/subsys/mgmt/updatehub/ @nandojve @otavio
/subsys/mgmt/osdp/ @cbsiddharth
/subsys/modbus/ @jfischer-no
/subsys/net/buf.c @jukkar @jhedberg @tbursztyka @pfalcon
/subsys/net/ip/ @jukkar @tbursztyka @pfalcon
/subsys/net/lib/ @jukkar @tbursztyka @pfalcon
Expand Down
1 change: 1 addition & 0 deletions doc/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ API Reference
logging/index.rst
misc/index
misc/data_structures.rst
modbus/index.rst
networking/index.rst
peripherals/index.rst
power_management/index.rst
Expand Down
9 changes: 9 additions & 0 deletions doc/reference/modbus/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. _modbus:

MODBUS
######

.. toctree::
:maxdepth: 2

modbus.rst
43 changes: 43 additions & 0 deletions doc/reference/modbus/modbus.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.. _modbus_api:

MODBUS
######

Modbus is an industrial messaging protocol. The protocol is specified
for different types of networks or buses. Zephyr OS implementation
supports communication over serial line and may be used
with different physical interfaces, like RS485 or RS232.
TCP support is not implemented directly, but there are helper functions
to realize TCP support according to the application's needs.

Modbus communication is based on client/server model.
Only one client may be present on the bus. Client can communicate with several
server devices. Server devices themselves are passive and must not send
requests or unsolicited responses.
Services requested by the client are specified by function codes (FCxx),
and can be found in the specification or documentation of the API below.

Zephyr RTOS implementation supports both client and server roles.

More information about Modbus and Modbus RTU can be found on the website
`MODBUS Protocol Specifications`_.

Samples
*******

`modbus-rtu-server-sample` and `modbus-rtu-client-sample` give
the possibility to try out RTU server and RTU client implementation with
an evaluation board.

`modbus-tcp-server-sample` is a simple Modbus TCP server.

`modbus-gateway-sample` is an example how to build a TCP to serial line
gateway with Zephyr OS.

API Reference
*************

.. doxygengroup:: modbus
:project: Zephyr

.. _`MODBUS Protocol Specifications`: https://www.modbus.org/specs.php
27 changes: 27 additions & 0 deletions dts/bindings/misc/zephyr,modbus-serial.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2020 PHYTEC Messtechnik GmbH
# SPDX-License-Identifier: Apache-2.0

description: Modbus over serial line device

compatible: "zephyr,modbus-serial"

include: uart-device.yaml

properties:
de-gpios:
type: phandle-array
required: false
description: Driver enable pin.

Driver enable pin (DE) of the RS-485 transceiver.
If connected directly the MCU pin should be configured
as active high.
Comment on lines +17 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be confusing, as in both provided overlays this signal is actually active low. Perhaps this sentence could be dropped. Similarly in the RE case. For the same reason, "nRE" and "DE" markings in descriptions could be dropped as well. I don't think they actually bring much value.


re-gpios:
type: phandle-array
required: false
description: Receiver enable pin.

Receiver enable pin (nRE) of the RS-485 transceiver.
If connected directly the MCU pin should be configured
as active low.
Loading