From ed1f6881e30d3efb49313d2958541ce4dac8fee5 Mon Sep 17 00:00:00 2001 From: Vladimir Zidar Date: Sat, 7 Oct 2017 15:30:18 +0200 Subject: [PATCH] LP-432 Automatically generate -DHAS_xxx_MODULE for *all* included modules. Use HAS_LOGGING_MODULE inside telemetry.c/setLoggingPeriod() to void function if logging module is not included. --- flight/make/apps-defs.mk | 4 ++++ flight/modules/Telemetry/telemetry.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/flight/make/apps-defs.mk b/flight/make/apps-defs.mk index 106077574..77620dabf 100644 --- a/flight/make/apps-defs.mk +++ b/flight/make/apps-defs.mk @@ -169,6 +169,10 @@ MODNAMES := $(notdir $(subst /revolution,,$(MODULES))) MODULES_BUILTIN := $(foreach mod, $(MODNAMES), -DMODULE_$(shell echo $(mod) | tr '[:lower:]' '[:upper:]')_BUILTIN) CDEFS += $(MODULES_BUILTIN) +MODNAMES_ALL := $(notdir $(subst /revolution,,$(OPTMODULES) $(MODULES))) +MODULES_ALL := $(foreach mod, $(MODNAMES_ALL), -DHAS_$(shell echo $(mod) | tr '[:lower:]' '[:upper:]')_MODULE) +CDEFS += $(MODULES_ALL) + # List C source files here which must be compiled in ARM-Mode (no -mthumb). # Use file-extension c for "c-only"-files SRCARM += diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index a3bbf0a77..67d2e770f 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -777,6 +777,7 @@ static int32_t setLoggingPeriod( UAVObjHandle obj, int32_t updatePeriodMs) { +#ifdef HAS_LOGGING_MODULE UAVObjEvent ev; int32_t ret; @@ -798,6 +799,14 @@ static int32_t setLoggingPeriod( ret = EventPeriodicQueueCreate(&ev, targetQueue, updatePeriodMs); } return ret; + +#else /* HAS_LOGGING_MODULE */ + (void)channel; + (void)obj; + (void)updatePeriodMs; + return 0; + +#endif /* ifdef HAS_LOGGING_MODULE */ } /**