Skip to content

Commit ab43cf9

Browse files
DroneCAN add socketcan support, rename to DroneCAN
1 parent 1927f80 commit ab43cf9

File tree

11 files changed

+253
-132
lines changed

11 files changed

+253
-132
lines changed

canutils/libcanardv0/Kconfig

Lines changed: 0 additions & 27 deletions
This file was deleted.

canutils/libcanardv0/Makefile

Lines changed: 0 additions & 71 deletions
This file was deleted.
File renamed without changes.

canutils/libdronecan/Kconfig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 CANUTILS_LIBDRONECAN
7+
bool "libcanard DroneCAN Library"
8+
default n
9+
depends on (CAN && CAN_EXTID) || NET_CAN
10+
---help---
11+
Enable the libcanard DroneCAN library.
12+
13+
if CANUTILS_LIBDRONECAN
14+
15+
config LIBDRONECAN_URL
16+
string "libcanard URL"
17+
default "https://github.com/dronecan/libcanard/archive"
18+
---help---
19+
libcanard URL.
20+
21+
config LIBDRONECAN_VERSION
22+
string "libcanard Version"
23+
default "21f2a73df86886101e254d02cfc2277cd2a15717"
24+
---help---
25+
libcanard version.
26+
27+
config LIBDRONECAN_CANFD
28+
bool "(Experimental) libcanard CAN FD Support"
29+
default n
30+
depends on NET_CAN_CANFD
31+
---help---
32+
libcanard CAN FD support.
33+
Adds support for CAN FD, this is still experimental
34+
since libcanard doesn't support runtime switching
35+
between CAN2.0B and CAN FD that well
36+
37+
endif

canutils/libcanardv0/Make.defs renamed to canutils/libdronecan/Make.defs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# apps/canutils/libcanardv0/Make.defs
2+
# apps/canutils/libdronecan/Make.defs
33
#
44
# Licensed to the Apache Software Foundation (ASF) under one or more
55
# contributor license agreements. See the NOTICE file distributed with
@@ -18,6 +18,6 @@
1818
#
1919
############################################################################
2020

21-
ifneq ($(CONFIG_CANUTILS_LIBCANARDV0),)
22-
CONFIGURED_APPS += $(APPDIR)/canutils/libcanardv0
21+
ifneq ($(CONFIG_CANUTILS_LIBDRONECAN),)
22+
CONFIGURED_APPS += $(APPDIR)/canutils/libdronecan
2323
endif

canutils/libdronecan/Makefile

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
############################################################################
2+
# apps/canutils/libdronecan/Makefile
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
include $(APPDIR)/Make.defs
22+
23+
UNPACK = unzip
24+
PACKEXT = .zip
25+
26+
LIBDRONECAN_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBDRONECAN_URL)))
27+
LIBDRONECAN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBDRONECAN_VERSION)))
28+
LIBDRONECAN_UNPACKNAME = libcanard-$(LIBDRONECAN_VERSION)
29+
LIBDRONECAN_PACKNAME = $(LIBDRONECAN_UNPACKNAME)$(PACKEXT)
30+
LIBDRONECAN_SRCDIR = $(LIBDRONECAN_UNPACKNAME)
31+
LIBDRONECAN_DRVDIR = $(LIBDRONECAN_SRCDIR)$(DELIM)drivers$(DELIM)nuttx
32+
LIBDRONECAN_SOCKETCANDIR = $(LIBDRONECAN_SRCDIR)$(DELIM)drivers$(DELIM)socketcan
33+
34+
APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)canutils
35+
36+
# Conflict with Cyphal's libcanard
37+
ifeq ($(CONFIG_CANUTILS_LIBCANARDV1),y)
38+
APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)canutils$(DELIM)dronecan
39+
CFLAGS += -DcanardInit=dronecanardInit -I$(APPS_INCDIR)
40+
endif
41+
42+
CFLAGS += -std=c99 -DCANARD_ASSERT=DEBUGASSERT
43+
CFLAGS += ${shell $(INCDIR) "$(CC)" $(APPS_INCDIR)}
44+
45+
ifeq ($(CONFIG_LIBDRONECAN_CANFD),y)
46+
CFLAGS += -DCANARD_ENABLE_CANFD=1
47+
endif
48+
49+
CSRCS = $(LIBDRONECAN_SRCDIR)$(DELIM)canard.c
50+
51+
ifeq ($(CONFIG_NET_CAN),y)
52+
CSRCS += $(LIBDRONECAN_SOCKETCANDIR)$(DELIM)socketcan.c
53+
else
54+
CSRCS += $(LIBDRONECAN_DRVDIR)$(DELIM)canard_nuttx.c
55+
endif
56+
57+
$(LIBDRONECAN_PACKNAME):
58+
@echo "Downloading: $@"
59+
$(Q) curl -o $@ -L $(LIBDRONECAN_URL)$(DELIM)$(LIBDRONECAN_VERSION)$(PACKEXT)
60+
61+
$(LIBDRONECAN_UNPACKNAME): $(LIBDRONECAN_PACKNAME)
62+
@echo "Unpacking: $< -> $@"
63+
$(call DELDIR, $@)
64+
$(Q) $(UNPACK) $<
65+
$(Q) touch $@
66+
67+
$(LIBDRONECAN_SRCDIR)$(DELIM)canard.h: $(LIBDRONECAN_UNPACKNAME)
68+
69+
$(LIBDRONECAN_DRVDIR)$(DELIM)canard_nuttx.h: $(LIBDRONECAN_UNPACKNAME)
70+
71+
$(LIBDRONECAN_SOCKETCANDIR)$(DELIM)socketcan.h: $(LIBDRONECAN_UNPACKNAME)
72+
73+
$(APPS_INCDIR)$(DELIM)canard.h: $(LIBDRONECAN_SRCDIR)$(DELIM)canard.h
74+
$(Q) mkdir -p $(APPS_INCDIR)
75+
$(Q) cp $< $@
76+
77+
$(APPS_INCDIR)$(DELIM)canard_nuttx.h: $(LIBDRONECAN_DRVDIR)$(DELIM)canard_nuttx.h
78+
$(Q) cp $< $@
79+
80+
$(APPS_INCDIR)$(DELIM)socketcan.h: $(LIBDRONECAN_SOCKETCANDIR)$(DELIM)socketcan.h
81+
$(Q) cp $< $@
82+
83+
context:: $(APPS_INCDIR)$(DELIM)canard.h $(APPS_INCDIR)$(DELIM)canard_nuttx.h $(APPS_INCDIR)$(DELIM)socketcan.h
84+
85+
clean::
86+
$(foreach OBJ, $(OBJS), $(call DELFILE, $(OBJ)))
87+
88+
distclean::
89+
$(call DELFILE, $(APPS_INCDIR)$(DELIM)canard.h)
90+
$(call DELFILE, $(APPS_INCDIR)$(DELIM)canard_nuttx.h)
91+
$(call DELFILE, $(APPS_INCDIR)$(DELIM)socketcan.h)
92+
$(call DELDIR, $(LIBDRONECAN_UNPACKNAME))
93+
$(call DELFILE, $(LIBDRONECAN_PACKNAME))
94+
95+
include $(APPDIR)/Application.mk

examples/canardv0/Kconfig renamed to examples/dronecan/Kconfig

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,46 @@
33
# see the file kconfig-language.txt in the NuttX tools repository.
44
#
55

6-
config EXAMPLES_LIBCANARDV0
7-
tristate "libcandard v0 example"
6+
config EXAMPLES_DRONECAN
7+
tristate "DroneCAN example"
88
default n
9-
depends on CANUTILS_LIBCANARDV0 && SYSTEM_TIME64
9+
depends on CANUTILS_LIBDRONECAN && SYSTEM_TIME64
1010
---help---
11-
Enable the LIBCANARDV0 example
11+
Enable the LIBDRONECAN example
1212

13-
if EXAMPLES_LIBCANARDV0
13+
if EXAMPLES_DRONECAN
1414

15-
config EXAMPLES_LIBCANARDV0_DEVPATH
15+
config EXAMPLES_DRONECAN_DEVPATH
1616
string "Device Path"
1717
default "/dev/can0"
18+
depends on CAN
1819
---help---
1920
The device path
2021

21-
config EXAMPLES_LIBCANARDV0_NODE_ID
22+
config EXAMPLES_DRONECAN_NODE_ID
2223
int "Node ID"
2324
default 1
2425
range 1 127
2526
---help---
2627
Specifies the node's ID
2728

28-
config EXAMPLES_LIBCANARDV0_APP_NODE_NAME
29+
config EXAMPLES_DRONECAN_APP_NODE_NAME
2930
string "Node name"
30-
default "org.uavcan.libcanard.nuttx.demo"
31+
default "org.dronecan.nuttx.demo"
3132
---help---
3233
app node name
3334

34-
config EXAMPLES_LIBCANARDV0_NODE_MEM_POOL_SIZE
35+
config EXAMPLES_DRONECAN_NODE_MEM_POOL_SIZE
3536
int "Node Memory Pool Size"
3637
default 1024
3738
---help---
3839
Specifies the node's memory pool size
3940

40-
config EXAMPLES_LIBCANARDV0_DAEMON_PRIORITY
41+
config EXAMPLES_DRONECAN_DAEMON_PRIORITY
4142
int "daemon task priority"
4243
default 100
4344

44-
config EXAMPLES_LIBCANARDV0_STACKSIZE
45+
config EXAMPLES_DRONECAN_STACKSIZE
4546
int "canard stack size"
4647
default DEFAULT_TASK_STACKSIZE
4748

examples/canardv0/Make.defs renamed to examples/dronecan/Make.defs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# apps/examples/canardv0/Make.defs
2+
# apps/examples/dronecan/Make.defs
33
#
44
# Licensed to the Apache Software Foundation (ASF) under one or more
55
# contributor license agreements. See the NOTICE file distributed with
@@ -18,6 +18,6 @@
1818
#
1919
############################################################################
2020

21-
ifneq ($(CONFIG_EXAMPLES_LIBCANARDV0),)
22-
CONFIGURED_APPS += $(APPDIR)/examples/canardv0
21+
ifneq ($(CONFIG_EXAMPLES_DRONECAN),)
22+
CONFIGURED_APPS += $(APPDIR)/examples/dronecan
2323
endif

examples/canardv0/Makefile renamed to examples/dronecan/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# apps/examples/canardv0/Makefile
2+
# apps/examples/dronecan/Makefile
33
#
44
# Licensed to the Apache Software Foundation (ASF) under one or more
55
# contributor license agreements. See the NOTICE file distributed with
@@ -20,10 +20,10 @@
2020

2121
include $(APPDIR)/Make.defs
2222

23-
PROGNAME = canardv0
23+
PROGNAME = dronecan
2424
PRIORITY = SCHED_PRIORITY_DEFAULT
25-
STACKSIZE = $(CONFIG_EXAMPLES_LIBCANARDV0_STACKSIZE)
26-
MODULE = $(CONFIG_EXAMPLES_LIBCANARDV0)
25+
STACKSIZE = $(CONFIG_EXAMPLES_DRONECAN_STACKSIZE)
26+
MODULE = $(CONFIG_EXAMPLES_DRONECAN)
2727

2828
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/include/canutils
2929
MAINSRC = canard_main.c

0 commit comments

Comments
 (0)