From a2cc6cbb9d2ef2a1f6a8d1c77f932e6af544ed66 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Wed, 11 Mar 2015 14:26:50 +0100 Subject: [PATCH] move STRINGIFY macro to std.h and use it a bit more --- conf/airframes/bebop.xml | 2 +- conf/modules/logger_file.xml | 26 +++++++++++-------- conf/modules/video_rtp_stream.xml | 2 +- .../modules/computer_vision/viewvideo.c | 5 +--- sw/airborne/modules/loggers/file_logger.c | 8 +++--- sw/include/pprz_version.h | 2 ++ sw/include/std.h | 4 +++ 7 files changed, 29 insertions(+), 20 deletions(-) diff --git a/conf/airframes/bebop.xml b/conf/airframes/bebop.xml index 24714be401..4d89a43048 100644 --- a/conf/airframes/bebop.xml +++ b/conf/airframes/bebop.xml @@ -28,7 +28,7 @@ diff --git a/conf/modules/logger_file.xml b/conf/modules/logger_file.xml index 52c4f3ba09..a33f38d497 100644 --- a/conf/modules/logger_file.xml +++ b/conf/modules/logger_file.xml @@ -1,15 +1,19 @@ - - Logs to a csv file (only for linux) - -
- -
- - - - + + + Logs to a csv file. + (only for linux) + + + +
+ +
+ + + +
diff --git a/conf/modules/video_rtp_stream.xml b/conf/modules/video_rtp_stream.xml index 6907588379..dc32405153 100644 --- a/conf/modules/video_rtp_stream.xml +++ b/conf/modules/video_rtp_stream.xml @@ -50,7 +50,7 @@ VIEWVIDEO_BROADCAST ?= $(MODEM_BROADCAST) VIEWVIDEO_DEV_LOWER = $(shell echo $(VIEWVIDEO_DEV) | tr A-Z a-z) - VIEWVID_G_CFLAGS = -DVIEWVIDEO_HOST=\"$(VIEWVIDEO_HOST)\" -DVIEWVIDEO_PORT_OUT=$(VIEWVIDEO_PORT_OUT) + VIEWVID_G_CFLAGS = -DVIEWVIDEO_HOST=$(VIEWVIDEO_HOST) -DVIEWVIDEO_PORT_OUT=$(VIEWVIDEO_PORT_OUT) VIEWVID_CFLAGS = -DUSE_$(VIEWVIDEO_DEV) -DVIEWVIDEO_DEV=$(VIEWVIDEO_DEV_LOWER) VIEWVID_CFLAGS += -D$(VIEWVIDEO_DEV)_PORT_OUT=$(VIEWVIDEO_PORT_OUT) -D$(VIEWVIDEO_DEV)_PORT_IN=$(VIEWVIDEO_PORT_IN) VIEWVID_CFLAGS += -D$(VIEWVIDEO_DEV)_BROADCAST=$(VIEWVIDEO_BROADCAST) -D$(VIEWVIDEO_DEV)_HOST=\"$(VIEWVIDEO_HOST)\" diff --git a/sw/airborne/modules/computer_vision/viewvideo.c b/sw/airborne/modules/computer_vision/viewvideo.c index 7fb4a516e7..85ebd24e3e 100644 --- a/sw/airborne/modules/computer_vision/viewvideo.c +++ b/sw/airborne/modules/computer_vision/viewvideo.c @@ -49,9 +49,6 @@ // Threaded computer vision #include -#define _STRINGIFY(s) #s -#define STRINGIFY(s) _STRINGIFY(s) - // The video device #ifndef VIEWVIDEO_DEVICE #define VIEWVIDEO_DEVICE /dev/video1 @@ -158,7 +155,7 @@ static void *viewvideo_thread(void *data __attribute__((unused))) #if VIEWVIDEO_USE_NETCAT char nc_cmd[64]; - sprintf(nc_cmd, "nc %s %d 2>/dev/null", VIEWVIDEO_HOST, VIEWVIDEO_PORT_OUT); + sprintf(nc_cmd, "nc %s %d 2>/dev/null", STRINGIFY(VIEWVIDEO_HOST), VIEWVIDEO_PORT_OUT); #endif // Start streaming diff --git a/sw/airborne/modules/loggers/file_logger.c b/sw/airborne/modules/loggers/file_logger.c index 31bf528e27..1019d08646 100644 --- a/sw/airborne/modules/loggers/file_logger.c +++ b/sw/airborne/modules/loggers/file_logger.c @@ -27,13 +27,15 @@ #include "file_logger.h" #include +#include "std.h" + #include "subsystems/imu.h" #include "firmwares/rotorcraft/stabilization.h" #include "state.h" /** Set the default File logger path to the USB drive */ #ifndef FILE_LOGGER_PATH -#define FILE_LOGGER_PATH "/data/video/usb/" +#define FILE_LOGGER_PATH /data/video/usb #endif /** The file pointer */ @@ -46,12 +48,12 @@ void file_logger_start(void) char filename[512]; // Check for available files - sprintf(filename, "%s%05d.csv", FILE_LOGGER_PATH, counter); + sprintf(filename, "%s/%05d.csv", STRINGIFY(FILE_LOGGER_PATH), counter); while ((file_logger = fopen(filename, "r"))) { fclose(file_logger); counter++; - sprintf(filename, "%s%05d.csv", FILE_LOGGER_PATH, counter); + sprintf(filename, "%s/%05d.csv", STRINGIFY(FILE_LOGGER_PATH), counter); } file_logger = fopen(filename, "w"); diff --git a/sw/include/pprz_version.h b/sw/include/pprz_version.h index dfa7ffa619..929a070190 100644 --- a/sw/include/pprz_version.h +++ b/sw/include/pprz_version.h @@ -45,8 +45,10 @@ extern "C" { #endif +#ifndef STRINGIFY #define _STRINGIFY(s) #s #define STRINGIFY(s) _STRINGIFY(s) +#endif #define GIT_VERSION STRINGIFY(GIT_SHA1) #define PPRZ_VERSION_DESC STRINGIFY(GIT_DESC) diff --git a/sw/include/std.h b/sw/include/std.h index 42f0879970..93eaf18131 100644 --- a/sw/include/std.h +++ b/sw/include/std.h @@ -33,6 +33,10 @@ /* some convenience macros to print debug/config messages at compile time */ #include "message_pragmas.h" +/* stringify a define, e.g. one that was not quoted */ +#define _STRINGIFY(s) #s +#define STRINGIFY(s) _STRINGIFY(s) + #ifndef FALSE #define FALSE 0 #endif