Skip to content

Commit de1f5f1

Browse files
committed
modbus: add nxmodbus
NxModbus is a lightweight Modbus protocol stack implementation for NuttX RTOS. This commit adds: - nxmodbus stack - nxmbserver - Modbus Server (Slave) example - nxmbclient - Modbus Client (Master) tool Supported Modbus transports: - ASCII - RTU over serial port - TCP - RAW (ADU) for custom transport implementations Signed-off-by: raiden00pl <[email protected]>
1 parent 722f319 commit de1f5f1

36 files changed

Lines changed: 8056 additions & 0 deletions

examples/nxmbserver/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ##############################################################################
2+
# apps/examples/nxmbserver/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_EXAMPLES_NXMBSERVER)
24+
nuttx_add_application(
25+
NAME
26+
${CONFIG_EXAMPLES_NXMBSERVER_PROGNAME}
27+
PRIORITY
28+
${CONFIG_EXAMPLES_NXMBSERVER_PRIORITY}
29+
STACKSIZE
30+
${CONFIG_EXAMPLES_NXMBSERVER_STACKSIZE}
31+
MODULE
32+
${CONFIG_EXAMPLES_NXMBSERVER}
33+
SRCS
34+
nxmbserver_main.c)
35+
endif()

examples/nxmbserver/Kconfig

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config EXAMPLES_NXMBSERVER
7+
tristate "NxModbus Server Example"
8+
default n
9+
depends on NXMODBUS
10+
---help---
11+
Enable the NxModbus server example. This example demonstrates
12+
how to create a Modbus server (slave) that responds to client
13+
requests. Supports RTU, ASCII, and TCP transports with simulated
14+
register data.
15+
16+
if EXAMPLES_NXMBSERVER
17+
18+
config EXAMPLES_NXMBSERVER_PROGNAME
19+
string "Program name"
20+
default "nxmbserver"
21+
---help---
22+
This is the name of the program that will be used when the NSH ELF
23+
program is installed.
24+
25+
config EXAMPLES_NXMBSERVER_PRIORITY
26+
int "NxModbus server task priority"
27+
default 100
28+
29+
config EXAMPLES_NXMBSERVER_STACKSIZE
30+
int "NxModbus server stack size"
31+
default DEFAULT_TASK_STACKSIZE
32+
33+
endif # EXAMPLES_NXMBSERVER

examples/nxmbserver/Make.defs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/examples/nxmbserver/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_EXAMPLES_NXMBSERVER),)
24+
CONFIGURED_APPS += $(APPDIR)/examples/nxmbserver
25+
endif

examples/nxmbserver/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
############################################################################
2+
# apps/examples/nxmbserver/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
MAINSRC = nxmbserver_main.c
26+
27+
PROGNAME = $(CONFIG_EXAMPLES_NXMBSERVER_PROGNAME)
28+
PRIORITY = $(CONFIG_EXAMPLES_NXMBSERVER_PRIORITY)
29+
STACKSIZE = $(CONFIG_EXAMPLES_NXMBSERVER_STACKSIZE)
30+
MODULE = $(CONFIG_EXAMPLES_NXMBSERVER)
31+
32+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)