Skip to content

Commit

Permalink
PPRZLINK v2.0
Browse files Browse the repository at this point in the history
This is following the roadmap as described here:
http://wiki.paparazziuav.org/wiki/Roadmap#Communication_Roadmap

Header size is increased by 2 bytes, allowing to include receiver, class
and component IDs to the two existing byte (sender and message IDs).
This will allow in particular to send messages from aircraft to aircraft
without ambiguity.
All libraries have been updated (except for IVY part, unchanged but
compatible). The version to be used is selected during the install.
The generated C code has backward compatible macros and functions, plus
new API to use full capabilities of the new protocol.
  • Loading branch information
gautierhattenberger committed Jun 6, 2017
1 parent 4b883e6 commit 3d38267
Show file tree
Hide file tree
Showing 67 changed files with 4,741 additions and 139 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -19,3 +19,4 @@

/build
/var
/.idea/
43 changes: 16 additions & 27 deletions Makefile
Expand Up @@ -24,8 +24,11 @@ Q=@

MAKE = make

MESSAGES_XML ?= message_definitions/v1.0/messages.xml
MESSAGES_DTD ?= message_definitions/v1.0/messages.dtd
PPRZLINK_MSG_VERSION ?= 1.0
PPRZLINK_LIB_VERSION ?= 1.0

MESSAGES_XML ?= message_definitions/v$(PPRZLINK_MSG_VERSION)/messages.xml
MESSAGES_DTD ?= message_definitions/v$(PPRZLINK_MSG_VERSION)/messages.dtd
UNITS_XML ?= message_definitions/common/units.xml
MESSAGES_INSTALL ?= var
MESSAGES_INCLUDE ?= $(MESSAGES_INSTALL)/include/pprzlink
Expand All @@ -43,49 +46,35 @@ else
VALIDATE_FLAG =
endif

all: libs

libs: ocaml_lib_v1

generators: ocaml_lib_v1
$(Q)$(MAKE) -C tools/generator install
all: libpprzlink

ocaml_lib_v1:
$(Q)$(MAKE) -C lib/v1.0/ocaml
libpprzlink:
$(Q)Q=$(Q) $(MAKE) -C lib/v$(PPRZLINK_LIB_VERSION)/ocaml

libpprzlink-install:
$(Q)$(MAKE) -C lib/v1.0/ocaml install
$(Q)Q=$(Q) DESTDIR=$(DESTDIR)/ocaml $(MAKE) -C lib/v$(PPRZLINK_LIB_VERSION)/ocaml install
$(Q)Q=$(Q) DESTDIR=$(DESTDIR)/python $(MAKE) -C lib/v$(PPRZLINK_LIB_VERSION)/python install

pre_messages_dir:
$(Q)test -d $(MESSAGES_INCLUDE) || mkdir -p $(MESSAGES_INCLUDE)
$(Q)test -d $(MESSAGES_LIB) || mkdir -p $(MESSAGES_LIB)

gen_messages: generators pre_messages_dir
@echo 'Generate C messages (OCaml) at location $(MESSAGES_INCLUDE)'
$(Q)./bin/gen_messages_c.byte $(MESSAGES_XML) telemetry $(TELEMETRY_H)
$(Q)./bin/gen_messages_c.byte $(MESSAGES_XML) datalink $(DATALINK_H)
$(Q)./bin/gen_messages_c.byte $(MESSAGES_XML) intermcu $(INTERMCU_H)
$(Q)cp tools/generator/C/include_v1.0/*.h $(MESSAGES_INCLUDE)

post_messages_install:
@echo 'Copy extra lib files'
$(Q)cp $(MESSAGES_XML) $(MESSAGES_DTD) $(UNITS_XML) $(MESSAGES_INSTALL)
$(Q)cp lib/v1.0/C/*.h $(MESSAGES_INCLUDE)
$(Q)cp lib/v1.0/C/*.c $(MESSAGES_LIB)
$(Q)Q=$(Q) MESSAGES_INCLUDE=$(MESSAGES_INCLUDE) MESSAGES_LIB=$(MESSAGES_LIB) $(MAKE) -C lib/v$(PPRZLINK_LIB_VERSION)/C install

pygen_messages: pre_messages_dir
@echo 'Generate C messages (Python) at location $(MESSAGES_INCLUDE)'
$(Q)./tools/generator/gen_messages.py $(VALIDATE_FLAG) --lang C -o $(TELEMETRY_H) $(MESSAGES_XML) telemetry
$(Q)./tools/generator/gen_messages.py $(VALIDATE_FLAG) --lang C -o $(DATALINK_H) $(MESSAGES_XML) datalink
$(Q)./tools/generator/gen_messages.py $(VALIDATE_FLAG) --lang C -o $(INTERMCU_H) $(MESSAGES_XML) intermcu

messages: gen_messages post_messages_install
$(Q)./tools/generator/gen_messages.py $(VALIDATE_FLAG) --protocol $(PPRZLINK_LIB_VERSION) --messages $(PPRZLINK_MSG_VERSION) --lang C -o $(TELEMETRY_H) $(MESSAGES_XML) telemetry
$(Q)./tools/generator/gen_messages.py $(VALIDATE_FLAG) --protocol $(PPRZLINK_LIB_VERSION) --messages $(PPRZLINK_MSG_VERSION) --lang C -o $(DATALINK_H) $(MESSAGES_XML) datalink
$(Q)./tools/generator/gen_messages.py $(VALIDATE_FLAG) --protocol $(PPRZLINK_LIB_VERSION) --messages $(PPRZLINK_MSG_VERSION) --lang C -o $(INTERMCU_H) $(MESSAGES_XML) intermcu

pymessages: pygen_messages post_messages_install

clean :
$(Q)$(MAKE) -C tools/generator clean
$(Q)$(MAKE) -C lib/v1.0/ocaml clean
$(Q)$(MAKE) -C lib/v$(PPRZLINK_LIB_VERSION)/ocaml clean

uninstall: clean
$(Q)rm -rf var bin build $(MESSAGES_INCLUDE) $(MESSAGES_LIB)
Expand All @@ -95,4 +84,4 @@ validate_messages:
$(Q)./tools/generator/gen_messages.py --only-validate $(MESSAGES_XML) datalink
$(Q)./tools/generator/gen_messages.py --only-validate $(MESSAGES_XML) intermcu

.PHONY: all libs generators ocaml_lib_v1 pre_messages_dir post_messages_install gen_messages pygen_messages messages pymessages clean uninstall validate_messages
.PHONY: libpprzlink libpprzlink-install pre_messages_dir post_messages_install pygen_messages pymessages clean uninstall validate_messages
File renamed without changes.
123 changes: 123 additions & 0 deletions lib/common/ocaml/Makefile
@@ -0,0 +1,123 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2003 Pascal Brisset, Antoine Drouin
# Copyright (C) 2015 Gautier Hattenberger <gautier.hattenberger@enac.fr>
#
# This file is part of paparazzi.
#
# paparazzi is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# paparazzi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with paparazzi; see the file COPYING. If not, see
# <http://www.gnu.org/licenses/>.
#

# Quiet compilation
Q=@

# redirect output if quiet compilation
ifeq ($(Q),@)
QUIET= -quiet
Q_OUT= >/dev/null 2>&1
else
Q_OUT=
endif


OCAMLBUILD=ocamlbuild -use-ocamlfind
CAMLP4_DEFS ?=

#
# NOTE: due to a bug in older ocamlbuild versions the build-dir can NOT be absolute
# see http://caml.inria.fr/mantis/view.php?id=5503
#
OCAML_VERSION := $(shell ocamlc -version)
OCAML_MAJOR := $(shell echo $(OCAML_VERSION) | cut -f1 -d.)
OCAMLC_MINOR := $(shell echo $(OCAML_VERSION) | cut -f2 -d.)
ifeq ($(shell test $(OCAML_MAJOR) -lt 4; echo $$?),0)
# need to use an old buggy ocaml(build) version: build-dir MUST be relative
BUILDDIR ?= ../../../build/ocaml/pprzlink
else
# using a recent ocaml(build) version without THAT particular bug,
# but build-dir MUST NOT contain ..
# so use some magic here to get a normalized absolute path if PPRZLINK_DIR is not set
PPRZLINK_DIR ?= $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/../../..)
BUILDDIR ?= $(PPRZLINK_DIR)/build/ocaml/pprzlink

ifeq ($(shell test $(OCAMLC_MINOR) -ge 2; echo $$?),0)
# the Bytes module is available since OCaml 4.02.0
CAMLP4_DEFS += -DHAS_BYTES_MODULE
endif
endif

INSTALL_FLAGS ?=
# use this option leave ocamlfind ldconf file unchanged
INSTALL_FLAGS += -ldconf ignore
DESTDIR ?=
ifneq ($(DESTDIR),)
INSTALL_FLAGS += -destdir $(DESTDIR)
endif

PP_OPTS = -pp "camlp4o pa_macro.cmo $(CAMLP4_DEFS)"
INSTALL_FILES = $(shell ls $(BUILDDIR)/*.so $(BUILDDIR)/*.a $(BUILDDIR)/*.mli $(BUILDDIR)/*.cm* $(BUILDDIR)/common/*.mli $(BUILDDIR)/common/*.cm*)


all: byte native

byte: _tags META
@echo Build bytecode lib
$(Q)test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
$(Q)$(OCAMLBUILD) $(QUIET) $(PP_OPTS) -build-dir $(BUILDDIR) -I common lib-pprzlink.cma
$(Q)cp META $(BUILDDIR)

# byte with statically linked libs
static: _tags META
@echo Build bytecode lib with static linking
$(Q)test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
$(Q)$(OCAMLBUILD) $(QUIET) -build-dir $(BUILDDIR) -tag static -I common lib-pprzlink.cma
$(Q)cp META $(BUILDDIR)

native: _tags META
@echo Build native lib
$(Q)test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
$(Q)$(OCAMLBUILD) $(QUIET) $(PP_OPTS) -build-dir $(BUILDDIR) -I common lib-pprzlink.cmxa
$(Q)cp META $(BUILDDIR)

install: clean_lib byte native META
@echo INSTALL at location $(DESTDIR)
$(Q)test -d $(DESTDIR) || mkdir -p $(DESTDIR)
$(Q)ocamlfind remove $(INSTALL_FLAGS) pprzlink $(Q_OUT)
$(Q)ocamlfind install $(INSTALL_FLAGS) pprzlink META $(INSTALL_FILES) $(Q_OUT)

UNAME = $(shell uname -s)
ifeq ("$(UNAME)","Darwin")
MKTEMP = gmktemp
else
MKTEMP = mktemp
endif

clean :
$(Q)rm -f *.cm* *.out *.opt .depend *.a *.o *.so
$(Q)ocamlbuild -clean -classic-display -build-dir $(BUILDDIR)

# test if an other version of the lib is installed and remove if needed
clean_lib:
@echo Check for already installed pprzlink ocaml lib
ifneq ("$(wildcard $(DESTDIR)/pprzlink/META)","")
@echo ' -> found lib version $(shell grep version $(DESTDIR)/pprzlink/META | cut -d \" -f2) while installing $(PPRZLINK_LIB_VERSION)'
ifneq ($(shell grep version $(DESTDIR)/pprzlink/META | cut -d \" -f2), $(PPRZLINK_LIB_VERSION))
@echo ' -> removing files'
$(Q)ocamlbuild -clean -classic-display -build-dir $(BUILDDIR)
$(Q)ocamlfind remove $(INSTALL_FLAGS) pprzlink $(Q_OUT)
endif
endif

.PHONY: all byte static native install install_local clean clean_lib
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions lib/v1.0/C/Makefile
@@ -0,0 +1,33 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2017 Fabien Garcia <fabien.garcia@enac.fr>
#
# This file is part of paparazzi.
#
# paparazzi is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# paparazzi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with paparazzi; see the file COPYING. If not, see
# <http://www.gnu.org/licenses/>.
#

MAKE = make

all:

install:
# $(Q)cp ../../common/C/*.c $(MESSAGES_LIB)
$(Q)cp ../../common/C/*.h $(MESSAGES_INCLUDE)
$(Q)cp ./*.h $(MESSAGES_INCLUDE)
$(Q)cp ./*.c $(MESSAGES_LIB)


.PHONY: install
92 changes: 2 additions & 90 deletions lib/v1.0/ocaml/Makefile
@@ -1,7 +1,6 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2003 Pascal Brisset, Antoine Drouin
# Copyright (C) 2015 Gautier Hattenberger <gautier.hattenberger@enac.fr>
# Copyright (C) 2017 Gautier Hattenberger <gautier.hattenberger@enac.fr>
#
# This file is part of paparazzi.
#
Expand All @@ -20,92 +19,5 @@
# <http://www.gnu.org/licenses/>.
#

# Quiet compilation
Q=@
include ../../common/ocaml/Makefile

# redirect output if quiet compilation
ifeq ($(Q),@)
QUIET= -quiet
Q_OUT= >/dev/null 2>&1
else
Q_OUT=
endif


OCAMLBUILD=ocamlbuild -use-ocamlfind
CAMLP4_DEFS ?=

#
# NOTE: due to a bug in older ocamlbuild versions the build-dir can NOT be absolute
# see http://caml.inria.fr/mantis/view.php?id=5503
#
OCAML_VERSION := $(shell ocamlc -version)
OCAML_MAJOR := $(shell echo $(OCAML_VERSION) | cut -f1 -d.)
OCAMLC_MINOR := $(shell echo $(OCAML_VERSION) | cut -f2 -d.)
ifeq ($(shell test $(OCAML_MAJOR) -lt 4; echo $$?),0)
# need to use an old buggy ocaml(build) version: build-dir MUST be relative
BUILDDIR ?= ../../../build/ocaml/pprzlink
else
# using a recent ocaml(build) version without THAT particular bug,
# but build-dir MUST NOT contain ..
# so use some magic here to get a normalized absolute path if PPRZLINK_DIR is not set
PPRZLINK_DIR ?= $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/../../..)
BUILDDIR ?= $(PPRZLINK_DIR)/build/ocaml/pprzlink

ifeq ($(shell test $(OCAMLC_MINOR) -ge 2; echo $$?),0)
# the Bytes module is available since OCaml 4.02.0
CAMLP4_DEFS += -DHAS_BYTES_MODULE
endif
endif

INSTALL_FLAGS ?=
# use this option leave ocamlfind ldconf file unchanged
INSTALL_FLAGS += -ldconf ignore
DESTDIR ?=
ifneq ($(DESTDIR),)
INSTALL_FLAGS += -destdir $(DESTDIR)
endif

PP_OPTS = -pp "camlp4o pa_macro.cmo $(CAMLP4_DEFS)"
INSTALL_FILES = $(shell ls $(BUILDDIR)/*.so $(BUILDDIR)/*.a $(BUILDDIR)/*.mli $(BUILDDIR)/*.cm*)


all: byte native

byte: _tags META
@echo Build bytecode lib
$(Q)test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
$(Q)$(OCAMLBUILD) $(QUIET) $(PP_OPTS) -build-dir $(BUILDDIR) lib-pprzlink.cma
$(Q)cp META $(BUILDDIR)

# byte with statically linked libs
static: _tags META
@echo Build bytecode lib with static linking
$(Q)test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
$(Q)$(OCAMLBUILD) $(QUIET) -build-dir $(BUILDDIR) -tag static lib-pprzlink.cma
$(Q)cp META $(BUILDDIR)

native: _tags META
@echo Build native lib
$(Q)test -d $(BUILDDIR) || mkdir -p $(BUILDDIR)
$(Q)$(OCAMLBUILD) $(QUIET) $(PP_OPTS) -build-dir $(BUILDDIR) lib-pprzlink.cmxa
$(Q)cp META $(BUILDDIR)

install: byte native META
@echo INSTALL at location $(DESTDIR)
$(Q)test -d $(DESTDIR) || mkdir -p $(DESTDIR)
$(Q)ocamlfind remove $(INSTALL_FLAGS) pprzlink $(Q_OUT)
$(Q)ocamlfind install $(INSTALL_FLAGS) pprzlink META $(INSTALL_FILES) $(Q_OUT)

UNAME = $(shell uname -s)
ifeq ("$(UNAME)","Darwin")
MKTEMP = gmktemp
else
MKTEMP = mktemp
endif

clean :
$(Q)rm -f *.cm* *.out *.opt .depend *.a *.o *.so
$(Q)ocamlbuild -clean -classic-display -build-dir $(BUILDDIR)

.PHONY: all byte static native install install_local clean
1 change: 1 addition & 0 deletions lib/v1.0/ocaml/common
34 changes: 34 additions & 0 deletions lib/v1.0/python/Makefile
@@ -0,0 +1,34 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2017 Fabien Garcia <fabien.garcia@enac.fr>
#
# This file is part of paparazzi.
#
# paparazzi is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# paparazzi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with paparazzi; see the file COPYING. If not, see
# <http://www.gnu.org/licenses/>.
#

MAKE = make

all:

install:
# Install correct version python library to DESTDIR
@echo INSTALL at location $(DESTDIR)
$(Q)test -d $(DESTDIR) || mkdir -p $(DESTDIR)
$(Q)cp -r pprzlink $(DESTDIR)


.PHONY: all install

0 comments on commit 3d38267

Please sign in to comment.