Skip to content

Commit d6d243c

Browse files
DroneCAN add socketcan support, rename to DroneCAN
1 parent b67b561 commit d6d243c

File tree

10 files changed

+255
-132
lines changed

10 files changed

+255
-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: 13 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,16 @@
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
23+
24+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard
25+
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard
26+
27+
28+
ifeq ($(CONFIG_NET_CAN),y)
29+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard/drivers/socketcan
30+
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard/drivers/socketcan
31+
endif
32+
2333
endif

canutils/libdronecan/Makefile

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}
24+
25+
UNPACK = unzip
26+
PACKEXT = .zip
27+
28+
LIBDRONECAN_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBDRONECAN_URL)))
29+
LIBDRONECAN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBDRONECAN_VERSION)))
30+
31+
LIBDRONECAN_PACKNAME = $(LIBDRONECAN_UNPACKNAME)$(PACKEXT)
32+
LIBDRONECAN_UNPACKNAME = libcanard-$(LIBDRONECAN_VERSION)
33+
LIBDRONECAN_SRCNAME = libcanard
34+
35+
LIBDRONECAN_SRCDIR = $(WD)/$(LIBDRONECAN_SRCNAME)
36+
LIBDRONECAN_DRVDIR = $(LIBDRONECAN_SRCDIR)$(DELIM)drivers$(DELIM)nuttx
37+
LIBDRONECAN_SOCKETCANDIR = $(LIBDRONECAN_SRCDIR)$(DELIM)drivers$(DELIM)socketcan
38+
39+
APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)canutils
40+
41+
# Conflict with Cyphal's libcanard
42+
ifeq ($(CONFIG_CANUTILS_LIBCANARDV1),y)
43+
APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)canutils$(DELIM)dronecan
44+
CFLAGS += -DcanardInit=dronecanardInit -I$(APPS_INCDIR)
45+
endif
46+
47+
CFLAGS += -std=c99 -DCANARD_ASSERT=DEBUGASSERT
48+
CFLAGS += ${shell $(INCDIR) "$(CC)" $(APPS_INCDIR)}
49+
50+
ifeq ($(CONFIG_LIBDRONECAN_CANFD),y)
51+
CFLAGS += -DCANARD_ENABLE_CANFD=1
52+
endif
53+
54+
CSRCS = $(LIBDRONECAN_SRCDIR)$(DELIM)canard.c
55+
56+
ifeq ($(CONFIG_NET_CAN),y)
57+
CSRCS += $(LIBDRONECAN_SOCKETCANDIR)$(DELIM)socketcan.c
58+
else
59+
CSRCS += $(LIBDRONECAN_DRVDIR)$(DELIM)canard_nuttx.c
60+
endif
61+
62+
# Download and unpack tarball if no git repo found
63+
ifeq ($(wildcard $(LIBDRONECAN_SRCNAME)/.git),)
64+
$(LIBDRONECAN_PACKNAME):
65+
@echo "Downloading: $@"
66+
$(Q) curl -o $@ -L $(LIBDRONECAN_URL)$(DELIM)$(LIBDRONECAN_VERSION)$(PACKEXT)
67+
68+
$(LIBDRONECAN_SRCNAME): $(LIBDRONECAN_PACKNAME)
69+
@echo "Unpacking: $< -> $@"
70+
$(call DELDIR, $@)
71+
$(Q) $(UNPACK) $<
72+
$(Q) mv $(LIBDRONECAN_UNPACKNAME) $(LIBDRONECAN_SRCNAME)
73+
$(Q) touch $@
74+
75+
$(LIBDRONECAN_SRCDIR)$(DELIM)canard.c: $(LIBDRONECAN_SRCNAME)
76+
endif
77+
78+
context:: $(LIBDRONECAN_SRCNAME)
79+
80+
clean::
81+
$(foreach OBJ, $(OBJS), $(call DELFILE, $(OBJ)))
82+
83+
distclean::
84+
ifeq ($(wildcard $(LIBDRONECAN_SRCNAME)/.git),)
85+
$(call DELDIR, $(LIBDRONECAN_SRCNAME))
86+
$(call DELFILE, $(LIBDRONECAN_PACKNAME))
87+
endif
88+
89+
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)