move STRINGIFY macro to std.h and use it a bit more

This commit is contained in:
Felix Ruess
2015-03-11 14:26:50 +01:00
parent a207d15c98
commit a2cc6cbb9d
7 changed files with 29 additions and 20 deletions
+1 -1
View File
@@ -28,7 +28,7 @@
<modules main_freq="512">
<load name="send_imu_mag_current.xml"/>
<!--load name="logger_file.xml">
<define name="FILE_LOGGER_PATH" value="\\\"/data/ftp/internal_000/\\\""/>
<define name="FILE_LOGGER_PATH" value="/data/ftp/internal_000"/>
</load-->
<load name="video_rtp_stream.xml">
<define name="VIEWVIDEO_FPS" value="60"/>
+15 -11
View File
@@ -1,15 +1,19 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="logger_file" dir="loggers">
<doc>
<description>Logs to a csv file (only for linux)</description>
</doc>
<header>
<file name="file_logger.h" />
</header>
<periodic fun="file_logger_periodic()" start="file_logger_start()"
stop="file_logger_stop()" autorun="FALSE" />
<makefile>
<file name="file_logger.c" />
</makefile>
<doc>
<description>
Logs to a csv file.
(only for linux)
</description>
<define name="FILE_LOGGER_PATH" value="/data/video/usb" description="path where csv file is saved."/>
</doc>
<header>
<file name="file_logger.h" />
</header>
<periodic fun="file_logger_periodic()" start="file_logger_start()"
stop="file_logger_stop()" autorun="FALSE" />
<makefile>
<file name="file_logger.c"/>
</makefile>
</module>
+1 -1
View File
@@ -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)\"
@@ -49,9 +49,6 @@
// Threaded computer vision
#include <pthread.h>
#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
+5 -3
View File
@@ -27,13 +27,15 @@
#include "file_logger.h"
#include <stdio.h>
#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");
+2
View File
@@ -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)
+4
View File
@@ -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