From 540dc9643efc866af6e7040634c9d7a17ca6c5b0 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周六, 05 12月 2015 21:40:52 +0800 Subject: [PATCH] Fix error queue and resolve #67 --- libscpi/inc/scpi/config.h | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 42 insertions(+), 4 deletions(-) diff --git a/libscpi/inc/scpi/config.h b/libscpi/inc/scpi/config.h index e301c56..2a8c90c 100644 --- a/libscpi/inc/scpi/config.h +++ b/libscpi/inc/scpi/config.h @@ -54,14 +54,30 @@ #define SCPI_LINE_ENDING LINE_ENDING_CRLF #endif -/* Enable full error list +/** + * Detect, if it has limited resources or it is running on a full blown operating system. + * All values can be overiden by scpi_user_config.h + */ +#define SYSTEM_BARE_METAL 0 +#define SYSTEM_FULL_BLOWN 1 + +/* This should cover all windows compilers (msvc, mingw, cvi) and all Linux/OSX/BSD and other UNIX compatible systems (gcc, clang) */ +#if defined(_WIN32) || defined(_WIN64) || defined(__unix) || defined(__unix__) || defined(__APPLE__) +#define SYSTEM_TYPE SYSTEM_FULL_BLOWN +#else +#define SYSTEM_TYPE SYSTEM_BARE_METAL +#endif + +/** + * Enable full error list * 0 = Minimal set of errors * 1 = Full set of errors * * For small systems, full set of errors will occupy large ammount of data + * It is enabled by default on full blown systems and disabled on limited bare metal systems */ #ifndef USE_FULL_ERROR_LIST -#define USE_FULL_ERROR_LIST 0 +#define USE_FULL_ERROR_LIST SYSTEM_TYPE #endif /** @@ -71,6 +87,18 @@ */ #ifndef USE_USER_ERROR_LIST #define USE_USER_ERROR_LIST 0 +#endif + +#ifndef USE_COMMAND_TAGS +#define USE_COMMAND_TAGS 1 +#endif + +#ifndef USE_DEPRECATED_FUNCTIONS +#define USE_DEPRECATED_FUNCTIONS 1 +#endif + +#ifndef USE_CUSTOM_DTOSTR +#define USE_CUSTOM_DTOSTR 0 #endif /* Compiler specific */ @@ -150,9 +178,19 @@ #endif #if HAVE_DTOSTRE -#define SCPIDEFINE_doubleToStr(v, s, l) strlen(dtostre((v), (s), 6, DTOSTR_PLUS_SIGN | DTOSTR_ALWAYS_SIGN | DTOSTR_UPPERCASE)) +#define SCPIDEFINE_floatToStr(v, s, l) strlen(dtostre((double)(v), (s), 6, DTOSTR_PLUS_SIGN | DTOSTR_ALWAYS_SIGN | DTOSTR_UPPERCASE)) +#elif USE_CUSTOM_DTOSTRE +#define SCPIDEFINE_floatToStr(v, s, l) strlen(SCPI_dtostre((v), (s), (l), 6, 0)) #else -#define SCPIDEFINE_doubleToStr(v, s, l) snprintf((s), (l), "%lg", (v)) +#define SCPIDEFINE_floatToStr(v, s, l) snprintf((s), (l), "%g", (v)) +#endif + +#if HAVE_DTOSTRE +#define SCPIDEFINE_doubleToStr(v, s, l) strlen(dtostre((v), (s), 15, DTOSTR_PLUS_SIGN | DTOSTR_ALWAYS_SIGN | DTOSTR_UPPERCASE)) +#elif USE_CUSTOM_DTOSTRE +#define SCPIDEFINE_doubleToStr(v, s, l) strlen(SCPI_dtostre((v), (s), (l), 15, 0)) +#else +#define SCPIDEFINE_doubleToStr(v, s, l) snprintf((s), (l), "%.15lg", (v)) #endif -- Gitblit v1.9.1