DroneCAN add socketcan support, rename to DroneCAN
Rename canardv1 to OpenCyphal Apply suggestions from code review Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
e935f153bc
commit
fa26bab6b2
1
canutils/libcanardv0/.gitignore
vendored
1
canutils/libcanardv0/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
/libcanard-*
|
|
@ -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
|
|
@ -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
|
|
2
canutils/libcanardv1/.gitignore
vendored
2
canutils/libcanardv1/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
/libcanard-*
|
|
||||||
/o1heap-*
|
|
2
canutils/libdronecan/.gitignore
vendored
Normal file
2
canutils/libdronecan/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/libcanard
|
||||||
|
/*.zip
|
37
canutils/libdronecan/Kconfig
Normal file
37
canutils/libdronecan/Kconfig
Normal file
@ -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
|
@ -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
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -18,6 +18,12 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifneq ($(CONFIG_CANUTILS_LIBCANARDV0),)
|
ifneq ($(CONFIG_CANUTILS_LIBDRONECAN),)
|
||||||
CONFIGURED_APPS += $(APPDIR)/canutils/libcanardv0
|
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
|
endif
|
83
canutils/libdronecan/Makefile
Normal file
83
canutils/libdronecan/Makefile
Normal file
@ -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
|
3
canutils/libopencyphal/.gitignore
vendored
Normal file
3
canutils/libopencyphal/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/libcanard
|
||||||
|
/o1heap
|
||||||
|
/*.zip
|
@ -3,22 +3,22 @@
|
|||||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
#
|
#
|
||||||
|
|
||||||
config CANUTILS_LIBCANARDV1
|
config CANUTILS_LIBOPENCYPHAL
|
||||||
bool "libcanard UAVCAN v1 Library"
|
bool "libcanard OpenCyphal Cyphal/CAN Library"
|
||||||
default n
|
default n
|
||||||
depends on NET_CAN && ALLOW_MIT_COMPONENTS
|
depends on NET_CAN && ALLOW_MIT_COMPONENTS
|
||||||
---help---
|
---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"
|
string "libcanard URL"
|
||||||
default "https://github.com/UAVCAN/libcanard/archive"
|
default "https://github.com/OpenCyphal/libcanard/archive"
|
||||||
---help---
|
---help---
|
||||||
libcanard URL.
|
libcanard URL.
|
||||||
|
|
||||||
config LIBCANARDV1_VERSION
|
config LIBOPENCYPHAL_VERSION
|
||||||
string "libcanard Version"
|
string "libcanard Version"
|
||||||
default "cde670347425023480a1417fcd603b27c8eb06c1"
|
default "cde670347425023480a1417fcd603b27c8eb06c1"
|
||||||
---help---
|
---help---
|
||||||
@ -28,12 +28,12 @@ config O1HEAP_URL
|
|||||||
string "O(1) heap URL"
|
string "O(1) heap URL"
|
||||||
default "https://github.com/pavel-kirienko/o1heap/archive"
|
default "https://github.com/pavel-kirienko/o1heap/archive"
|
||||||
---help---
|
---help---
|
||||||
libcanard URL.
|
O(1) heap allocator URL.
|
||||||
|
|
||||||
config O1HEAP_VERSION
|
config O1HEAP_VERSION
|
||||||
string "O(1) heap Version"
|
string "O(1) heap Version"
|
||||||
default "b21b069e4b971d3016dd232784faca6f7d9fd724"
|
default "b21b069e4b971d3016dd232784faca6f7d9fd724"
|
||||||
---help---
|
---help---
|
||||||
libcanard version.
|
O(1) heap allocator version.
|
||||||
|
|
||||||
endif
|
endif
|
@ -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
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -18,6 +18,10 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifneq ($(CONFIG_CANUTILS_LIBCANARDV1),)
|
ifneq ($(CONFIG_CANUTILS_LIBOPENCYPHAL),)
|
||||||
CONFIGURED_APPS += $(APPDIR)/canutils/libcanardv1
|
CONFIGURED_APPS += $(APPDIR)/canutils/libopencyphal
|
||||||
|
|
||||||
|
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libopencyphal/o1heap/o1heap
|
||||||
|
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/canutils/libopencyphal/o1heap/o1heap
|
||||||
|
|
||||||
endif
|
endif
|
@ -1,5 +1,5 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# apps/canutils/libcanardv1/Makefile
|
# apps/canutils/libopencyphal/Makefile
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -20,81 +20,72 @@
|
|||||||
|
|
||||||
include $(APPDIR)/Make.defs
|
include $(APPDIR)/Make.defs
|
||||||
|
|
||||||
|
WD := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}
|
||||||
|
|
||||||
UNPACK = unzip
|
UNPACK = unzip
|
||||||
PACKEXT = .zip
|
PACKEXT = .zip
|
||||||
|
|
||||||
LIBCANARDV1_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV1_URL)))
|
LIBOPENCYPHAL_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBOPENCYPHAL_URL)))
|
||||||
LIBCANARDV1_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV1_VERSION)))
|
LIBOPENCYPHAL_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBOPENCYPHAL_VERSION)))
|
||||||
LIBCANARDV1_UNPACKNAME = libcanard-$(LIBCANARDV1_VERSION)
|
|
||||||
LIBCANARDV1_PACKNAME = $(LIBCANARDV1_UNPACKNAME)$(PACKEXT)
|
LIBOPENCYPHAL_PACKNAME = $(LIBOPENCYPHAL_UNPACKNAME)$(PACKEXT)
|
||||||
LIBCANARDV1_SRCDIR = $(LIBCANARDV1_UNPACKNAME)
|
LIBOPENCYPHAL_UNPACKNAME = libcanard-$(LIBOPENCYPHAL_VERSION)
|
||||||
LIBCANARDV1_DRVDIR = $(LIBCANARDV1_SRCDIR)$(DELIM)libcanard
|
LIBOPENCYPHAL_SRCNAME = libcanard
|
||||||
|
|
||||||
|
LIBOPENCYPHAL_SRCDIR = $(WD)/$(LIBOPENCYPHAL_SRCNAME)
|
||||||
|
LIBOPENCYPHAL_DRVDIR = $(LIBOPENCYPHAL_SRCDIR)$(DELIM)libcanard
|
||||||
|
|
||||||
O1HEAP_URL = $(patsubst "%",%,$(strip $(CONFIG_O1HEAP_URL)))
|
O1HEAP_URL = $(patsubst "%",%,$(strip $(CONFIG_O1HEAP_URL)))
|
||||||
O1HEAP_VERSION = $(patsubst "%",%,$(strip $(CONFIG_O1HEAP_VERSION)))
|
O1HEAP_VERSION = $(patsubst "%",%,$(strip $(CONFIG_O1HEAP_VERSION)))
|
||||||
O1HEAP_UNPACKNAME = o1heap-$(O1HEAP_VERSION)
|
|
||||||
O1HEAP_PACKNAME = $(O1HEAP_UNPACKNAME)$(PACKEXT)
|
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
|
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 += -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
|
CSRCS += $(O1HEAP_DRVDIR)$(DELIM)o1heap.c
|
||||||
|
|
||||||
|
ifeq ($(wildcard $(LIBOPENCYPHAL_SRCNAME)/.git),)
|
||||||
$(LIBCANARDV1_PACKNAME):
|
$(LIBOPENCYPHAL_PACKNAME):
|
||||||
@echo "Downloading: $@"
|
@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: $< -> $@"
|
@echo "Unpacking: $< -> $@"
|
||||||
$(call DELDIR, $@)
|
$(call DELDIR, $@)
|
||||||
$(Q) $(UNPACK) $<
|
$(Q) $(UNPACK) $<
|
||||||
|
$(Q) mv $(LIBOPENCYPHAL_UNPACKNAME) $(LIBOPENCYPHAL_SRCNAME)
|
||||||
$(Q) touch $@
|
$(Q) touch $@
|
||||||
|
|
||||||
|
$(LIBOPENCYPHAL_DRVDIR)$(DELIM)canard.c: $(LIBOPENCYPHAL_SRCNAME)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(wildcard $(O1HEAP_SRCNAME)/.git),)
|
||||||
$(O1HEAP_PACKNAME):
|
$(O1HEAP_PACKNAME):
|
||||||
@echo "Downloading: $@"
|
@echo "Downloading: $@"
|
||||||
$(Q) curl -o $@ -L $(O1HEAP_URL)$(DELIM)$(O1HEAP_VERSION)$(PACKEXT)
|
$(Q) curl -o $@ -L $(O1HEAP_URL)$(DELIM)$(O1HEAP_VERSION)$(PACKEXT)
|
||||||
|
|
||||||
$(O1HEAP_UNPACKNAME): $(O1HEAP_PACKNAME)
|
$(O1HEAP_SRCNAME): $(O1HEAP_PACKNAME)
|
||||||
@echo "Unpacking: $< -> $@"
|
@echo "Unpacking: $< -> $@"
|
||||||
$(call DELDIR, $@)
|
$(call DELDIR, $@)
|
||||||
$(Q) $(UNPACK) $<
|
$(Q) $(UNPACK) $<
|
||||||
|
$(Q) mv $(O1HEAP_UNPACKNAME) $(O1HEAP_SRCNAME)
|
||||||
$(Q) touch $@
|
$(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)
|
context:: $(LIBOPENCYPHAL_SRCNAME) $(O1HEAP_SRCNAME)
|
||||||
|
|
||||||
$(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)))
|
|
||||||
|
|
||||||
distclean::
|
distclean::
|
||||||
$(call DELFILE, $(APPS_INCDIR)$(DELIM)canard.h)
|
$(call DELDIR, $(LIBOPENCYPHAL_SRCNAME))
|
||||||
$(call DELFILE, $(APPS_INCDIR)$(DELIM)canard_dsdl.h)
|
$(call DELFILE, $(LIBOPENCYPHAL_PACKNAME))
|
||||||
$(call DELDIR, $(LIBCANARDV1_UNPACKNAME))
|
$(call DELDIR, $(O1HEAP_SRCNAME))
|
||||||
$(call DELFILE, $(LIBCANARDV1_PACKNAME))
|
|
||||||
$(call DELDIR, $(O1HEAP_UNPACKNAME))
|
|
||||||
$(call DELFILE, $(O1HEAP_PACKNAME))
|
|
||||||
$(call DELFILE, $(APPS_INCDIR)$(DELIM)o1heap.h)
|
|
||||||
$(call DELDIR, $(O1HEAP_UNPACKNAME))
|
|
||||||
$(call DELFILE, $(O1HEAP_PACKNAME))
|
$(call DELFILE, $(O1HEAP_PACKNAME))
|
||||||
|
|
||||||
include $(APPDIR)/Application.mk
|
include $(APPDIR)/Application.mk
|
@ -3,45 +3,46 @@
|
|||||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
#
|
#
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV0
|
config EXAMPLES_DRONECAN
|
||||||
tristate "libcandard v0 example"
|
tristate "DroneCAN example"
|
||||||
default n
|
default n
|
||||||
depends on CANUTILS_LIBCANARDV0 && SYSTEM_TIME64
|
depends on CANUTILS_LIBDRONECAN && SYSTEM_TIME64
|
||||||
---help---
|
---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"
|
string "Device Path"
|
||||||
default "/dev/can0"
|
default "/dev/can0"
|
||||||
|
depends on CAN
|
||||||
---help---
|
---help---
|
||||||
The device path
|
The device path
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV0_NODE_ID
|
config EXAMPLES_DRONECAN_NODE_ID
|
||||||
int "Node ID"
|
int "Node ID"
|
||||||
default 1
|
default 1
|
||||||
range 1 127
|
range 1 127
|
||||||
---help---
|
---help---
|
||||||
Specifies the node's ID
|
Specifies the node's ID
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV0_APP_NODE_NAME
|
config EXAMPLES_DRONECAN_APP_NODE_NAME
|
||||||
string "Node name"
|
string "Node name"
|
||||||
default "org.uavcan.libcanard.nuttx.demo"
|
default "org.dronecan.nuttx.demo"
|
||||||
---help---
|
---help---
|
||||||
app node name
|
app node name
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV0_NODE_MEM_POOL_SIZE
|
config EXAMPLES_DRONECAN_NODE_MEM_POOL_SIZE
|
||||||
int "Node Memory Pool Size"
|
int "Node Memory Pool Size"
|
||||||
default 1024
|
default 1024
|
||||||
---help---
|
---help---
|
||||||
Specifies the node's memory pool size
|
Specifies the node's memory pool size
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV0_DAEMON_PRIORITY
|
config EXAMPLES_DRONECAN_DAEMON_PRIORITY
|
||||||
int "daemon task priority"
|
int "daemon task priority"
|
||||||
default 100
|
default 100
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV0_STACKSIZE
|
config EXAMPLES_DRONECAN_STACKSIZE
|
||||||
int "canard stack size"
|
int "canard stack size"
|
||||||
default DEFAULT_TASK_STACKSIZE
|
default DEFAULT_TASK_STACKSIZE
|
||||||
|
|
@ -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
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -18,6 +18,6 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifneq ($(CONFIG_EXAMPLES_LIBCANARDV0),)
|
ifneq ($(CONFIG_EXAMPLES_DRONECAN),)
|
||||||
CONFIGURED_APPS += $(APPDIR)/examples/canardv0
|
CONFIGURED_APPS += $(APPDIR)/examples/dronecan
|
||||||
endif
|
endif
|
@ -1,5 +1,5 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# apps/examples/canardv0/Makefile
|
# apps/examples/dronecan/Makefile
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -20,12 +20,19 @@
|
|||||||
|
|
||||||
include $(APPDIR)/Make.defs
|
include $(APPDIR)/Make.defs
|
||||||
|
|
||||||
PROGNAME = canardv0
|
PROGNAME = dronecan
|
||||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||||
STACKSIZE = $(CONFIG_EXAMPLES_LIBCANARDV0_STACKSIZE)
|
STACKSIZE = $(CONFIG_EXAMPLES_DRONECAN_STACKSIZE)
|
||||||
MODULE = $(CONFIG_EXAMPLES_LIBCANARDV0)
|
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
|
MAINSRC = canard_main.c
|
||||||
|
|
||||||
include $(APPDIR)/Application.mk
|
include $(APPDIR)/Application.mk
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* apps/examples/canardv0/canard_main.c
|
* apps/examples/dronecan/canard_main.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 ETH Zuerich. All rights reserved.
|
* Copyright (C) 2016 ETH Zuerich. All rights reserved.
|
||||||
* Author: Matthias Renner <rennerm@ethz.ch>
|
* Author: Matthias Renner <rennerm@ethz.ch>
|
||||||
@ -38,9 +38,19 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/can/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_CAN_CANFD
|
||||||
|
# define CANARD_ENABLE_CANFD 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <canard.h>
|
#include <canard.h>
|
||||||
|
#ifdef CONFIG_NET_CAN
|
||||||
|
#include <socketcan.h> /* CAN backend driver for nuttx socketcan, distributed
|
||||||
|
* with Libcanard */
|
||||||
|
#else
|
||||||
#include <canard_nuttx.h> /* CAN backend driver for nuttx, distributed
|
#include <canard_nuttx.h> /* CAN backend driver for nuttx, distributed
|
||||||
* with Libcanard */
|
* with Libcanard */
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
@ -60,7 +70,7 @@
|
|||||||
|
|
||||||
#define APP_VERSION_MAJOR 1
|
#define APP_VERSION_MAJOR 1
|
||||||
#define APP_VERSION_MINOR 0
|
#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
|
#define GIT_HASH 0xb28bf6ac
|
||||||
|
|
||||||
/* Some useful constants defined by the UAVCAN specification.
|
/* Some useful constants defined by the UAVCAN specification.
|
||||||
@ -100,7 +110,7 @@ static CanardInstance canard;
|
|||||||
/* Arena for memory allocation, used by the library */
|
/* Arena for memory allocation, used by the library */
|
||||||
|
|
||||||
static uint8_t canard_memory_pool
|
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] =
|
static uint8_t unique_id[UNIQUE_ID_LENGTH_BYTES] =
|
||||||
{ 0x00, 0x00, 0x00, 0x00,
|
{ 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 uint8_t node_mode = UAVCAN_NODE_MODE_INITIALIZATION;
|
||||||
static bool g_canard_daemon_started;
|
static bool g_canard_daemon_started;
|
||||||
|
|
||||||
|
#if CANARD_ENABLE_CANFD
|
||||||
|
static bool canfd;
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -227,6 +241,17 @@ static void onTransferReceived(CanardInstance *ins,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const int resp_res =
|
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,
|
canardRequestOrRespond(ins,
|
||||||
transfer->source_node_id,
|
transfer->source_node_id,
|
||||||
UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE,
|
UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE,
|
||||||
@ -236,6 +261,7 @@ static void onTransferReceived(CanardInstance *ins,
|
|||||||
CanardResponse,
|
CanardResponse,
|
||||||
&buffer[0],
|
&buffer[0],
|
||||||
(uint16_t) total_size);
|
(uint16_t) total_size);
|
||||||
|
#endif
|
||||||
if (resp_res <= 0)
|
if (resp_res <= 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not respond to GetNodeInfo; error %d\n",
|
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;
|
static uint8_t transfer_id;
|
||||||
|
|
||||||
const int bc_res =
|
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,
|
canardBroadcast(&canard, UAVCAN_NODE_STATUS_DATA_TYPE_SIGNATURE,
|
||||||
UAVCAN_NODE_STATUS_DATA_TYPE_ID, &transfer_id,
|
UAVCAN_NODE_STATUS_DATA_TYPE_ID, &transfer_id,
|
||||||
CANARD_TRANSFER_PRIORITY_LOW,
|
CANARD_TRANSFER_PRIORITY_LOW,
|
||||||
buffer, UAVCAN_NODE_STATUS_MESSAGE_SIZE);
|
buffer, UAVCAN_NODE_STATUS_MESSAGE_SIZE);
|
||||||
|
#endif
|
||||||
if (bc_res <= 0)
|
if (bc_res <= 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not broadcast node status; error %d\n",
|
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 payload[1];
|
||||||
uint8_t dest_id = 2;
|
uint8_t dest_id = 2;
|
||||||
const int resp_res =
|
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,
|
canardRequestOrRespond(&canard, dest_id,
|
||||||
UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE,
|
UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE,
|
||||||
UAVCAN_GET_NODE_INFO_DATA_TYPE_ID,
|
UAVCAN_GET_NODE_INFO_DATA_TYPE_ID,
|
||||||
&transfer_id,
|
&transfer_id,
|
||||||
CANARD_TRANSFER_PRIORITY_LOW, CanardRequest,
|
CANARD_TRANSFER_PRIORITY_LOW, CanardRequest,
|
||||||
payload, 0);
|
payload, 0);
|
||||||
|
#endif
|
||||||
if (resp_res <= 0)
|
if (resp_res <= 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not request GetNodeInfo; error %d\n",
|
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.
|
* Transmits all frames from the TX queue, receives up to one frame.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#ifdef CONFIG_NET_CAN
|
||||||
void processTxRxOnce(CanardNuttXInstance * nuttxcan, int timeout_msec)
|
void processTxRxOnce(SocketCANInstance *socketcan, int timeout_msec)
|
||||||
|
#else
|
||||||
|
void processTxRxOnce(CanardNuttXInstance *nuttxcan, int timeout_msec)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
const CanardCANFrame *txf;
|
const CanardCANFrame *txf;
|
||||||
|
|
||||||
@ -381,8 +426,12 @@ void processTxRxOnce(CanardNuttXInstance * nuttxcan, int timeout_msec)
|
|||||||
|
|
||||||
for (txf = NULL; (txf = canardPeekTxQueue(&canard)) != NULL; )
|
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);
|
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);
|
canardPopTxQueue(&canard);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -403,7 +452,11 @@ void processTxRxOnce(CanardNuttXInstance * nuttxcan, int timeout_msec)
|
|||||||
|
|
||||||
CanardCANFrame rx_frame;
|
CanardCANFrame rx_frame;
|
||||||
const uint64_t timestamp = getMonotonicTimestampUSec();
|
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);
|
const int rx_res = canardNuttXReceive(nuttxcan, &rx_frame, timeout_msec);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (rx_res < 0) /* Failure - report */
|
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[])
|
static int canard_daemon(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_NET_CAN
|
||||||
|
static SocketCANInstance socketcan;
|
||||||
|
#else
|
||||||
static CanardNuttXInstance canardnuttx_instance;
|
static CanardNuttXInstance canardnuttx_instance;
|
||||||
|
int ret;
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_DEBUG_CAN
|
#ifdef CONFIG_DEBUG_CAN
|
||||||
struct canioc_bittiming_s bt;
|
struct canioc_bittiming_s bt;
|
||||||
#endif
|
#endif
|
||||||
int errval = 0;
|
int errval = 0;
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Initialization of the CAN hardware is performed by external, board-
|
/* Initialization of the CAN hardware is performed by external, board-
|
||||||
* specific logic to running this test.
|
* specific logic to running this test.
|
||||||
@ -442,17 +499,33 @@ static int canard_daemon(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Open the CAN device for reading */
|
/* 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,
|
ret = canardNuttXInit(&canardnuttx_instance,
|
||||||
CONFIG_EXAMPLES_LIBCANARDV0_DEVPATH);
|
CONFIG_EXAMPLES_DRONECAN_DEVPATH);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
printf("canard_daemon: ERROR: open %s failed: %d\n",
|
printf("canard_daemon: ERROR: open %s failed: %d\n",
|
||||||
CONFIG_EXAMPLES_LIBCANARDV0_DEVPATH, errno);
|
CONFIG_EXAMPLES_DRONECAN_DEVPATH, errno);
|
||||||
errval = 2;
|
errval = 2;
|
||||||
goto errout_with_dev;
|
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
|
/* Show bit timing information if provided by the driver. Not all CAN
|
||||||
* drivers will support this IOCTL.
|
* 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),
|
canardInit(&canard, canard_memory_pool, sizeof(canard_memory_pool),
|
||||||
onTransferReceived, shouldAcceptTransfer, (void *)(12345));
|
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("canard_daemon: canard initialized\n");
|
||||||
printf("start node (ID: %d Name: %s)\n",
|
printf("start node (ID: %d Name: %s)\n",
|
||||||
CONFIG_EXAMPLES_LIBCANARDV0_NODE_ID,
|
CONFIG_EXAMPLES_DRONECAN_NODE_ID,
|
||||||
APP_NODE_NAME);
|
APP_NODE_NAME);
|
||||||
|
|
||||||
g_canard_daemon_started = true;
|
g_canard_daemon_started = true;
|
||||||
@ -487,7 +560,11 @@ static int canard_daemon(int argc, char *argv[])
|
|||||||
|
|
||||||
for (; ; )
|
for (; ; )
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_NET_CAN
|
||||||
|
processTxRxOnce(&socketcan, 10);
|
||||||
|
#else
|
||||||
processTxRxOnce(&canardnuttx_instance, 10);
|
processTxRxOnce(&canardnuttx_instance, 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
const uint64_t ts = getMonotonicTimestampUSec();
|
const uint64_t ts = getMonotonicTimestampUSec();
|
||||||
|
|
||||||
@ -498,8 +575,10 @@ static int canard_daemon(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN
|
||||||
errout_with_dev:
|
errout_with_dev:
|
||||||
canardNuttXClose(&canardnuttx_instance);
|
canardNuttXClose(&canardnuttx_instance);
|
||||||
|
#endif
|
||||||
|
|
||||||
g_canard_daemon_started = false;
|
g_canard_daemon_started = false;
|
||||||
printf("canard_daemon: Terminating!\n");
|
printf("canard_daemon: Terminating!\n");
|
||||||
@ -525,9 +604,17 @@ int main(int argc, FAR char *argv[])
|
|||||||
return EXIT_SUCCESS;
|
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",
|
ret = task_create("canard_daemon",
|
||||||
CONFIG_EXAMPLES_LIBCANARDV0_DAEMON_PRIORITY,
|
CONFIG_EXAMPLES_DRONECAN_DAEMON_PRIORITY,
|
||||||
CONFIG_EXAMPLES_LIBCANARDV0_STACKSIZE, canard_daemon,
|
CONFIG_EXAMPLES_DRONECAN_STACKSIZE, canard_daemon,
|
||||||
NULL);
|
NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
@ -3,45 +3,45 @@
|
|||||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
#
|
#
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV1
|
config EXAMPLES_LIBOPENCYPHAL
|
||||||
tristate "libcandard v1 example"
|
tristate "OpenCyphal Cyphal/CAN example"
|
||||||
default n
|
default n
|
||||||
depends on CANUTILS_LIBCANARDV1
|
depends on CANUTILS_LIBOPENCYPHAL
|
||||||
---help---
|
---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"
|
string "Device"
|
||||||
default "can0"
|
default "can0"
|
||||||
---help---
|
---help---
|
||||||
The device
|
The device
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV1_NODE_ID
|
config EXAMPLES_LIBOPENCYPHAL_NODE_ID
|
||||||
int "Node ID"
|
int "Node ID"
|
||||||
default 1
|
default 1
|
||||||
range 1 127
|
range 1 127
|
||||||
---help---
|
---help---
|
||||||
Specifies the node's ID
|
Specifies the node's ID
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV1_APP_NODE_NAME
|
config EXAMPLES_LIBOPENCYPHAL_APP_NODE_NAME
|
||||||
string "Node name"
|
string "Node name"
|
||||||
default "org.uavcan.libcanardv1.nuttx.demo"
|
default "org.apache.nuttx.demo"
|
||||||
---help---
|
---help---
|
||||||
app node name
|
app node name
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV1_NODE_MEM_POOL_SIZE
|
config EXAMPLES_LIBOPENCYPHAL_NODE_MEM_POOL_SIZE
|
||||||
int "Node Memory Pool Size"
|
int "Node Memory Pool Size"
|
||||||
default 1024
|
default 1024
|
||||||
---help---
|
---help---
|
||||||
Specifies the node's memory pool size
|
Specifies the node's memory pool size
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV1_DAEMON_PRIORITY
|
config EXAMPLES_LIBOPENCYPHAL_DAEMON_PRIORITY
|
||||||
int "daemon task priority"
|
int "daemon task priority"
|
||||||
default 100
|
default 100
|
||||||
|
|
||||||
config EXAMPLES_LIBCANARDV1_DAEMON_STACK_SIZE
|
config EXAMPLES_LIBOPENCYPHAL_DAEMON_STACK_SIZE
|
||||||
int "canard stack size"
|
int "canard stack size"
|
||||||
default DEFAULT_TASK_STACKSIZE
|
default DEFAULT_TASK_STACKSIZE
|
||||||
|
|
@ -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
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -18,6 +18,6 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifneq ($(CONFIG_EXAMPLES_LIBCANARDV1),)
|
ifneq ($(CONFIG_EXAMPLES_LIBOPENCYPHAL),)
|
||||||
CONFIGURED_APPS += $(APPDIR)/examples/canardv1
|
CONFIGURED_APPS += $(APPDIR)/examples/opencyphal
|
||||||
endif
|
endif
|
@ -1,5 +1,5 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# apps/examples/canardv1/Makefile
|
# apps/examples/opencyphal/Makefile
|
||||||
#
|
#
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -20,12 +20,15 @@
|
|||||||
|
|
||||||
include $(APPDIR)/Make.defs
|
include $(APPDIR)/Make.defs
|
||||||
|
|
||||||
PROGNAME = canardv1
|
PROGNAME = opencyphal
|
||||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||||
STACKSIZE = $(CONFIG_EXAMPLES_LIBCANARDV1_DAEMON_STACK_SIZE)
|
STACKSIZE = $(CONFIG_EXAMPLES_LIBOPENCYPHAL_DAEMON_STACK_SIZE)
|
||||||
MODULE = $(CONFIG_EXAMPLES_LIBCANARDV1)
|
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
|
CSRCS = socketcan.c
|
||||||
MAINSRC = canard_main.c
|
MAINSRC = 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
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
#define APP_VERSION_MAJOR 1
|
#define APP_VERSION_MAJOR 1
|
||||||
#define APP_VERSION_MINOR 0
|
#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
|
* Private Data
|
||||||
@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
/* Arena for memory allocation, used by the library */
|
/* 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 */
|
/* Temporary development UAVCAN topic service ID to publish/subscribe from */
|
||||||
#define PORT_ID 4421
|
#define PORT_ID 4421
|
||||||
@ -310,13 +310,13 @@ static int canard_daemon(int argc, char *argv[])
|
|||||||
ins.mtu_bytes = CANARD_MTU_CAN_CLASSIC;
|
ins.mtu_bytes = CANARD_MTU_CAN_CLASSIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
ins.node_id = (pub ? CONFIG_EXAMPLES_LIBCANARDV1_NODE_ID :
|
ins.node_id = (pub ? CONFIG_EXAMPLES_LIBOPENCYPHAL_NODE_ID :
|
||||||
CONFIG_EXAMPLES_LIBCANARDV1_NODE_ID + 1);
|
CONFIG_EXAMPLES_LIBOPENCYPHAL_NODE_ID + 1);
|
||||||
|
|
||||||
/* Open the CAN device for reading */
|
/* Open the CAN device for reading */
|
||||||
|
|
||||||
canardsocketinstance sock_ins;
|
canardsocketinstance sock_ins;
|
||||||
socketcanopen(&sock_ins, CONFIG_EXAMPLES_LIBCANARDV1_DEV, can_fd);
|
socketcanopen(&sock_ins, CONFIG_EXAMPLES_LIBOPENCYPHAL_DEV, can_fd);
|
||||||
|
|
||||||
/* setup poll fd */
|
/* setup poll fd */
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ static int canard_daemon(int argc, char *argv[])
|
|||||||
if (sock_ins.s < 0)
|
if (sock_ins.s < 0)
|
||||||
{
|
{
|
||||||
printf("canard_daemon: ERROR: open %s failed: %d\n",
|
printf("canard_daemon: ERROR: open %s failed: %d\n",
|
||||||
CONFIG_EXAMPLES_LIBCANARDV1_DEV, errno);
|
CONFIG_EXAMPLES_LIBOPENCYPHAL_DEV, errno);
|
||||||
errval = 2;
|
errval = 2;
|
||||||
goto errout_with_dev;
|
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;
|
int ret;
|
||||||
|
|
||||||
@ -395,8 +395,8 @@ int canardv1_main(int argc, FAR char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = task_create("canard_daemon",
|
ret = task_create("canard_daemon",
|
||||||
CONFIG_EXAMPLES_LIBCANARDV1_DAEMON_PRIORITY,
|
CONFIG_EXAMPLES_LIBOPENCYPHAL_DAEMON_PRIORITY,
|
||||||
CONFIG_EXAMPLES_LIBCANARDV1_DAEMON_STACK_SIZE,
|
CONFIG_EXAMPLES_LIBOPENCYPHAL_DAEMON_STACK_SIZE,
|
||||||
canard_daemon, argv);
|
canard_daemon, argv);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
@ -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
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
Loading…
x
Reference in New Issue
Block a user