From d01476a661466bf14eeb5bafdfccfd34687e8075 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Thu, 25 Jun 2020 22:37:13 +0200 Subject: [PATCH] dist/tools/openvisualizer: inital support --- Makefile.include | 4 + dist/tools/openvisualizer/logging.conf | 236 ++++++++++++++++++ .../makefile.openvisualizer.inc.mk | 93 +++++++ 3 files changed, 333 insertions(+) create mode 100644 dist/tools/openvisualizer/logging.conf create mode 100644 dist/tools/openvisualizer/makefile.openvisualizer.inc.mk diff --git a/Makefile.include b/Makefile.include index 8056a026f3..40956332b2 100644 --- a/Makefile.include +++ b/Makefile.include @@ -896,6 +896,10 @@ ifneq (,$(filter iotlab-m3 wsn430-v1_3b wsn430-v1_4,$(BOARD))) endif endif +ifneq (,$(filter openv-%,$(MAKECMDGOALS))) + include $(RIOTBASE)/dist/tools/openvisualizer/makefile.openvisualizer.inc.mk +endif + # Include desvirt Makefile include $(RIOTTOOLS)/desvirt/Makefile.desvirt diff --git a/dist/tools/openvisualizer/logging.conf b/dist/tools/openvisualizer/logging.conf new file mode 100644 index 0000000000..ab17387a04 --- /dev/null +++ b/dist/tools/openvisualizer/logging.conf @@ -0,0 +1,236 @@ +# Note Expects 'logDir' passed in with location for file output. + +#============================ formatters =============================== + +[formatters] +keys=std, console + +[formatter_std] +format=%(asctime)s [%(name)s:%(levelname)s] %(message)s +datefmt=%H:%M:%S + +[formatter_console] +class=openvisualizer.main.ColoredFormatter +format=%(asctime)s [%(name)s:%(levelname)s] %(message)s +datefmt=%H:%M:%S + +#============================ handlers ================================= + +[handlers] +keys=std,console + +[handler_std] +class=handlers.RotatingFileHandler +# args: filename, open mode, max file size, backup file count +args=('LOG_PATH/openv-server.log', 'a', 2000000, 5) +formatter=std + +[handler_console] +class=StreamHandler +args=() +formatter=console + +#============================ loggers ================================== + +[loggers] +keys= + root, + EventBusMonitor, + EventBusClient, + OpenTun, + OpenTunMacOS, + OpenTunWindows, + OpenTunLinux, + MoteConnector, + MoteProbe, + MoteState, + OpenParser, + ParserData, + ParserPrintf, + ParserIEC, + ParserStatus, + Parser, + OpenHdlc, + OpenLbr, + SixLowPanFrag, + RPL, + SourceRoute, + JRC, + Topology, + OpenVisualizerServer, + Utils, + OVWebServer, + OVtracer, + CoAP + +[logger_root] +level=ERROR +handlers=std + +[logger_EventBusMonitor] +level=ERROR +handlers=std +propagate=0 +qualname=EventBusMonitor + +[logger_EventBusClient] +level=ERROR +handlers=std +propagate=0 +qualname=EventBusClient + +[logger_OpenTun] +level=ERROR +handlers=std +propagate=0 +qualname=OpenTun + +[logger_OpenTunWindows] +level=INFO +handlers=std, console +propagate=0 +qualname=OpenTunWindows + +[logger_OpenTunLinux] +level=INFO +handlers=std, console +propagate=0 +qualname=OpenTunLinux + +[logger_OpenTunMacOS] +level=INFO +handlers=std, console +propagate=0 +qualname=OpenTunMacOS + +[logger_MoteConnector] +level=ERROR +handlers=std +propagate=0 +qualname=MoteConnector + +[logger_MoteProbe] +level=INFO +handlers=std, console +propagate=0 +qualname=MoteProbe + +[logger_MoteState] +level=ERROR +handlers=std +propagate=0 +qualname=MoteState + +[logger_OpenParser] +level=ERROR +handlers=std +propagate=0 +qualname=OpenParser + +[logger_Parser] +level=ERROR +handlers=std +propagate=0 +qualname=Parser + +[logger_ParserIEC] +level=VERBOSE +handlers=std, console +propagate=0 +qualname=ParserIEC + +[logger_ParserData] +level=ERROR +handlers=std +propagate=0 +qualname=ParserData + +[logger_ParserPrintf] +level=INFO +handlers=std, console +propagate=0 +qualname=ParserPrintf + +[logger_ParserPacket] +level=ERROR +handlers=std +propagate=0 +qualname=ParserPacket + +[logger_ParserStatus] +level=ERROR +handlers=std +propagate=0 +qualname=ParserStatus + +[logger_OpenHdlc] +level=ERROR +handlers=std +propagate=0 +qualname=OpenHdlc + +[logger_OpenLbr] +level=ERROR +handlers=std +propagate=0 +qualname=OpenLbr + +[logger_SixLowPanFrag] +level=INFO +handlers=std +propagate=0 +qualname=SixLowPanFrag + +[logger_RPL] +level=INFO +handlers=std, console +propagate=0 +qualname=RPL + +[logger_SourceRoute] +level=ERROR +handlers=std +propagate=0 +qualname=SourceRoute + +[logger_JRC] +level=VERBOSE +handlers=std, console +propagate=0 +qualname=JRC + +[logger_Topology] +level=ERROR +handlers=std +propagate=0 +qualname=Topology + +[logger_OpenVisualizerServer] +level=VERBOSE +handlers=std, console +propagate=0 +qualname=OpenVisualizerServer + +[logger_Utils] +level=VERBOSE +handlers=std, console +propagate=0 +qualname=Utils + +[logger_OVWebServer] +level=INFO +handlers=std +propagate=0 +qualname=OVWebServer + +[logger_OVtracer] +level=INFO +handlers=std, console +propagate=0 +qualname=OVtracer + +[logger_CoAP] +level=INFO +handlers=std, console +propagate=0 +qualname=coap diff --git a/dist/tools/openvisualizer/makefile.openvisualizer.inc.mk b/dist/tools/openvisualizer/makefile.openvisualizer.inc.mk new file mode 100644 index 0000000000..43dd8cf062 --- /dev/null +++ b/dist/tools/openvisualizer/makefile.openvisualizer.inc.mk @@ -0,0 +1,93 @@ +.PHONY: openv-clean openv-setroot openv-term openv-termroot + +# Use a single board with openv +# =================================== +# +# OpenVisualizer runs on port 9000 by default, if that ports conflicts or +# multiple instances are spawned you will need to specify the port, eg. +# * `OPENV_FLAGS='--port=9001` +# +# Not all logs for openvisualizer are piped to the terminal, more detailed logs +# are stored in $(BINDIR)/openv-server.log +# +# More info at https://github.com/fjmolinas/openvisualizer/blob/develop_SW-318-RIOT/README.md +# +# Supported: +# * openv-term +# * openv-termroot +# * openv-termtun +# * openv-setroot +# * openv-clean +# * openv-serial +# +# Prerequisites +# ------------- +# +# * Install openvisualizer: +# * git clone -b develop_SW-318-RIOT https://github.com/fjmolinas/openvisualizer.git +# * cd openvisualizer +# * pip2 install . +# +# * If using iotlab nodes, pre-requisites in makefile.iotlab.single.inc.mk +# +# * For `openv-termtun` it will require root must be able to ssh into iotlab +# + +# Use full path in case it needs to be run with sudo +OPENV_SERVER_PATH := $(shell which openv-server) +OPENV_CLIENT_PATH := $(shell which openv-client) +OPENV_SERIAL_PATH := $(shell which openv-serial) + +# Openvisualizer requires to know where openwsn-fw is located +OPENV_OPENWSN_FW_PATH ?= --fw-path=$(RIOTBASE)/build/pkg/openwsn +OPENV_DEFAULT_FLAGS += $(OPENV_OPENWSN_FW_PATH) + +OPENV_DEFAULT_FLAGS ?= + +ifneq (,$(IOTLAB_NODE)) + OPENV_MOTE ?= $(IOTLAB_NODE) + OPENV_DEFAULT_FLAGS += --iotlab-motes=$(IOTLAB_NODE) +else + OPENV_MOTE += $(PORT) + OPENV_DEFAULT_FLAGS += --port-mask=$(OPENV_MOTE) --baudrate=$(BAUD) +endif + +# Use modified logging configuration +OPENV_LOG_CONFIG = $(BINDIR)/logging.conf +OPENV_LOG_FILE = $(BINDIR)/openv-server.log +OPENV_DEFAULT_FLAGS += --lconf=$(OPENV_LOG_CONFIG) + +$(OPENV_LOG_CONFIG): $(LAST_MAKEFILEDIR)/logging.conf + $(Q)cp $^ $@.tmp + $(Q)sed -i 's#LOG_PATH#'"$(BINDIR)"'#g' $@.tmp + $(Q)mv $@.tmp $@ + +# Start tun interface +ifneq (,$(filter openv-termtun,$(MAKECMDGOALS))) + OPENV_DEFAULT_FLAGS += --opentun +endif + +# Optional flags to pass through command line +OPENV_FLAGS ?= + +openv-term: $(OPENV_LOG_CONFIG) +openv-term: $(TERMDEPS) + $(Q)$(OPENV_SERVER_PATH) $(OPENV_DEFAULT_FLAGS) $(OPENV_FLAGS) + +openv-termroot: $(OPENV_LOG_CONFIG) +openv-termroot: $(TERMDEPS) + $(Q)$(OPENV_SERVER_PATH) $(OPENV_DEFAULT_FLAGS) $(OPENV_FLAGS) --root=$(OPENV_MOTE) + +openv-termtun: $(OPENV_LOG_CONFIG) +openv-termtun: $(TERMDEPS) + sudo $(OPENV_SERVER_PATH) $(OPENV_DEFAULT_FLAGS) $(OPENV_FLAGS) --root=$(OPENV_MOTE) + +openv-setroot: + $(Q)$(OPENV_CLIENT_PATH) $(OPENV_OPENWSN_FW_PATH) $(OPENV_FLAGS) root=$(OPENV_MOTE) + +openv-clean: + $(Q)rm -rf $(OPENV_LOG_CONFIG) + $(Q)rm -rf $(OPENV_LOG_FILE) + +openv-serial: + $(Q)$(OPENV_SERIAL_PATH) --port=$(PORT) --baudrate=$(BAUD)