Skip to content

Commit 722f319

Browse files
raiden00pljerpelea
authored andcommitted
modbus: move freemodbus to a separate directory
move freemodbus to modbus/freemodbus so it is possible to add other modbus implementations Signed-off-by: raiden00pl <raiden00@railab.me>
1 parent f22a8d0 commit 722f319

45 files changed

Lines changed: 187 additions & 113 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modbus/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Kconfig

modbus/CMakeLists.txt

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -20,82 +20,6 @@
2020
#
2121
# ##############################################################################
2222

23-
if(CONFIG_MODBUS)
23+
nuttx_add_subdirectory()
2424

25-
set(CSRCS)
26-
27-
if(CONFIG_MODBUS_SLAVE)
28-
list(APPEND CSRCS mb.c)
29-
endif()
30-
31-
if(CONFIG_MB_RTU_MASTER)
32-
list(APPEND CSRCS mb_m.c)
33-
endif()
34-
35-
# ascii/Make.defs
36-
37-
if(CONFIG_MB_ASCII_ENABLED)
38-
list(APPEND CSRCS ascii/mbascii.c)
39-
endif()
40-
41-
# functions/Make.defs
42-
43-
list(
44-
APPEND
45-
CSRCS
46-
functions/mbfunccoils.c
47-
functions/mbfuncdiag.c
48-
functions/mbfuncdisc.c
49-
functions/mbfuncholding.c
50-
functions/mbfuncinput.c
51-
functions/mbfuncother.c
52-
functions/mbutils.c)
53-
54-
if(CONFIG_MB_ASCII_MASTER)
55-
list(APPEND CSRCS functions/mbfunccoils_m.c functions/mbfuncdisc_m.c
56-
functions/mbfuncholding_m.c functions/mbfuncinput_m.c)
57-
elseif(CONFIG_MB_RTU_MASTER)
58-
list(APPEND CSRCS functions/mbfunccoils_m.c functions/mbfuncdisc_m.c
59-
functions/mbfuncholding_m.c functions/mbfuncinput_m.c)
60-
endif()
61-
62-
# nuttx/Make.defs
63-
64-
list(APPEND CSRCS nuttx/portother.c)
65-
66-
if(CONFIG_MODBUS_SLAVE)
67-
list(APPEND CSRCS nuttx/portevent.c nuttx/portserial.c nuttx/porttimer.c)
68-
endif()
69-
70-
if(CONFIG_MB_RTU_MASTER)
71-
list(APPEND CSRCS nuttx/portother_m.c nuttx/portserial_m.c
72-
nuttx/porttimer_m.c nuttx/portevent_m.c)
73-
endif()
74-
75-
# rtu/Make.defs
76-
77-
if(CONFIG_MB_RTU_ENABLED OR CONFIG_MB_RTU_MASTER)
78-
list(APPEND CSRCS rtu/mbcrc.c)
79-
if(CONFIG_MB_RTU_ENABLED)
80-
list(APPEND CSRCS rtu/mbrtu.c)
81-
endif()
82-
83-
if(CONFIG_MB_RTU_MASTER)
84-
list(APPEND CSRCS rtu/mbrtu_m.c)
85-
endif()
86-
endif()
87-
88-
# tcp/Make.defs
89-
90-
if(CONFIG_MB_TCP_ENABLED)
91-
list(APPEND CSRCS tcp/mbtcp.c)
92-
endif()
93-
94-
# include private headers
95-
96-
target_include_directories(apps PRIVATE nuttx)
97-
target_include_directories(apps PRIVATE rtu)
98-
99-
target_sources(apps PRIVATE ${CSRCS})
100-
101-
endif()
25+
nuttx_generate_kconfig(MENUDESC "Modbus")

modbus/Make.defs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,4 @@
2020
#
2121
############################################################################
2222

23-
ifneq ($(CONFIG_MODBUS),)
24-
CONFIGURED_APPS += $(APPDIR)/modbus
25-
endif
23+
include $(wildcard $(APPDIR)/modbus/*/Make.defs)

modbus/Makefile

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,6 @@
2020
#
2121
############################################################################
2222

23-
include $(APPDIR)/Make.defs
23+
MENUDESC = "Modbus"
2424

25-
# FreeModBus Library
26-
27-
ifeq ($(CONFIG_MODBUS),y)
28-
29-
ifeq ($(CONFIG_MODBUS_SLAVE),y)
30-
CSRCS += mb.c
31-
endif
32-
33-
ifeq ($(CONFIG_MB_RTU_MASTER),y)
34-
CSRCS += mb_m.c
35-
endif
36-
37-
include ascii/Make.defs
38-
include functions/Make.defs
39-
include nuttx/Make.defs
40-
include rtu/Make.defs
41-
include tcp/Make.defs
42-
43-
endif
44-
45-
include $(APPDIR)/Application.mk
25+
include $(APPDIR)/Directory.mk

modbus/freemodbus/CMakeLists.txt

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# ##############################################################################
2+
# apps/modbus/freemodbus/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_MODBUS)
24+
25+
set(CSRCS)
26+
27+
if(CONFIG_MODBUS_SLAVE)
28+
list(APPEND CSRCS mb.c)
29+
endif()
30+
31+
if(CONFIG_MB_RTU_MASTER)
32+
list(APPEND CSRCS mb_m.c)
33+
endif()
34+
35+
# ascii/Make.defs
36+
37+
if(CONFIG_MB_ASCII_ENABLED)
38+
list(APPEND CSRCS ascii/mbascii.c)
39+
endif()
40+
41+
# functions/Make.defs
42+
43+
list(
44+
APPEND
45+
CSRCS
46+
functions/mbfunccoils.c
47+
functions/mbfuncdiag.c
48+
functions/mbfuncdisc.c
49+
functions/mbfuncholding.c
50+
functions/mbfuncinput.c
51+
functions/mbfuncother.c
52+
functions/mbutils.c)
53+
54+
if(CONFIG_MB_ASCII_MASTER)
55+
list(APPEND CSRCS functions/mbfunccoils_m.c functions/mbfuncdisc_m.c
56+
functions/mbfuncholding_m.c functions/mbfuncinput_m.c)
57+
elseif(CONFIG_MB_RTU_MASTER)
58+
list(APPEND CSRCS functions/mbfunccoils_m.c functions/mbfuncdisc_m.c
59+
functions/mbfuncholding_m.c functions/mbfuncinput_m.c)
60+
endif()
61+
62+
# nuttx/Make.defs
63+
64+
list(APPEND CSRCS nuttx/portother.c)
65+
66+
if(CONFIG_MODBUS_SLAVE)
67+
list(APPEND CSRCS nuttx/portevent.c nuttx/portserial.c nuttx/porttimer.c)
68+
endif()
69+
70+
if(CONFIG_MB_RTU_MASTER)
71+
list(APPEND CSRCS nuttx/portother_m.c nuttx/portserial_m.c
72+
nuttx/porttimer_m.c nuttx/portevent_m.c)
73+
endif()
74+
75+
# rtu/Make.defs
76+
77+
if(CONFIG_MB_RTU_ENABLED OR CONFIG_MB_RTU_MASTER)
78+
list(APPEND CSRCS rtu/mbcrc.c)
79+
if(CONFIG_MB_RTU_ENABLED)
80+
list(APPEND CSRCS rtu/mbrtu.c)
81+
endif()
82+
83+
if(CONFIG_MB_RTU_MASTER)
84+
list(APPEND CSRCS rtu/mbrtu_m.c)
85+
endif()
86+
endif()
87+
88+
# tcp/Make.defs
89+
90+
if(CONFIG_MB_TCP_ENABLED)
91+
list(APPEND CSRCS tcp/mbtcp.c)
92+
endif()
93+
94+
# include private headers
95+
96+
target_include_directories(apps PRIVATE nuttx)
97+
target_include_directories(apps PRIVATE rtu)
98+
99+
target_sources(apps PRIVATE ${CSRCS})
100+
101+
endif()

modbus/freemodbus/Make.defs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/modbus/freemodbus/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_MODBUS),)
24+
CONFIGURED_APPS += $(APPDIR)/modbus/freemodbus
25+
endif

modbus/freemodbus/Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
############################################################################
2+
# apps/modbus/freemodbus/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+
# FreeModBus Library
26+
27+
ifeq ($(CONFIG_MODBUS),y)
28+
29+
ifeq ($(CONFIG_MODBUS_SLAVE),y)
30+
CSRCS += mb.c
31+
endif
32+
33+
ifeq ($(CONFIG_MB_RTU_MASTER),y)
34+
CSRCS += mb_m.c
35+
endif
36+
37+
include ascii/Make.defs
38+
include functions/Make.defs
39+
include nuttx/Make.defs
40+
include rtu/Make.defs
41+
include tcp/Make.defs
42+
43+
endif
44+
45+
include $(APPDIR)/Application.mk
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# apps/modbus/ascii/Make.defs
2+
# apps/modbus/freemodbus/ascii/Make.defs
33
#
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -26,6 +26,6 @@ CSRCS += mbascii.c
2626

2727
DEPPATH += --dep-path ascii
2828
VPATH += :ascii
29-
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/modbus/ascii
29+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/modbus/freemodbus/ascii
3030

3131
endif

0 commit comments

Comments
 (0)