From 1556424b92edbece957c8400d1a6f447a5001d59 Mon Sep 17 00:00:00 2001 From: "Paul A. Patience" Date: Thu, 12 May 2016 11:50:50 -0400 Subject: [PATCH] libcanard: Add libcanard UAVCAN library --- canutils/Kconfig | 1 + canutils/libcanard/.gitignore | 2 + canutils/libcanard/Kconfig | 27 +++++++++ canutils/libcanard/Make.defs | 39 ++++++++++++ canutils/libcanard/Makefile | 111 ++++++++++++++++++++++++++++++++++ include/canutils/.gitignore | 1 + 6 files changed, 181 insertions(+) create mode 100644 canutils/libcanard/.gitignore create mode 100644 canutils/libcanard/Kconfig create mode 100644 canutils/libcanard/Make.defs create mode 100644 canutils/libcanard/Makefile create mode 100644 include/canutils/.gitignore diff --git a/canutils/Kconfig b/canutils/Kconfig index 59830cba2..a0907602b 100644 --- a/canutils/Kconfig +++ b/canutils/Kconfig @@ -6,5 +6,6 @@ menu "CAN Utilities" source "$APPSDIR/canutils/uavcan/Kconfig" +source "$APPSDIR/canutils/libcanard/Kconfig" endmenu # CAN Utilities diff --git a/canutils/libcanard/.gitignore b/canutils/libcanard/.gitignore new file mode 100644 index 000000000..5ca33bd27 --- /dev/null +++ b/canutils/libcanard/.gitignore @@ -0,0 +1,2 @@ +/.built +/libcanard-* diff --git a/canutils/libcanard/Kconfig b/canutils/libcanard/Kconfig new file mode 100644 index 000000000..e4635cb63 --- /dev/null +++ b/canutils/libcanard/Kconfig @@ -0,0 +1,27 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config CANUTILS_LIBCANARD + bool "libcanard UAVCAN Library" + default n + depends on CAN && CAN_EXTID + ---help--- + Enable the libcanard UAVCAN library. + +if CANUTILS_LIBCANARD + +config LIBCANARD_URL + string "libcanard URL" + default "https://github.com/UAVCAN/libcanard/archive" + ---help--- + libcanard URL. + +config LIBCANARD_VERSION + string "libcanard Version" + default "34195e7f13637bdc79198c94bd1b2e5ecffe9383" + ---help--- + libcanard version. + +endif diff --git a/canutils/libcanard/Make.defs b/canutils/libcanard/Make.defs new file mode 100644 index 000000000..22cd3e077 --- /dev/null +++ b/canutils/libcanard/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# apps/canutils/libcanard/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved. +# Author: Paul Alexander Patience +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_CANUTILS_LIBCANARD),y) +CONFIGURED_APPS += canutils/libcanard +endif diff --git a/canutils/libcanard/Makefile b/canutils/libcanard/Makefile new file mode 100644 index 000000000..79c2bb853 --- /dev/null +++ b/canutils/libcanard/Makefile @@ -0,0 +1,111 @@ +############################################################################ +# apps/canutils/libcanard/Makefile +# +# Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved. +# Authors: Paul Alexander Patience +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +WGET = wget +UNPACK = unzip +PACKEXT = .zip + +LIBCANARD_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARD_URL))) +LIBCANARD_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARD_VERSION))) +LIBCANARD_UNPACKNAME = libcanard-$(LIBCANARD_VERSION) +LIBCANARD_PACKNAME = $(LIBCANARD_UNPACKNAME)$(PACKEXT) +LIBCANARD_SRCDIR = $(LIBCANARD_UNPACKNAME)$(DELIM)src + +CSRCS = $(LIBCANARD_SRCDIR)$(DELIM)canard.c +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(CSRCS) +OBJS = $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)$(DELIM)libapps$(LIBEXT)}" +else + BIN = $(APPDIR)$(DELIM)libapps$(LIBEXT) +endif + +ROOTDEPPATH = --dep-path . + +VPATH = + +all: .built +.PHONY: clean depend distclean + +$(LIBCANARD_PACKNAME): + @echo "Downloading: $@" + $(Q) $(WGET) -O $@ $(LIBCANARD_URL)$(DELIM)$(LIBCANARD_VERSION)$(PACKEXT) + +$(LIBCANARD_UNPACKNAME): $(LIBCANARD_PACKNAME) + @echo "Unpacking: $< -> $@" + $(Q) $(UNPACK) $< + $(Q) touch $@ + +$(LIBCANARD_SRCDIR)$(DELIM)canard.h: $(LIBCANARD_UNPACKNAME) + +$(APPDIR)$(DELIM)include$(DELIM)canutils$(DELIM)canard.h: $(LIBCANARD_SRCDIR)$(DELIM)canard.h + $(Q) cp $< $@ + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + $(Q) touch $@ + +install: + +context: $(APPDIR)$(DELIM)include$(DELIM)canutils$(DELIM)canard.h + +.depend: Makefile $(SRCS) + $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + $(foreach OBJ, $(OBJS), $(call DELFILE, $(OBJ))) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + $(call DELFILE, $(APPDIR)$(DELIM)include$(DELIM)canutils$(DELIM)canard.h) + $(call DELDIR, $(LIBCANARD_UNPACKNAME)) + $(call DELFILE, $(LIBCANARD_PACKNAME)) + +-include Make.dep diff --git a/include/canutils/.gitignore b/include/canutils/.gitignore new file mode 100644 index 000000000..369d64802 --- /dev/null +++ b/include/canutils/.gitignore @@ -0,0 +1 @@ +/canard.h