From fa26bab6b24626a47af8886aaf518df1d00ce9ba Mon Sep 17 00:00:00 2001 From: Peter van der Perk Date: Tue, 31 Jan 2023 16:35:23 +0100 Subject: [PATCH] DroneCAN add socketcan support, rename to DroneCAN Rename canardv1 to OpenCyphal Apply suggestions from code review Co-authored-by: Petro Karashchenko --- canutils/libcanardv0/.gitignore | 1 - canutils/libcanardv0/Kconfig | 27 ---- canutils/libcanardv0/Makefile | 71 ----------- canutils/libcanardv1/.gitignore | 2 - canutils/libdronecan/.gitignore | 2 + canutils/libdronecan/Kconfig | 37 ++++++ .../{libcanardv0 => libdronecan}/Make.defs | 12 +- canutils/libdronecan/Makefile | 83 +++++++++++++ canutils/libopencyphal/.gitignore | 3 + .../{libcanardv1 => libopencyphal}/Kconfig | 18 +-- .../{libcanardv1 => libopencyphal}/Make.defs | 10 +- .../{libcanardv1 => libopencyphal}/Makefile | 79 ++++++------ examples/{canardv0 => dronecan}/Kconfig | 25 ++-- examples/{canardv0 => dronecan}/Make.defs | 6 +- examples/{canardv0 => dronecan}/Makefile | 17 ++- examples/{canardv0 => dronecan}/canard_main.c | 115 +++++++++++++++--- examples/{canardv1 => opencyphal}/Kconfig | 24 ++-- examples/{canardv1 => opencyphal}/Make.defs | 6 +- examples/{canardv1 => opencyphal}/Makefile | 13 +- .../{canardv1 => opencyphal}/canard_main.c | 20 +-- examples/{canardv1 => opencyphal}/socketcan.c | 2 +- examples/{canardv1 => opencyphal}/socketcan.h | 2 +- 22 files changed, 349 insertions(+), 226 deletions(-) delete mode 100644 canutils/libcanardv0/.gitignore delete mode 100644 canutils/libcanardv0/Kconfig delete mode 100644 canutils/libcanardv0/Makefile delete mode 100644 canutils/libcanardv1/.gitignore create mode 100644 canutils/libdronecan/.gitignore create mode 100644 canutils/libdronecan/Kconfig rename canutils/{libcanardv0 => libdronecan}/Make.defs (73%) create mode 100644 canutils/libdronecan/Makefile create mode 100644 canutils/libopencyphal/.gitignore rename canutils/{libcanardv1 => libopencyphal}/Kconfig (65%) rename canutils/{libcanardv1 => libopencyphal}/Make.defs (76%) rename canutils/{libcanardv1 => libopencyphal}/Makefile (50%) rename examples/{canardv0 => dronecan}/Kconfig (55%) rename examples/{canardv0 => dronecan}/Make.defs (88%) rename examples/{canardv0 => dronecan}/Makefile (71%) rename examples/{canardv0 => dronecan}/canard_main.c (83%) rename examples/{canardv1 => opencyphal}/Kconfig (54%) rename examples/{canardv1 => opencyphal}/Make.defs (88%) rename examples/{canardv1 => opencyphal}/Makefile (75%) rename examples/{canardv1 => opencyphal}/canard_main.c (95%) rename examples/{canardv1 => opencyphal}/socketcan.c (99%) rename examples/{canardv1 => opencyphal}/socketcan.h (98%) diff --git a/canutils/libcanardv0/.gitignore b/canutils/libcanardv0/.gitignore deleted file mode 100644 index ab82ca37f..000000000 --- a/canutils/libcanardv0/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/libcanard-* diff --git a/canutils/libcanardv0/Kconfig b/canutils/libcanardv0/Kconfig deleted file mode 100644 index db32d813b..000000000 --- a/canutils/libcanardv0/Kconfig +++ /dev/null @@ -1,27 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -config CANUTILS_LIBCANARDV0 - bool "libcanard UAVCAN v0 Library" - default n - depends on CAN && CAN_EXTID - ---help--- - Enable the libcanard UAVCAN v0 library. - -if CANUTILS_LIBCANARDV0 - -config LIBCANARDV0_URL - string "libcanard URL" - default "https://github.com/UAVCAN/libcanard/archive" - ---help--- - libcanard URL. - -config LIBCANARDV0_VERSION - string "libcanard Version" - default "5ad65c6a4efda60cda7a8f0512da0f465822bbb8" - ---help--- - libcanard version. - -endif diff --git a/canutils/libcanardv0/Makefile b/canutils/libcanardv0/Makefile deleted file mode 100644 index e708e1208..000000000 --- a/canutils/libcanardv0/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -############################################################################ -# apps/canutils/libcanardv0/Makefile -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. The -# ASF licenses this file to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -############################################################################ - -include $(APPDIR)/Make.defs - -UNPACK = unzip -PACKEXT = .zip - -LIBCANARDV0_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV0_URL))) -LIBCANARDV0_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV0_VERSION))) -LIBCANARDV0_UNPACKNAME = libcanard-$(LIBCANARDV0_VERSION) -LIBCANARDV0_PACKNAME = $(LIBCANARDV0_UNPACKNAME)$(PACKEXT) -LIBCANARDV0_SRCDIR = $(LIBCANARDV0_UNPACKNAME) -LIBCANARDV0_DRVDIR = $(LIBCANARDV0_SRCDIR)$(DELIM)drivers$(DELIM)nuttx - -APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)canutils - -CFLAGS += -std=c99 -DCANARD_ASSERT=DEBUGASSERT -CFLAGS += ${INCDIR_PREFIX}$(APPS_INCDIR) - -CSRCS = $(LIBCANARDV0_SRCDIR)$(DELIM)canard.c $(LIBCANARDV0_DRVDIR)$(DELIM)canard_nuttx.c - -$(LIBCANARDV0_PACKNAME): - @echo "Downloading: $@" - $(Q) curl -o $@ -L $(LIBCANARDV0_URL)$(DELIM)$(LIBCANARDV0_VERSION)$(PACKEXT) - -$(LIBCANARDV0_UNPACKNAME): $(LIBCANARDV0_PACKNAME) - @echo "Unpacking: $< -> $@" - $(call DELDIR, $@) - $(Q) $(UNPACK) $< - $(Q) touch $@ - -$(LIBCANARDV0_SRCDIR)$(DELIM)canard.h: $(LIBCANARDV0_UNPACKNAME) - -$(LIBCANARDV0_DRVDIR)$(DELIM)canard_nuttx.h: $(LIBCANARDV0_UNPACKNAME) - -$(APPS_INCDIR)$(DELIM)canard.h: $(LIBCANARDV0_SRCDIR)$(DELIM)canard.h - $(Q) cp $< $@ - -$(APPS_INCDIR)$(DELIM)canard_nuttx.h: $(LIBCANARDV0_DRVDIR)$(DELIM)canard_nuttx.h - $(Q) cp $< $@ - -context:: $(APPS_INCDIR)$(DELIM)canard.h $(APPS_INCDIR)$(DELIM)canard_nuttx.h - -clean:: - $(foreach OBJ, $(OBJS), $(call DELFILE, $(OBJ))) - -distclean:: - $(call DELFILE, $(APPS_INCDIR)$(DELIM)canard.h) - $(call DELFILE, $(APPS_INCDIR)$(DELIM)canard_nuttx.h) - $(call DELDIR, $(LIBCANARDV0_UNPACKNAME)) - $(call DELFILE, $(LIBCANARDV0_PACKNAME)) - -include $(APPDIR)/Application.mk diff --git a/canutils/libcanardv1/.gitignore b/canutils/libcanardv1/.gitignore deleted file mode 100644 index 19287278b..000000000 --- a/canutils/libcanardv1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/libcanard-* -/o1heap-* diff --git a/canutils/libdronecan/.gitignore b/canutils/libdronecan/.gitignore new file mode 100644 index 000000000..03f1063a6 --- /dev/null +++ b/canutils/libdronecan/.gitignore @@ -0,0 +1,2 @@ +/libcanard +/*.zip diff --git a/canutils/libdronecan/Kconfig b/canutils/libdronecan/Kconfig new file mode 100644 index 000000000..6419d198d --- /dev/null +++ b/canutils/libdronecan/Kconfig @@ -0,0 +1,37 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config CANUTILS_LIBDRONECAN + bool "libcanard DroneCAN Library" + default n + depends on (CAN && CAN_EXTID) || NET_CAN + ---help--- + Enable the libcanard DroneCAN library. + +if CANUTILS_LIBDRONECAN + +config LIBDRONECAN_URL + string "libcanard URL" + default "https://github.com/dronecan/libcanard/archive" + ---help--- + libcanard URL. + +config LIBDRONECAN_VERSION + string "libcanard Version" + default "21f2a73df86886101e254d02cfc2277cd2a15717" + ---help--- + libcanard version. + +config LIBDRONECAN_CANFD + bool "(Experimental) libcanard CAN FD Support" + default n + depends on NET_CAN_CANFD && EXPERIMENTAL + ---help--- + libcanard CAN FD support. + Adds support for CAN FD, this is still experimental + since libcanard doesn't support runtime switching + between CAN2.0B and CAN FD that well + +endif diff --git a/canutils/libcanardv0/Make.defs b/canutils/libdronecan/Make.defs similarity index 73% rename from canutils/libcanardv0/Make.defs rename to canutils/libdronecan/Make.defs index 478faac38..ad0ea54bb 100644 --- a/canutils/libcanardv0/Make.defs +++ b/canutils/libdronecan/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# apps/canutils/libcanardv0/Make.defs +# apps/canutils/libdronecan/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -18,6 +18,12 @@ # ############################################################################ -ifneq ($(CONFIG_CANUTILS_LIBCANARDV0),) -CONFIGURED_APPS += $(APPDIR)/canutils/libcanardv0 +ifneq ($(CONFIG_CANUTILS_LIBDRONECAN),) +CONFIGURED_APPS += $(APPDIR)/canutils/libdronecan + +ifeq ($(CONFIG_NET_CAN),y) +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard/drivers/socketcan +CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard/drivers/socketcan +endif + endif diff --git a/canutils/libdronecan/Makefile b/canutils/libdronecan/Makefile new file mode 100644 index 000000000..7606ac4a3 --- /dev/null +++ b/canutils/libdronecan/Makefile @@ -0,0 +1,83 @@ +############################################################################ +# apps/canutils/libdronecan/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'} + +UNPACK = unzip +PACKEXT = .zip + +LIBDRONECAN_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBDRONECAN_URL))) +LIBDRONECAN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBDRONECAN_VERSION))) + +LIBDRONECAN_PACKNAME = $(LIBDRONECAN_UNPACKNAME)$(PACKEXT) +LIBDRONECAN_UNPACKNAME = libcanard-$(LIBDRONECAN_VERSION) +LIBDRONECAN_SRCNAME = libcanard + +LIBDRONECAN_SRCDIR = $(WD)/$(LIBDRONECAN_SRCNAME) +LIBDRONECAN_DRVDIR = $(LIBDRONECAN_SRCDIR)$(DELIM)drivers$(DELIM)nuttx +LIBDRONECAN_SOCKETCANDIR = $(LIBDRONECAN_SRCDIR)$(DELIM)drivers$(DELIM)socketcan + +# Conflict with Cyphal's libcanard +ifeq ($(CONFIG_CANUTILS_LIBOPENCYPHAL),y) +CFLAGS += -DcanardInit=dronecanardInit +endif + +CFLAGS += -std=c99 -DCANARD_ASSERT=DEBUGASSERT +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard + +ifeq ($(CONFIG_LIBDRONECAN_CANFD),y) +CFLAGS += -DCANARD_ENABLE_CANFD=1 +endif + +CSRCS = $(LIBDRONECAN_SRCDIR)$(DELIM)canard.c + +ifeq ($(CONFIG_NET_CAN),y) +CSRCS += $(LIBDRONECAN_SOCKETCANDIR)$(DELIM)socketcan.c +else +CSRCS += $(LIBDRONECAN_DRVDIR)$(DELIM)canard_nuttx.c +endif + +# Download and unpack tarball if no git repo found +ifeq ($(wildcard $(LIBDRONECAN_SRCNAME)/.git),) +$(LIBDRONECAN_PACKNAME): + @echo "Downloading: $@" + $(Q) curl -o $@ -L $(LIBDRONECAN_URL)$(DELIM)$(LIBDRONECAN_VERSION)$(PACKEXT) + +$(LIBDRONECAN_SRCNAME): $(LIBDRONECAN_PACKNAME) + @echo "Unpacking: $< -> $@" + $(call DELDIR, $@) + $(Q) $(UNPACK) $< + $(Q) mv $(LIBDRONECAN_UNPACKNAME) $(LIBDRONECAN_SRCNAME) + $(Q) touch $@ + +$(LIBDRONECAN_SRCDIR)$(DELIM)canard.c: $(LIBDRONECAN_SRCNAME) +endif + +context:: $(LIBDRONECAN_SRCNAME) + +distclean:: +ifeq ($(wildcard $(LIBDRONECAN_SRCNAME)/.git),) + $(call DELDIR, $(LIBDRONECAN_SRCNAME)) + $(call DELFILE, $(LIBDRONECAN_PACKNAME)) +endif + +include $(APPDIR)/Application.mk diff --git a/canutils/libopencyphal/.gitignore b/canutils/libopencyphal/.gitignore new file mode 100644 index 000000000..aeac8afe8 --- /dev/null +++ b/canutils/libopencyphal/.gitignore @@ -0,0 +1,3 @@ +/libcanard +/o1heap +/*.zip diff --git a/canutils/libcanardv1/Kconfig b/canutils/libopencyphal/Kconfig similarity index 65% rename from canutils/libcanardv1/Kconfig rename to canutils/libopencyphal/Kconfig index 70d58c648..77c9a875c 100644 --- a/canutils/libcanardv1/Kconfig +++ b/canutils/libopencyphal/Kconfig @@ -3,22 +3,22 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -config CANUTILS_LIBCANARDV1 - bool "libcanard UAVCAN v1 Library" +config CANUTILS_LIBOPENCYPHAL + bool "libcanard OpenCyphal Cyphal/CAN Library" default n depends on NET_CAN && ALLOW_MIT_COMPONENTS ---help--- - Enable the libcanard UAVCAN v1 library. + Enable the OpenCyphal Cyphal/CAN library. -if CANUTILS_LIBCANARDV1 +if CANUTILS_LIBOPENCYPHAL -config LIBCANARDV1_URL +config LIBOPENCYPHAL_URL string "libcanard URL" - default "https://github.com/UAVCAN/libcanard/archive" + default "https://github.com/OpenCyphal/libcanard/archive" ---help--- libcanard URL. -config LIBCANARDV1_VERSION +config LIBOPENCYPHAL_VERSION string "libcanard Version" default "cde670347425023480a1417fcd603b27c8eb06c1" ---help--- @@ -28,12 +28,12 @@ config O1HEAP_URL string "O(1) heap URL" default "https://github.com/pavel-kirienko/o1heap/archive" ---help--- - libcanard URL. + O(1) heap allocator URL. config O1HEAP_VERSION string "O(1) heap Version" default "b21b069e4b971d3016dd232784faca6f7d9fd724" ---help--- - libcanard version. + O(1) heap allocator version. endif diff --git a/canutils/libcanardv1/Make.defs b/canutils/libopencyphal/Make.defs similarity index 76% rename from canutils/libcanardv1/Make.defs rename to canutils/libopencyphal/Make.defs index 1e8785bb5..5fdf13abf 100644 --- a/canutils/libcanardv1/Make.defs +++ b/canutils/libopencyphal/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# apps/canutils/libcanardv1/Make.defs +# apps/canutils/libopencyphal/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -18,6 +18,10 @@ # ############################################################################ -ifneq ($(CONFIG_CANUTILS_LIBCANARDV1),) -CONFIGURED_APPS += $(APPDIR)/canutils/libcanardv1 +ifneq ($(CONFIG_CANUTILS_LIBOPENCYPHAL),) +CONFIGURED_APPS += $(APPDIR)/canutils/libopencyphal + +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libopencyphal/o1heap/o1heap +CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libopencyphal/o1heap/o1heap + endif diff --git a/canutils/libcanardv1/Makefile b/canutils/libopencyphal/Makefile similarity index 50% rename from canutils/libcanardv1/Makefile rename to canutils/libopencyphal/Makefile index fb18d762c..5d580dd08 100644 --- a/canutils/libcanardv1/Makefile +++ b/canutils/libopencyphal/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# apps/canutils/libcanardv1/Makefile +# apps/canutils/libopencyphal/Makefile # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -20,81 +20,72 @@ include $(APPDIR)/Make.defs +WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'} + UNPACK = unzip PACKEXT = .zip -LIBCANARDV1_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV1_URL))) -LIBCANARDV1_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV1_VERSION))) -LIBCANARDV1_UNPACKNAME = libcanard-$(LIBCANARDV1_VERSION) -LIBCANARDV1_PACKNAME = $(LIBCANARDV1_UNPACKNAME)$(PACKEXT) -LIBCANARDV1_SRCDIR = $(LIBCANARDV1_UNPACKNAME) -LIBCANARDV1_DRVDIR = $(LIBCANARDV1_SRCDIR)$(DELIM)libcanard +LIBOPENCYPHAL_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBOPENCYPHAL_URL))) +LIBOPENCYPHAL_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBOPENCYPHAL_VERSION))) + +LIBOPENCYPHAL_PACKNAME = $(LIBOPENCYPHAL_UNPACKNAME)$(PACKEXT) +LIBOPENCYPHAL_UNPACKNAME = libcanard-$(LIBOPENCYPHAL_VERSION) +LIBOPENCYPHAL_SRCNAME = libcanard + +LIBOPENCYPHAL_SRCDIR = $(WD)/$(LIBOPENCYPHAL_SRCNAME) +LIBOPENCYPHAL_DRVDIR = $(LIBOPENCYPHAL_SRCDIR)$(DELIM)libcanard O1HEAP_URL = $(patsubst "%",%,$(strip $(CONFIG_O1HEAP_URL))) O1HEAP_VERSION = $(patsubst "%",%,$(strip $(CONFIG_O1HEAP_VERSION))) -O1HEAP_UNPACKNAME = o1heap-$(O1HEAP_VERSION) + O1HEAP_PACKNAME = $(O1HEAP_UNPACKNAME)$(PACKEXT) -O1HEAP_SRCDIR = $(O1HEAP_UNPACKNAME) +O1HEAP_UNPACKNAME = o1heap-$(O1HEAP_VERSION) +O1HEAP_SRCNAME = o1heap + +O1HEAP_SRCDIR = $(WD)/$(O1HEAP_SRCNAME) O1HEAP_DRVDIR = $(O1HEAP_SRCDIR)$(DELIM)o1heap -APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)canutils - CFLAGS += -std=c11 -DCANARD_ASSERT=DEBUGASSERT -DCANARD_DSDL_CONFIG_LITTLE_ENDIAN=1 -CFLAGS += ${INCDIR_PREFIX}$(APPS_INCDIR) -CSRCS = $(LIBCANARDV1_DRVDIR)$(DELIM)canard.c $(LIBCANARDV1_DRVDIR)$(DELIM)canard_dsdl.c +CSRCS = $(LIBOPENCYPHAL_DRVDIR)$(DELIM)canard.c $(LIBOPENCYPHAL_DRVDIR)$(DELIM)canard_dsdl.c CSRCS += $(O1HEAP_DRVDIR)$(DELIM)o1heap.c - -$(LIBCANARDV1_PACKNAME): +ifeq ($(wildcard $(LIBOPENCYPHAL_SRCNAME)/.git),) +$(LIBOPENCYPHAL_PACKNAME): @echo "Downloading: $@" - $(Q) curl -o $@ -L $(LIBCANARDV1_URL)$(DELIM)$(LIBCANARDV1_VERSION)$(PACKEXT) + $(Q) curl -o $@ -L $(LIBOPENCYPHAL_URL)$(DELIM)$(LIBOPENCYPHAL_VERSION)$(PACKEXT) -$(LIBCANARDV1_UNPACKNAME): $(LIBCANARDV1_PACKNAME) +$(LIBOPENCYPHAL_SRCNAME): $(LIBOPENCYPHAL_PACKNAME) @echo "Unpacking: $< -> $@" $(call DELDIR, $@) $(Q) $(UNPACK) $< + $(Q) mv $(LIBOPENCYPHAL_UNPACKNAME) $(LIBOPENCYPHAL_SRCNAME) $(Q) touch $@ + +$(LIBOPENCYPHAL_DRVDIR)$(DELIM)canard.c: $(LIBOPENCYPHAL_SRCNAME) +endif +ifeq ($(wildcard $(O1HEAP_SRCNAME)/.git),) $(O1HEAP_PACKNAME): @echo "Downloading: $@" $(Q) curl -o $@ -L $(O1HEAP_URL)$(DELIM)$(O1HEAP_VERSION)$(PACKEXT) -$(O1HEAP_UNPACKNAME): $(O1HEAP_PACKNAME) +$(O1HEAP_SRCNAME): $(O1HEAP_PACKNAME) @echo "Unpacking: $< -> $@" $(call DELDIR, $@) $(Q) $(UNPACK) $< + $(Q) mv $(O1HEAP_UNPACKNAME) $(O1HEAP_SRCNAME) $(Q) touch $@ -$(LIBCANARDV1_DRVDIR)$(DELIM)canard.h: $(LIBCANARDV1_UNPACKNAME) +$(O1HEAP_DRVDIR)$(DELIM)o1heap.c: $(O1HEAP_SRCNAME) +endif -$(LIBCANARDV1_DRVDIR)$(DELIM)canard_dsdl.h: $(LIBCANARDV1_UNPACKNAME) - -$(O1HEAP_DRVDIR)$(DELIM)o1heap.h: $(O1HEAP_UNPACKNAME) - -$(APPS_INCDIR)$(DELIM)canard.h: $(LIBCANARDV1_DRVDIR)$(DELIM)canard.h - $(Q) cp $< $@ - -$(APPS_INCDIR)$(DELIM)canard_dsdl.h: $(LIBCANARDV1_DRVDIR)$(DELIM)canard_dsdl.h - $(Q) cp $< $@ - -$(APPS_INCDIR)$(DELIM)o1heap.h: $(O1HEAP_DRVDIR)$(DELIM)o1heap.h - $(Q) cp $< $@ - -context:: $(APPS_INCDIR)$(DELIM)canard.h $(APPS_INCDIR)$(DELIM)canard_dsdl.h $(APPS_INCDIR)$(DELIM)o1heap.h - -clean:: - $(foreach OBJ, $(OBJS), $(call DELFILE, $(OBJ))) +context:: $(LIBOPENCYPHAL_SRCNAME) $(O1HEAP_SRCNAME) distclean:: - $(call DELFILE, $(APPS_INCDIR)$(DELIM)canard.h) - $(call DELFILE, $(APPS_INCDIR)$(DELIM)canard_dsdl.h) - $(call DELDIR, $(LIBCANARDV1_UNPACKNAME)) - $(call DELFILE, $(LIBCANARDV1_PACKNAME)) - $(call DELDIR, $(O1HEAP_UNPACKNAME)) - $(call DELFILE, $(O1HEAP_PACKNAME)) - $(call DELFILE, $(APPS_INCDIR)$(DELIM)o1heap.h) - $(call DELDIR, $(O1HEAP_UNPACKNAME)) + $(call DELDIR, $(LIBOPENCYPHAL_SRCNAME)) + $(call DELFILE, $(LIBOPENCYPHAL_PACKNAME)) + $(call DELDIR, $(O1HEAP_SRCNAME)) $(call DELFILE, $(O1HEAP_PACKNAME)) include $(APPDIR)/Application.mk diff --git a/examples/canardv0/Kconfig b/examples/dronecan/Kconfig similarity index 55% rename from examples/canardv0/Kconfig rename to examples/dronecan/Kconfig index 3aea891e1..f005a37f2 100644 --- a/examples/canardv0/Kconfig +++ b/examples/dronecan/Kconfig @@ -3,45 +3,46 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -config EXAMPLES_LIBCANARDV0 - tristate "libcandard v0 example" +config EXAMPLES_DRONECAN + tristate "DroneCAN example" default n - depends on CANUTILS_LIBCANARDV0 && SYSTEM_TIME64 + depends on CANUTILS_LIBDRONECAN && SYSTEM_TIME64 ---help--- - Enable the LIBCANARDV0 example + Enable the LIBDRONECAN example -if EXAMPLES_LIBCANARDV0 +if EXAMPLES_DRONECAN -config EXAMPLES_LIBCANARDV0_DEVPATH +config EXAMPLES_DRONECAN_DEVPATH string "Device Path" default "/dev/can0" + depends on CAN ---help--- The device path -config EXAMPLES_LIBCANARDV0_NODE_ID +config EXAMPLES_DRONECAN_NODE_ID int "Node ID" default 1 range 1 127 ---help--- Specifies the node's ID -config EXAMPLES_LIBCANARDV0_APP_NODE_NAME +config EXAMPLES_DRONECAN_APP_NODE_NAME string "Node name" - default "org.uavcan.libcanard.nuttx.demo" + default "org.dronecan.nuttx.demo" ---help--- app node name -config EXAMPLES_LIBCANARDV0_NODE_MEM_POOL_SIZE +config EXAMPLES_DRONECAN_NODE_MEM_POOL_SIZE int "Node Memory Pool Size" default 1024 ---help--- Specifies the node's memory pool size -config EXAMPLES_LIBCANARDV0_DAEMON_PRIORITY +config EXAMPLES_DRONECAN_DAEMON_PRIORITY int "daemon task priority" default 100 -config EXAMPLES_LIBCANARDV0_STACKSIZE +config EXAMPLES_DRONECAN_STACKSIZE int "canard stack size" default DEFAULT_TASK_STACKSIZE diff --git a/examples/canardv0/Make.defs b/examples/dronecan/Make.defs similarity index 88% rename from examples/canardv0/Make.defs rename to examples/dronecan/Make.defs index 84f5e3aad..afcaed2be 100644 --- a/examples/canardv0/Make.defs +++ b/examples/dronecan/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# apps/examples/canardv0/Make.defs +# apps/examples/dronecan/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -18,6 +18,6 @@ # ############################################################################ -ifneq ($(CONFIG_EXAMPLES_LIBCANARDV0),) -CONFIGURED_APPS += $(APPDIR)/examples/canardv0 +ifneq ($(CONFIG_EXAMPLES_DRONECAN),) +CONFIGURED_APPS += $(APPDIR)/examples/dronecan endif diff --git a/examples/canardv0/Makefile b/examples/dronecan/Makefile similarity index 71% rename from examples/canardv0/Makefile rename to examples/dronecan/Makefile index 9e10611ea..b2f35d861 100644 --- a/examples/canardv0/Makefile +++ b/examples/dronecan/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# apps/examples/canardv0/Makefile +# apps/examples/dronecan/Makefile # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -20,12 +20,19 @@ include $(APPDIR)/Make.defs -PROGNAME = canardv0 +PROGNAME = dronecan PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = $(CONFIG_EXAMPLES_LIBCANARDV0_STACKSIZE) -MODULE = $(CONFIG_EXAMPLES_LIBCANARDV0) +STACKSIZE = $(CONFIG_EXAMPLES_DRONECAN_STACKSIZE) +MODULE = $(CONFIG_EXAMPLES_DRONECAN) + +# Conflict with Cyphal's libcanard +ifeq ($(CONFIG_CANUTILS_LIBOPENCYPHAL),y) +CFLAGS += -DcanardInit=dronecanardInit +endif + +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libdronecan/libcanard/drivers/nuttx -CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/include/canutils MAINSRC = canard_main.c include $(APPDIR)/Application.mk diff --git a/examples/canardv0/canard_main.c b/examples/dronecan/canard_main.c similarity index 83% rename from examples/canardv0/canard_main.c rename to examples/dronecan/canard_main.c index e0b645cca..eb2f7b320 100644 --- a/examples/canardv0/canard_main.c +++ b/examples/dronecan/canard_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/examples/canardv0/canard_main.c + * apps/examples/dronecan/canard_main.c * * Copyright (C) 2016 ETH Zuerich. All rights reserved. * Author: Matthias Renner @@ -38,9 +38,19 @@ ****************************************************************************/ #include + +#ifdef CONFIG_NET_CAN_CANFD +# define CANARD_ENABLE_CANFD 1 +#endif + #include +#ifdef CONFIG_NET_CAN +#include /* CAN backend driver for nuttx socketcan, distributed + * with Libcanard */ +#else #include /* CAN backend driver for nuttx, distributed * with Libcanard */ +#endif #include #include @@ -60,7 +70,7 @@ #define APP_VERSION_MAJOR 1 #define APP_VERSION_MINOR 0 -#define APP_NODE_NAME CONFIG_EXAMPLES_LIBCANARDV0_APP_NODE_NAME +#define APP_NODE_NAME CONFIG_EXAMPLES_DRONECAN_APP_NODE_NAME #define GIT_HASH 0xb28bf6ac /* Some useful constants defined by the UAVCAN specification. @@ -100,7 +110,7 @@ static CanardInstance canard; /* Arena for memory allocation, used by the library */ static uint8_t canard_memory_pool - [CONFIG_EXAMPLES_LIBCANARDV0_NODE_MEM_POOL_SIZE]; + [CONFIG_EXAMPLES_DRONECAN_NODE_MEM_POOL_SIZE]; static uint8_t unique_id[UNIQUE_ID_LENGTH_BYTES] = { 0x00, 0x00, 0x00, 0x00, @@ -115,6 +125,10 @@ static uint8_t node_health = UAVCAN_NODE_HEALTH_OK; static uint8_t node_mode = UAVCAN_NODE_MODE_INITIALIZATION; static bool g_canard_daemon_started; +#if CANARD_ENABLE_CANFD +static bool canfd; +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -227,6 +241,17 @@ static void onTransferReceived(CanardInstance *ins, */ const int resp_res = +#if CANARD_ENABLE_CANFD + canardRequestOrRespond(ins, + transfer->source_node_id, + UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE, + UAVCAN_GET_NODE_INFO_DATA_TYPE_ID, + &transfer->transfer_id, + transfer->priority, + CanardResponse, + &buffer[0], + (uint16_t)total_size, canfd); +#else canardRequestOrRespond(ins, transfer->source_node_id, UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE, @@ -236,6 +261,7 @@ static void onTransferReceived(CanardInstance *ins, CanardResponse, &buffer[0], (uint16_t) total_size); +#endif if (resp_res <= 0) { fprintf(stderr, "Could not respond to GetNodeInfo; error %d\n", @@ -333,10 +359,17 @@ void process1HzTasks(uint64_t timestamp_usec) static uint8_t transfer_id; const int bc_res = +#if CANARD_ENABLE_CANFD + canardBroadcast(&canard, UAVCAN_NODE_STATUS_DATA_TYPE_SIGNATURE, + UAVCAN_NODE_STATUS_DATA_TYPE_ID, &transfer_id, + CANARD_TRANSFER_PRIORITY_LOW, + buffer, UAVCAN_NODE_STATUS_MESSAGE_SIZE, canfd); +#else canardBroadcast(&canard, UAVCAN_NODE_STATUS_DATA_TYPE_SIGNATURE, UAVCAN_NODE_STATUS_DATA_TYPE_ID, &transfer_id, CANARD_TRANSFER_PRIORITY_LOW, buffer, UAVCAN_NODE_STATUS_MESSAGE_SIZE); +#endif if (bc_res <= 0) { fprintf(stderr, "Could not broadcast node status; error %d\n", @@ -349,12 +382,21 @@ void process1HzTasks(uint64_t timestamp_usec) uint8_t payload[1]; uint8_t dest_id = 2; const int resp_res = +#if CANARD_ENABLE_CANFD + canardRequestOrRespond(&canard, dest_id, + UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE, + UAVCAN_GET_NODE_INFO_DATA_TYPE_ID, + &transfer_id, + CANARD_TRANSFER_PRIORITY_LOW, CanardRequest, + payload, 0, canfd); +#else canardRequestOrRespond(&canard, dest_id, UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE, UAVCAN_GET_NODE_INFO_DATA_TYPE_ID, &transfer_id, CANARD_TRANSFER_PRIORITY_LOW, CanardRequest, payload, 0); +#endif if (resp_res <= 0) { fprintf(stderr, "Could not request GetNodeInfo; error %d\n", @@ -372,8 +414,11 @@ void process1HzTasks(uint64_t timestamp_usec) * Transmits all frames from the TX queue, receives up to one frame. * ****************************************************************************/ - -void processTxRxOnce(CanardNuttXInstance * nuttxcan, int timeout_msec) +#ifdef CONFIG_NET_CAN +void processTxRxOnce(SocketCANInstance *socketcan, int timeout_msec) +#else +void processTxRxOnce(CanardNuttXInstance *nuttxcan, int timeout_msec) +#endif { const CanardCANFrame *txf; @@ -381,8 +426,12 @@ void processTxRxOnce(CanardNuttXInstance * nuttxcan, int timeout_msec) for (txf = NULL; (txf = canardPeekTxQueue(&canard)) != NULL; ) { +#ifdef CONFIG_NET_CAN + const int tx_res = socketcanTransmit(socketcan, txf, 0); +#else const int tx_res = canardNuttXTransmit(nuttxcan, txf, 0); - if (tx_res < 0) /* Failure - drop the frame and report */ +#endif + if (tx_res < 0 && tx_res != -EAGAIN) /* Failure - drop the frame and report */ { canardPopTxQueue(&canard); fprintf(stderr, @@ -403,7 +452,11 @@ void processTxRxOnce(CanardNuttXInstance * nuttxcan, int timeout_msec) CanardCANFrame rx_frame; const uint64_t timestamp = getMonotonicTimestampUSec(); +#ifdef CONFIG_NET_CAN + const int rx_res = socketcanReceive(socketcan, &rx_frame, timeout_msec); +#else const int rx_res = canardNuttXReceive(nuttxcan, &rx_frame, timeout_msec); +#endif if (rx_res < 0) /* Failure - report */ { @@ -429,12 +482,16 @@ void processTxRxOnce(CanardNuttXInstance * nuttxcan, int timeout_msec) static int canard_daemon(int argc, char *argv[]) { +#ifdef CONFIG_NET_CAN + static SocketCANInstance socketcan; +#else static CanardNuttXInstance canardnuttx_instance; + int ret; +#endif #ifdef CONFIG_DEBUG_CAN struct canioc_bittiming_s bt; #endif int errval = 0; - int ret; /* Initialization of the CAN hardware is performed by external, board- * specific logic to running this test. @@ -442,17 +499,33 @@ static int canard_daemon(int argc, char *argv[]) /* Open the CAN device for reading */ + +#ifdef CONFIG_NET_CAN + const char * const can_iface_name = "can0"; + +# if CANARD_ENABLE_CANFD + int16_t res = socketcanInit(&socketcan, can_iface_name, canfd); +# else + int16_t res = socketcanInit(&socketcan, can_iface_name); +# endif + if (res < 0) + { + fprintf(stderr, "Failed to open CAN iface '%s'\n", can_iface_name); + return 1; + } +#else ret = canardNuttXInit(&canardnuttx_instance, - CONFIG_EXAMPLES_LIBCANARDV0_DEVPATH); + CONFIG_EXAMPLES_DRONECAN_DEVPATH); if (ret < 0) { printf("canard_daemon: ERROR: open %s failed: %d\n", - CONFIG_EXAMPLES_LIBCANARDV0_DEVPATH, errno); + CONFIG_EXAMPLES_DRONECAN_DEVPATH, errno); errval = 2; goto errout_with_dev; } +#endif -#ifdef CONFIG_DEBUG_CAN +#if defined(CONFIG_CAN) && defined(CONFIG_DEBUG_CAN) /* Show bit timing information if provided by the driver. Not all CAN * drivers will support this IOCTL. */ @@ -476,10 +549,10 @@ static int canard_daemon(int argc, char *argv[]) canardInit(&canard, canard_memory_pool, sizeof(canard_memory_pool), onTransferReceived, shouldAcceptTransfer, (void *)(12345)); - canardSetLocalNodeID(&canard, CONFIG_EXAMPLES_LIBCANARDV0_NODE_ID); + canardSetLocalNodeID(&canard, CONFIG_EXAMPLES_DRONECAN_NODE_ID); printf("canard_daemon: canard initialized\n"); printf("start node (ID: %d Name: %s)\n", - CONFIG_EXAMPLES_LIBCANARDV0_NODE_ID, + CONFIG_EXAMPLES_DRONECAN_NODE_ID, APP_NODE_NAME); g_canard_daemon_started = true; @@ -487,7 +560,11 @@ static int canard_daemon(int argc, char *argv[]) for (; ; ) { +#ifdef CONFIG_NET_CAN + processTxRxOnce(&socketcan, 10); +#else processTxRxOnce(&canardnuttx_instance, 10); +#endif const uint64_t ts = getMonotonicTimestampUSec(); @@ -498,8 +575,10 @@ static int canard_daemon(int argc, char *argv[]) } } +#ifdef CONFIG_CAN errout_with_dev: canardNuttXClose(&canardnuttx_instance); +#endif g_canard_daemon_started = false; printf("canard_daemon: Terminating!\n"); @@ -525,9 +604,17 @@ int main(int argc, FAR char *argv[]) return EXIT_SUCCESS; } +#if CANARD_ENABLE_CANFD + if (argc == 2 && strcmp(argv[1], "canfd") == 0) + { + printf("CAN FD mode enabled\n"); + canfd = true; + } +#endif + ret = task_create("canard_daemon", - CONFIG_EXAMPLES_LIBCANARDV0_DAEMON_PRIORITY, - CONFIG_EXAMPLES_LIBCANARDV0_STACKSIZE, canard_daemon, + CONFIG_EXAMPLES_DRONECAN_DAEMON_PRIORITY, + CONFIG_EXAMPLES_DRONECAN_STACKSIZE, canard_daemon, NULL); if (ret < 0) { diff --git a/examples/canardv1/Kconfig b/examples/opencyphal/Kconfig similarity index 54% rename from examples/canardv1/Kconfig rename to examples/opencyphal/Kconfig index 9ce2e6698..49ab8d5f7 100644 --- a/examples/canardv1/Kconfig +++ b/examples/opencyphal/Kconfig @@ -3,45 +3,45 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -config EXAMPLES_LIBCANARDV1 - tristate "libcandard v1 example" +config EXAMPLES_LIBOPENCYPHAL + tristate "OpenCyphal Cyphal/CAN example" default n - depends on CANUTILS_LIBCANARDV1 + depends on CANUTILS_LIBOPENCYPHAL ---help--- - Enable the LIBCANARDV1 example + Enable the LIBOPENCYPHAL example -if EXAMPLES_LIBCANARDV1 +if EXAMPLES_LIBOPENCYPHAL -config EXAMPLES_LIBCANARDV1_DEV +config EXAMPLES_LIBOPENCYPHAL_DEV string "Device" default "can0" ---help--- The device -config EXAMPLES_LIBCANARDV1_NODE_ID +config EXAMPLES_LIBOPENCYPHAL_NODE_ID int "Node ID" default 1 range 1 127 ---help--- Specifies the node's ID -config EXAMPLES_LIBCANARDV1_APP_NODE_NAME +config EXAMPLES_LIBOPENCYPHAL_APP_NODE_NAME string "Node name" - default "org.uavcan.libcanardv1.nuttx.demo" + default "org.apache.nuttx.demo" ---help--- app node name -config EXAMPLES_LIBCANARDV1_NODE_MEM_POOL_SIZE +config EXAMPLES_LIBOPENCYPHAL_NODE_MEM_POOL_SIZE int "Node Memory Pool Size" default 1024 ---help--- Specifies the node's memory pool size -config EXAMPLES_LIBCANARDV1_DAEMON_PRIORITY +config EXAMPLES_LIBOPENCYPHAL_DAEMON_PRIORITY int "daemon task priority" default 100 -config EXAMPLES_LIBCANARDV1_DAEMON_STACK_SIZE +config EXAMPLES_LIBOPENCYPHAL_DAEMON_STACK_SIZE int "canard stack size" default DEFAULT_TASK_STACKSIZE diff --git a/examples/canardv1/Make.defs b/examples/opencyphal/Make.defs similarity index 88% rename from examples/canardv1/Make.defs rename to examples/opencyphal/Make.defs index dc9399209..60b182fab 100644 --- a/examples/canardv1/Make.defs +++ b/examples/opencyphal/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# apps/examples/canardv1/Make.defs +# apps/examples/opencyphal/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -18,6 +18,6 @@ # ############################################################################ -ifneq ($(CONFIG_EXAMPLES_LIBCANARDV1),) -CONFIGURED_APPS += $(APPDIR)/examples/canardv1 +ifneq ($(CONFIG_EXAMPLES_LIBOPENCYPHAL),) +CONFIGURED_APPS += $(APPDIR)/examples/opencyphal endif diff --git a/examples/canardv1/Makefile b/examples/opencyphal/Makefile similarity index 75% rename from examples/canardv1/Makefile rename to examples/opencyphal/Makefile index 2ad75d03b..2004e1469 100644 --- a/examples/canardv1/Makefile +++ b/examples/opencyphal/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# apps/examples/canardv1/Makefile +# apps/examples/opencyphal/Makefile # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -20,12 +20,15 @@ include $(APPDIR)/Make.defs -PROGNAME = canardv1 +PROGNAME = opencyphal PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = $(CONFIG_EXAMPLES_LIBCANARDV1_DAEMON_STACK_SIZE) -MODULE = $(CONFIG_EXAMPLES_LIBCANARDV1) +STACKSIZE = $(CONFIG_EXAMPLES_LIBOPENCYPHAL_DAEMON_STACK_SIZE) +MODULE = $(CONFIG_EXAMPLES_LIBOPENCYPHAL) -CFLAGS += -std=c11 ${INCDIR_PREFIX}$(APPDIR)/include/canutils $(APPDIR)/include/o1heap +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libopencyphal/libcanard/libcanard +CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libopencyphal/libcanard/libcanard + +CFLAGS += -std=c11 CSRCS = socketcan.c MAINSRC = canard_main.c diff --git a/examples/canardv1/canard_main.c b/examples/opencyphal/canard_main.c similarity index 95% rename from examples/canardv1/canard_main.c rename to examples/opencyphal/canard_main.c index ebf8f0119..91341ab71 100644 --- a/examples/canardv1/canard_main.c +++ b/examples/opencyphal/canard_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/examples/canardv1/canard_main.c + * apps/examples/opencyphal/canard_main.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -55,7 +55,7 @@ #define APP_VERSION_MAJOR 1 #define APP_VERSION_MINOR 0 -#define APP_NODE_NAME CONFIG_EXAMPLES_LIBCANARDV1_APP_NODE_NAME +#define APP_NODE_NAME CONFIG_EXAMPLES_LIBOPENCYPHAL_APP_NODE_NAME /**************************************************************************** * Private Data @@ -63,7 +63,7 @@ /* Arena for memory allocation, used by the library */ -#define O1_HEAP_SIZE CONFIG_EXAMPLES_LIBCANARDV1_NODE_MEM_POOL_SIZE +#define O1_HEAP_SIZE CONFIG_EXAMPLES_LIBOPENCYPHAL_NODE_MEM_POOL_SIZE /* Temporary development UAVCAN topic service ID to publish/subscribe from */ #define PORT_ID 4421 @@ -310,13 +310,13 @@ static int canard_daemon(int argc, char *argv[]) ins.mtu_bytes = CANARD_MTU_CAN_CLASSIC; } - ins.node_id = (pub ? CONFIG_EXAMPLES_LIBCANARDV1_NODE_ID : - CONFIG_EXAMPLES_LIBCANARDV1_NODE_ID + 1); + ins.node_id = (pub ? CONFIG_EXAMPLES_LIBOPENCYPHAL_NODE_ID : + CONFIG_EXAMPLES_LIBOPENCYPHAL_NODE_ID + 1); /* Open the CAN device for reading */ canardsocketinstance sock_ins; - socketcanopen(&sock_ins, CONFIG_EXAMPLES_LIBCANARDV1_DEV, can_fd); + socketcanopen(&sock_ins, CONFIG_EXAMPLES_LIBOPENCYPHAL_DEV, can_fd); /* setup poll fd */ @@ -326,7 +326,7 @@ static int canard_daemon(int argc, char *argv[]) if (sock_ins.s < 0) { printf("canard_daemon: ERROR: open %s failed: %d\n", - CONFIG_EXAMPLES_LIBCANARDV1_DEV, errno); + CONFIG_EXAMPLES_LIBOPENCYPHAL_DEV, errno); errval = 2; goto errout_with_dev; } @@ -382,7 +382,7 @@ errout_with_dev: * ****************************************************************************/ -int canardv1_main(int argc, FAR char *argv[]) +int opencyphal_main(int argc, FAR char *argv[]) { int ret; @@ -395,8 +395,8 @@ int canardv1_main(int argc, FAR char *argv[]) } ret = task_create("canard_daemon", - CONFIG_EXAMPLES_LIBCANARDV1_DAEMON_PRIORITY, - CONFIG_EXAMPLES_LIBCANARDV1_DAEMON_STACK_SIZE, + CONFIG_EXAMPLES_LIBOPENCYPHAL_DAEMON_PRIORITY, + CONFIG_EXAMPLES_LIBOPENCYPHAL_DAEMON_STACK_SIZE, canard_daemon, argv); if (ret < 0) diff --git a/examples/canardv1/socketcan.c b/examples/opencyphal/socketcan.c similarity index 99% rename from examples/canardv1/socketcan.c rename to examples/opencyphal/socketcan.c index 9d4fd595b..ac6f58a01 100644 --- a/examples/canardv1/socketcan.c +++ b/examples/opencyphal/socketcan.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/examples/canardv1/socketcan.c + * apps/examples/opencyphal/socketcan.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/examples/canardv1/socketcan.h b/examples/opencyphal/socketcan.h similarity index 98% rename from examples/canardv1/socketcan.h rename to examples/opencyphal/socketcan.h index da5de9298..12f836575 100644 --- a/examples/canardv1/socketcan.h +++ b/examples/opencyphal/socketcan.h @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/examples/canardv1/socketcan.h + * apps/examples/opencyphal/socketcan.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with