From b06bb75b62251cab81d41ffa506ce47916448165 Mon Sep 17 00:00:00 2001 From: Alexander Wenzel Date: Tue, 13 May 2014 14:05:54 +0200 Subject: [PATCH] Send timestamp can be disabled by new API. Signed-off-by: Alexander Wenzel --- include/dlt/dlt_user.h | 9 +++++++++ src/lib/dlt_user.c | 27 ++++++++++++++++++++++++++- src/lib/dlt_user_cfg.h | 3 +++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h index 75cf9a7..0c665ab 100644 --- a/include/dlt/dlt_user.h +++ b/include/dlt/dlt_user.h @@ -231,6 +231,7 @@ typedef struct int8_t verbose_mode; /**< Verbose mode enabled: 1 enabled, 0 disabled */ int8_t use_extende_header_for_non_verbose; /**< Use extended header for non verbose: 1 enabled, 0 disabled */ int8_t with_session_id; /**< Send always session id: 1 enabled, 0 disabled */ + int8_t with_timestamp; /**< Send always timestamp: 1 enabled, 0 disabled */ int8_t enable_local_print; /**< Local printing of log messages: 1 enabled, 0 disabled */ int8_t local_print_mode; /**< Local print mode, controlled by environment variable */ @@ -560,6 +561,14 @@ int dlt_use_extended_header_for_non_verbose(int8_t use_extende_header_for_non_ve int dlt_with_session_id(int8_t with_session_id); /** + * Send timestamp configuration. + * Enabled by default. + * @param with_timestamp Send timestamp id in each message if enabled + * @return negative value if no success + */ +int dlt_with_timestamp(int8_t with_timestamp); + +/** * Set maximum logged log level and trace status of application * * @param loglevel This is the log level to be set for the whole application diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 6c55a3b..b7ab992 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -405,6 +405,9 @@ int dlt_init_common(void) /* WIth session id is enabled by default */ dlt_user.with_session_id = DLT_USER_WITH_SESSION_ID; + /* With timestamp is enabled by default */ + dlt_user.with_timestamp= DLT_USER_WITH_TIMESTAMP; + /* Local print is disabled by default */ dlt_user.enable_local_print = 0; @@ -2742,6 +2745,22 @@ int dlt_with_session_id(int8_t with_session_id) return 0; } +int dlt_with_timestamp(int8_t with_timestamp) +{ + if (dlt_user_initialised==0) + { + if (dlt_init()<0) + { + return -1; + } + } + + /* Set with_timestamp */ + dlt_user.with_timestamp = with_timestamp; + + return 0; +} + int dlt_enable_local_print(void) { if (dlt_user_initialised==0) @@ -2921,7 +2940,13 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype) } msg.standardheader = (DltStandardHeader*)(msg.headerbuffer + sizeof(DltStorageHeader)); - msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_PROTOCOL_VERSION1 ; + msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_PROTOCOL_VERSION1 ; + + /* send timestamp */ + if(dlt_user.with_timestamp) + { + msg.standardheader->htyp |= DLT_HTYP_WTMS; + } /* send session id */ if(dlt_user.with_session_id) diff --git a/src/lib/dlt_user_cfg.h b/src/lib/dlt_user_cfg.h index ca53c95..4c3e201 100755 --- a/src/lib/dlt_user_cfg.h +++ b/src/lib/dlt_user_cfg.h @@ -111,6 +111,9 @@ /* send always session id: 0 - don't use, 1 - use */ #define DLT_USER_WITH_SESSION_ID 1 +/* send always timestamp: 0 - don't use, 1 - use */ +#define DLT_USER_WITH_TIMESTAMP 1 + /* default message id for non-verbose mode, if no message id was provided */ #define DLT_USER_DEFAULT_MSGID 0xffff -- 2.7.4