Skip to content

Commit 0b2953b

Browse files
DroneCAN add socketcan support, rename to DroneCAN
Rename canardv1 to OpenCyphal Apply suggestions from code review Co-authored-by: Petro Karashchenko <[email protected]>
1 parent b67b561 commit 0b2953b

File tree

22 files changed

+349
-226
lines changed

22 files changed

+349
-226
lines changed

canutils/libcanardv0/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

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.

canutils/libcanardv1/.gitignore

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

canutils/libdronecan/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/libcanard
2+
/*.zip

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 && EXPERIMENTAL
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: 9 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,12 @@
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+
ifeq ($(CONFIG_NET_CAN),y)
25+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard/drivers/socketcan
26+
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard/drivers/socketcan
27+
endif
28+
2329
endif

canutils/libdronecan/Makefile

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
# Conflict with Cyphal's libcanard
40+
ifeq ($(CONFIG_CANUTILS_LIBOPENCYPHAL),y)
41+
CFLAGS += -DcanardInit=dronecanardInit
42+
endif
43+
44+
CFLAGS += -std=c99 -DCANARD_ASSERT=DEBUGASSERT
45+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard
46+
47+
ifeq ($(CONFIG_LIBDRONECAN_CANFD),y)
48+
CFLAGS += -DCANARD_ENABLE_CANFD=1
49+
endif
50+
51+
CSRCS = $(LIBDRONECAN_SRCDIR)$(DELIM)canard.c
52+
53+
ifeq ($(CONFIG_NET_CAN),y)
54+
CSRCS += $(LIBDRONECAN_SOCKETCANDIR)$(DELIM)socketcan.c
55+
else
56+
CSRCS += $(LIBDRONECAN_DRVDIR)$(DELIM)canard_nuttx.c
57+
endif
58+
59+
# Download and unpack tarball if no git repo found
60+
ifeq ($(wildcard $(LIBDRONECAN_SRCNAME)/.git),)
61+
$(LIBDRONECAN_PACKNAME):
62+
@echo "Downloading: $@"
63+
$(Q) curl -o $@ -L $(LIBDRONECAN_URL)$(DELIM)$(LIBDRONECAN_VERSION)$(PACKEXT)
64+
65+
$(LIBDRONECAN_SRCNAME): $(LIBDRONECAN_PACKNAME)
66+
@echo "Unpacking: $< -> $@"
67+
$(call DELDIR, $@)
68+
$(Q) $(UNPACK) $<
69+
$(Q) mv $(LIBDRONECAN_UNPACKNAME) $(LIBDRONECAN_SRCNAME)
70+
$(Q) touch $@
71+
72+
$(LIBDRONECAN_SRCDIR)$(DELIM)canard.c: $(LIBDRONECAN_SRCNAME)
73+
endif
74+
75+
context:: $(LIBDRONECAN_SRCNAME)
76+
77+
distclean::
78+
ifeq ($(wildcard $(LIBDRONECAN_SRCNAME)/.git),)
79+
$(call DELDIR, $(LIBDRONECAN_SRCNAME))
80+
$(call DELFILE, $(LIBDRONECAN_PACKNAME))
81+
endif
82+
83+
include $(APPDIR)/Application.mk

canutils/libopencyphal/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/libcanard
2+
/o1heap
3+
/*.zip

canutils/libcanardv1/Kconfig renamed to canutils/libopencyphal/Kconfig

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

6-
config CANUTILS_LIBCANARDV1
7-
bool "libcanard UAVCAN v1 Library"
6+
config CANUTILS_LIBOPENCYPHAL
7+
bool "libcanard OpenCyphal Cyphal/CAN Library"
88
default n
99
depends on NET_CAN && ALLOW_MIT_COMPONENTS
1010
---help---
11-
Enable the libcanard UAVCAN v1 library.
11+
Enable the OpenCyphal Cyphal/CAN library.
1212

13-
if CANUTILS_LIBCANARDV1
13+
if CANUTILS_LIBOPENCYPHAL
1414

15-
config LIBCANARDV1_URL
15+
config LIBOPENCYPHAL_URL
1616
string "libcanard URL"
17-
default "https://github.com/UAVCAN/libcanard/archive"
17+
default "https://github.com/OpenCyphal/libcanard/archive"
1818
---help---
1919
libcanard URL.
2020

21-
config LIBCANARDV1_VERSION
21+
config LIBOPENCYPHAL_VERSION
2222
string "libcanard Version"
2323
default "cde670347425023480a1417fcd603b27c8eb06c1"
2424
---help---
@@ -28,12 +28,12 @@ config O1HEAP_URL
2828
string "O(1) heap URL"
2929
default "https://github.com/pavel-kirienko/o1heap/archive"
3030
---help---
31-
libcanard URL.
31+
O(1) heap allocator URL.
3232

3333
config O1HEAP_VERSION
3434
string "O(1) heap Version"
3535
default "b21b069e4b971d3016dd232784faca6f7d9fd724"
3636
---help---
37-
libcanard version.
37+
O(1) heap allocator version.
3838

3939
endif

0 commit comments

Comments
 (0)