From dca8ab254aa0a687c32009079d85e4d8f960b213 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Thu, 20 Dec 2018 14:58:19 +0100 Subject: Code beautification using uncrustify Signed-off-by: Christoph Lipka --- include/dlt/dlt.h | 6 +- include/dlt/dlt_client.h | 43 +- include/dlt/dlt_common.h | 1959 ++++++++++++++++++++------------------- include/dlt/dlt_common_api.h | 424 +++++++-- include/dlt/dlt_filetransfer.h | 4 +- include/dlt/dlt_offline_trace.h | 28 +- include/dlt/dlt_protocol.h | 29 +- include/dlt/dlt_shm.h | 22 +- include/dlt/dlt_types.h | 104 +-- include/dlt/dlt_user.h | 192 ++-- include/dlt/dlt_user_macros.h | 282 +++--- 11 files changed, 1736 insertions(+), 1357 deletions(-) (limited to 'include') diff --git a/include/dlt/dlt.h b/include/dlt/dlt.h index 54a2883..6ecd1e1 100644 --- a/include/dlt/dlt.h +++ b/include/dlt/dlt.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt.h -*/ + */ /******************************************************************************* ** ** @@ -63,8 +63,8 @@ * $LastChangedRevision: 1670 $ * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $ * $LastChangedBy$ - Initials Date Comment - aw 13.01.2010 initial + * Initials Date Comment + * aw 13.01.2010 initial */ #ifndef DLT_H diff --git a/include/dlt/dlt_client.h b/include/dlt/dlt_client.h index 7ff55cf..8947e2f 100644 --- a/include/dlt/dlt_client.h +++ b/include/dlt/dlt_client.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_client.h -*/ + */ /******************************************************************************* @@ -67,16 +67,16 @@ */ #ifndef DLT_CLIENT_H -#define DLT_CLIENT_H +# define DLT_CLIENT_H /** - \defgroup clientapi DLT Client API - \addtogroup clientapi - \{ -*/ + * \defgroup clientapi DLT Client API + * \addtogroup clientapi + \{ + */ -#include "dlt_types.h" -#include "dlt_common.h" +# include "dlt_types.h" +# include "dlt_common.h" typedef enum { @@ -99,11 +99,11 @@ typedef struct DltClientMode mode; /**< mode DltClientMode */ } DltClient; -#ifdef __cplusplus +# ifdef __cplusplus extern "C" { -#endif +# endif -void dlt_client_register_message_callback(int (*registerd_callback) (DltMessage *message, void *data)); +void dlt_client_register_message_callback(int (*registerd_callback)(DltMessage *message, void *data)); /** * Initialising dlt client structure with a specific port @@ -163,7 +163,12 @@ DltReturnValue dlt_client_send_ctrl_msg(DltClient *client, char *apid, char *cti * @param size Size of injection data within buffer * @return Value from DltReturnValue enum */ -DltReturnValue dlt_client_send_inject_msg(DltClient *client, char *apid, char *ctid, uint32_t serviceID, uint8_t *buffer, uint32_t size); +DltReturnValue dlt_client_send_inject_msg(DltClient *client, + char *apid, + char *ctid, + uint32_t serviceID, + uint8_t *buffer, + uint32_t size); /** * Send an set log level message to the dlt daemon * @param client pointer to dlt client structure @@ -196,13 +201,13 @@ int dlt_client_get_software_version(DltClient *client); * @param void * @return void */ -void dlt_getloginfo_init( void ); +void dlt_getloginfo_init(void); /** * To free the memory allocated for app description in get log info * @param void * @return void */ -void dlt_getloginfo_free( void ); +void dlt_getloginfo_free(void); /** * Send a set trace status message to the dlt daemon * @param client pointer to dlt client structure @@ -299,7 +304,7 @@ int dlt_client_set_socket_path(DltClient *client, char *socket_path); * @return Value from DltReturnValue enum */ DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoResponse *resp, - char *resp_text); + char *resp_text); /** * Free memory allocated for get log info message @@ -307,12 +312,12 @@ DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoRespo * @return 0 on success, -1 otherwise */ int dlt_client_cleanup_get_log_info(DltServiceGetLogInfoResponse *resp); -#ifdef __cplusplus +# ifdef __cplusplus } -#endif +# endif /** - \} -*/ + \} + */ #endif /* DLT_CLIENT_H */ diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h index 3db3a27..fc02743 100644 --- a/include/dlt/dlt_common.h +++ b/include/dlt/dlt_common.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_common.h -*/ + */ /******************************************************************************* ** ** @@ -63,163 +63,164 @@ * $LastChangedRevision: 1670 $ * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $ * $LastChangedBy$ - Initials Date Comment - aw 13.01.2010 initial + * Initials Date Comment + * aw 13.01.2010 initial */ #ifndef DLT_COMMON_H -#define DLT_COMMON_H +# define DLT_COMMON_H /** - \defgroup commonapi DLT Common API - \addtogroup commonapi - \{ -*/ + * \defgroup commonapi DLT Common API + * \addtogroup commonapi + \{ + */ -#include -#ifdef __linux__ -#include -#else -#include -#endif +# include +# ifdef __linux__ +# include +# else +# include +# endif -#if !defined(_MSC_VER) -#include -#include -#endif +# if !defined(_MSC_VER) +# include +# include +# endif -#if !defined (__WIN32__) && !defined(_MSC_VER) -#include -#endif +# if !defined (__WIN32__) && !defined(_MSC_VER) +# include +# endif -#include "dlt_types.h" -#include "dlt_protocol.h" +# include "dlt_types.h" +# include "dlt_protocol.h" -#if !defined (PACKED) -#define PACKED __attribute__((aligned(1),packed)) -#endif +# if !defined (PACKED) +# define PACKED __attribute__((aligned(1), packed)) +# endif -#if defined (__MSDOS__) || defined (_MSC_VER) +# if defined (__MSDOS__) || defined (_MSC_VER) /* set instead /Zp8 flag in Visual C++ configuration */ -#undef PACKED -#define PACKED -#endif +# undef PACKED +# define PACKED +# endif /* * Macros to swap the byte order. */ -#define DLT_SWAP_64(value) ((((uint64_t)DLT_SWAP_32((value)&0xffffffffull))<<32) | (DLT_SWAP_32((value)>>32))) +# define DLT_SWAP_64(value) ((((uint64_t)DLT_SWAP_32((value) & 0xffffffffull)) << 32) | (DLT_SWAP_32((value) >> 32))) -#define DLT_SWAP_16(value) ((((value) >> 8)&0xff) | (((value) << 8)&0xff00)) -#define DLT_SWAP_32(value) ((((value) >> 24)&0xff) | (((value) << 8)&0xff0000) | (((value) >> 8)&0xff00) | (((value) << 24)&0xff000000)) +# define DLT_SWAP_16(value) ((((value) >> 8) & 0xff) | (((value) << 8) & 0xff00)) +# define DLT_SWAP_32(value) ((((value) >> 24) & 0xff) | (((value) << 8) & 0xff0000) | (((value) >> 8) & 0xff00) | \ + (((value) << 24) & 0xff000000)) /* Set Big Endian and Little Endian to a initial value, if not defined */ -#if !defined __USE_BSD -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif +# if !defined __USE_BSD +# ifndef LITTLE_ENDIAN +# define LITTLE_ENDIAN 1234 +# endif -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif -#endif /* __USE_BSD */ +# ifndef BIG_ENDIAN +# define BIG_ENDIAN 4321 +# endif +# endif /* __USE_BSD */ /* If byte order is not defined, default to little endian */ -#if !defined __USE_BSD -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN -#endif -#endif /* __USE_BSD */ +# if !defined __USE_BSD +# ifndef BYTE_ORDER +# define BYTE_ORDER LITTLE_ENDIAN +# endif +# endif /* __USE_BSD */ /* Check for byte-order */ -#if (BYTE_ORDER==BIG_ENDIAN) +# if (BYTE_ORDER == BIG_ENDIAN) /* #warning "Big Endian Architecture!" */ -#define DLT_HTOBE_16(x) ((x)) -#define DLT_HTOLE_16(x) DLT_SWAP_16((x)) -#define DLT_BETOH_16(x) ((x)) -#define DLT_LETOH_16(x) DLT_SWAP_16((x)) - -#define DLT_HTOBE_32(x) ((x)) -#define DLT_HTOLE_32(x) DLT_SWAP_32((x)) -#define DLT_BETOH_32(x) ((x)) -#define DLT_LETOH_32(x) DLT_SWAP_32((x)) - -#define DLT_HTOBE_64(x) ((x)) -#define DLT_HTOLE_64(x) DLT_SWAP_64((x)) -#define DLT_BETOH_64(x) ((x)) -#define DLT_LETOH_64(x) DLT_SWAP_64((x)) -#else +# define DLT_HTOBE_16(x) ((x)) +# define DLT_HTOLE_16(x) DLT_SWAP_16((x)) +# define DLT_BETOH_16(x) ((x)) +# define DLT_LETOH_16(x) DLT_SWAP_16((x)) + +# define DLT_HTOBE_32(x) ((x)) +# define DLT_HTOLE_32(x) DLT_SWAP_32((x)) +# define DLT_BETOH_32(x) ((x)) +# define DLT_LETOH_32(x) DLT_SWAP_32((x)) + +# define DLT_HTOBE_64(x) ((x)) +# define DLT_HTOLE_64(x) DLT_SWAP_64((x)) +# define DLT_BETOH_64(x) ((x)) +# define DLT_LETOH_64(x) DLT_SWAP_64((x)) +# else /* #warning "Litte Endian Architecture!" */ -#define DLT_HTOBE_16(x) DLT_SWAP_16((x)) -#define DLT_HTOLE_16(x) ((x)) -#define DLT_BETOH_16(x) DLT_SWAP_16((x)) -#define DLT_LETOH_16(x) ((x)) - -#define DLT_HTOBE_32(x) DLT_SWAP_32((x)) -#define DLT_HTOLE_32(x) ((x)) -#define DLT_BETOH_32(x) DLT_SWAP_32((x)) -#define DLT_LETOH_32(x) ((x)) - -#define DLT_HTOBE_64(x) DLT_SWAP_64((x)) -#define DLT_HTOLE_64(x) ((x)) -#define DLT_BETOH_64(x) DLT_SWAP_64((x)) -#define DLT_LETOH_64(x) ((x)) -#endif - -#define DLT_ENDIAN_GET_16(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_16(x):DLT_LETOH_16(x)) -#define DLT_ENDIAN_GET_32(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_32(x):DLT_LETOH_32(x)) -#define DLT_ENDIAN_GET_64(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_64(x):DLT_LETOH_64(x)) - -#if defined (__WIN32__) || defined (_MSC_VER) -#define LOG_EMERG 0 -#define LOG_ALERT 1 -#define LOG_CRIT 2 -#define LOG_ERR 3 -#define LOG_WARNING 4 -#define LOG_NOTICE 5 -#define LOG_INFO 6 -#define LOG_DEBUG 7 - -#define LOG_PID 0x01 -#define LOG_DAEMON (3<<3) -#endif +# define DLT_HTOBE_16(x) DLT_SWAP_16((x)) +# define DLT_HTOLE_16(x) ((x)) +# define DLT_BETOH_16(x) DLT_SWAP_16((x)) +# define DLT_LETOH_16(x) ((x)) + +# define DLT_HTOBE_32(x) DLT_SWAP_32((x)) +# define DLT_HTOLE_32(x) ((x)) +# define DLT_BETOH_32(x) DLT_SWAP_32((x)) +# define DLT_LETOH_32(x) ((x)) + +# define DLT_HTOBE_64(x) DLT_SWAP_64((x)) +# define DLT_HTOLE_64(x) ((x)) +# define DLT_BETOH_64(x) DLT_SWAP_64((x)) +# define DLT_LETOH_64(x) ((x)) +# endif + +# define DLT_ENDIAN_GET_16(htyp, x) ((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_16(x) : DLT_LETOH_16(x)) +# define DLT_ENDIAN_GET_32(htyp, x) ((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_32(x) : DLT_LETOH_32(x)) +# define DLT_ENDIAN_GET_64(htyp, x) ((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_64(x) : DLT_LETOH_64(x)) + +# if defined (__WIN32__) || defined (_MSC_VER) +# define LOG_EMERG 0 +# define LOG_ALERT 1 +# define LOG_CRIT 2 +# define LOG_ERR 3 +# define LOG_WARNING 4 +# define LOG_NOTICE 5 +# define LOG_INFO 6 +# define LOG_DEBUG 7 + +# define LOG_PID 0x01 +# define LOG_DAEMON (3 << 3) +# endif enum { - DLT_LOG_TO_CONSOLE=0, - DLT_LOG_TO_SYSLOG=1, - DLT_LOG_TO_FILE=2, - DLT_LOG_DROPPED=3 + DLT_LOG_TO_CONSOLE = 0, + DLT_LOG_TO_SYSLOG = 1, + DLT_LOG_TO_FILE = 2, + DLT_LOG_DROPPED = 3 }; /** * The standard TCP Port used for DLT daemon, can be overwritten via -p when starting dlt-daemon */ -#define DLT_DAEMON_TCP_PORT 3490 +# define DLT_DAEMON_TCP_PORT 3490 /* Initial value for file descriptor */ -#define DLT_FD_INIT -1 +# define DLT_FD_INIT -1 /* Minimum value for a file descriptor except the POSIX Standards: stdin=0, stdout=1, stderr=2 */ -#define DLT_FD_MINIMUM 3 +# define DLT_FD_MINIMUM 3 /** * The size of a DLT ID */ -#define DLT_ID_SIZE 4 +# define DLT_ID_SIZE 4 -#define DLT_SIZE_WEID DLT_ID_SIZE -#define DLT_SIZE_WSID (sizeof(uint32_t)) -#define DLT_SIZE_WTMS (sizeof(uint32_t)) +# define DLT_SIZE_WEID DLT_ID_SIZE +# define DLT_SIZE_WSID (sizeof(uint32_t)) +# define DLT_SIZE_WTMS (sizeof(uint32_t)) /** * Definitions for GET_LOG_INFO */ -#define DLT_GET_LOG_INFO_HEADER 18 /*Get log info header size in response text */ -#define GET_LOG_INFO_LENGTH 13 -#define SERVICE_OPT_LENGTH 3 +# define DLT_GET_LOG_INFO_HEADER 18 /*Get log info header size in response text */ +# define GET_LOG_INFO_LENGTH 13 +# define SERVICE_OPT_LENGTH 3 /* checks if received size is big enough for expected data */ -#define DLT_CHECK_RCV_DATA_SIZE(received, required) \ +# define DLT_CHECK_RCV_DATA_SIZE(received, required) \ ({ \ int _ret = DLT_RETURN_OK; \ if (((int)received - (int)required) < 0) { \ @@ -232,155 +233,158 @@ enum { /** * Get the size of extra header parameters, depends on htyp. */ -#define DLT_STANDARD_HEADER_EXTRA_SIZE(htyp) ( (DLT_IS_HTYP_WEID(htyp) ? DLT_SIZE_WEID : 0) + (DLT_IS_HTYP_WSID(htyp) ? DLT_SIZE_WSID : 0) + (DLT_IS_HTYP_WTMS(htyp) ? DLT_SIZE_WTMS : 0) ) +# define DLT_STANDARD_HEADER_EXTRA_SIZE(htyp) ((DLT_IS_HTYP_WEID(htyp) ? DLT_SIZE_WEID : 0) + \ + (DLT_IS_HTYP_WSID(htyp) ? DLT_SIZE_WSID : 0) + \ + (DLT_IS_HTYP_WTMS(htyp) ? DLT_SIZE_WTMS : 0)) -#if defined (__MSDOS__) || defined (_MSC_VER) -#define __func__ __FUNCTION__ -#endif +# if defined (__MSDOS__) || defined (_MSC_VER) +# define __func__ __FUNCTION__ +# endif -#define PRINT_FUNCTION_VERBOSE(_verbose) \ -{ \ - static char _strbuf[255]; \ - \ - if(_verbose) \ +# define PRINT_FUNCTION_VERBOSE(_verbose) \ { \ - snprintf(_strbuf, 255, "%s()\n",__func__); \ - dlt_log(LOG_INFO, _strbuf); \ - } \ -} + static char _strbuf[255]; \ + \ + if (_verbose) \ + { \ + snprintf(_strbuf, 255, "%s()\n", __func__); \ + dlt_log(LOG_INFO, _strbuf); \ + } \ + } -#ifndef NULL -#define NULL (char*)0 -#endif +# ifndef NULL +# define NULL (char *)0 +# endif -#define DLT_MSG_IS_CONTROL(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ - (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL)) +# define DLT_MSG_IS_CONTROL(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ + (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_CONTROL)) -#define DLT_MSG_IS_CONTROL_REQUEST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ - (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \ - (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_REQUEST)) +# define DLT_MSG_IS_CONTROL_REQUEST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ + (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_CONTROL) && \ + (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin) == DLT_CONTROL_REQUEST)) -#define DLT_MSG_IS_CONTROL_RESPONSE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ - (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \ - (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_RESPONSE)) +# define DLT_MSG_IS_CONTROL_RESPONSE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ + (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_CONTROL) && \ + (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin) == DLT_CONTROL_RESPONSE)) -#define DLT_MSG_IS_CONTROL_TIME(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ - (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \ - (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_TIME)) +# define DLT_MSG_IS_CONTROL_TIME(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ + (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_CONTROL) && \ + (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin) == DLT_CONTROL_TIME)) -#define DLT_MSG_IS_NW_TRACE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ - (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE)) +# define DLT_MSG_IS_NW_TRACE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ + (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_NW_TRACE)) -#define DLT_MSG_IS_TRACE_MOST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ - (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE) && \ - (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_NW_TRACE_MOST)) +# define DLT_MSG_IS_TRACE_MOST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ + (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin) == DLT_TYPE_NW_TRACE) && \ + (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin) == DLT_NW_TRACE_MOST)) -#define DLT_MSG_IS_NONVERBOSE(MSG) (!(DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) || \ - ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && (!(DLT_IS_MSIN_VERB((MSG)->extendedheader->msin))))) +# define DLT_MSG_IS_NONVERBOSE(MSG) (!(DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) || \ + ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ + (!(DLT_IS_MSIN_VERB((MSG)->extendedheader->msin))))) /* - + * * Definitions of DLT message buffer overflow */ -#define DLT_MESSAGE_BUFFER_NO_OVERFLOW 0x00 /**< Buffer overflow has not occured */ -#define DLT_MESSAGE_BUFFER_OVERFLOW 0x01 /**< Buffer overflow has occured */ +# define DLT_MESSAGE_BUFFER_NO_OVERFLOW 0x00/**< Buffer overflow has not occured */ +# define DLT_MESSAGE_BUFFER_OVERFLOW 0x01/**< Buffer overflow has occured */ /* * Definition of DLT output variants */ -#define DLT_OUTPUT_HEX 1 -#define DLT_OUTPUT_ASCII 2 -#define DLT_OUTPUT_MIXED_FOR_PLAIN 3 -#define DLT_OUTPUT_MIXED_FOR_HTML 4 -#define DLT_OUTPUT_ASCII_LIMITED 5 +# define DLT_OUTPUT_HEX 1 +# define DLT_OUTPUT_ASCII 2 +# define DLT_OUTPUT_MIXED_FOR_PLAIN 3 +# define DLT_OUTPUT_MIXED_FOR_HTML 4 +# define DLT_OUTPUT_ASCII_LIMITED 5 -#define DLT_FILTER_MAX 30 /**< Maximum number of filters */ +# define DLT_FILTER_MAX 30 /**< Maximum number of filters */ -#define DLT_MSG_READ_VALUE(dst,src,length,type) \ -{ \ - if((length<0) || ((length)<((int32_t)sizeof(type)))) \ - { length = -1; } \ - else \ - { dst = *((type*)src);src+=sizeof(type);length-=sizeof(type); } \ -} - -#define DLT_MSG_READ_ID(dst,src,length) \ -{ \ - if((length<0) || ((length) on the console - */ - int dlt_mkdir_recursive(const char *dir); -#endif - -#ifdef __cplusplus +# endif + +/** + * Helper function to print a byte array in hex. + * @param ptr pointer to the byte array. + * @param size number of bytes to be printed. + */ +void dlt_print_hex(uint8_t *ptr, int size); +/** + * Helper function to print a byte array in hex into a string. + * @param text pointer to a ASCII string, in which the text is written + * @param textlength maximal size of text buffer + * @param ptr pointer to the byte array. + * @param size number of bytes to be printed. + * @return negative value if there was an error + */ +DltReturnValue dlt_print_hex_string(char *text, int textlength, uint8_t *ptr, int size); +/** + * Helper function to print a byte array in hex and ascii into a string. + * @param text pointer to a ASCII string, in which the text is written + * @param textlength maximal size of text buffer + * @param ptr pointer to the byte array. + * @param size number of bytes to be printed. + * @param html output is html? 0 - false, 1 - true + * @return negative value if there was an error + */ +DltReturnValue dlt_print_mixed_string(char *text, int textlength, uint8_t *ptr, int size, int html); +/** + * Helper function to print a byte array in ascii into a string. + * @param text pointer to a ASCII string, in which the text is written + * @param textlength maximal size of text buffer + * @param ptr pointer to the byte array. + * @param size number of bytes to be printed. + * @return negative value if there was an error + */ +DltReturnValue dlt_print_char_string(char **text, int textlength, uint8_t *ptr, int size); + +/** + * Helper function to print an id. + * @param text pointer to ASCII string where to write the id + * @param id four byte char array as used in DLT mesages as IDs. + */ +void dlt_print_id(char *text, const char *id); + +/** + * Helper function to set an ID parameter. + * @param id four byte char array as used in DLT mesages as IDs. + * @param text string to be copied into char array. + */ +void dlt_set_id(char *id, const char *text); + +/** + * Helper function to remove not nice to print characters, e.g. NULL or carage return. + * @param text pointer to string to be cleaned. + * @param length length of string excluding terminating zero. + */ +void dlt_clean_string(char *text, int length); + +/** + * Initialise the filter list. + * This function must be called before using further dlt filter. + * @param filter pointer to structure of organising DLT filter + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_filter_init(DltFilter *filter, int verbose); +/** + * Free the used memory by the organising structure of filter. + * @param filter pointer to structure of organising DLT filter + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_filter_free(DltFilter *filter, int verbose); +/** + * Load filter list from file. + * @param filter pointer to structure of organising DLT filter + * @param filename filename to load filters from + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verbose); +/** + * Save filter list to file. + * @param filter pointer to structure of organising DLT filter + * @param filename filename to load filters from + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_filter_save(DltFilter *filter, const char *filename, int verbose); +/** + * Find index of filter in filter list + * @param filter pointer to structure of organising DLT filter + * @param apid application id to be found in filter list + * @param ctid context id to be found in filter list + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error (or not found), else return index of filter + */ +int dlt_filter_find(DltFilter *filter, const char *apid, const char *ctid, int verbose); +/** + * Add new filter to filter list. + * @param filter pointer to structure of organising DLT filter + * @param apid application id to be added to filter list (must always be set). + * @param ctid context id to be added to filter list. empty equals don't care. + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_filter_add(DltFilter *filter, const char *apid, const char *ctid, int verbose); +/** + * Delete filter from filter list + * @param filter pointer to structure of organising DLT filter + * @param apid application id to be deleted from filter list + * @param ctid context id to be deleted from filter list + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_filter_delete(DltFilter *filter, const char *apid, const char *ctid, int verbose); + +/** + * Initialise the structure used to access a DLT message. + * This function must be called before using further dlt_message functions. + * @param msg pointer to structure of organising access to DLT messages + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_init(DltMessage *msg, int verbose); +/** + * Free the used memory by the organising structure of file. + * @param msg pointer to structure of organising access to DLT messages + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_free(DltMessage *msg, int verbose); +/** + * Print Header into an ASCII string. + * This function calls dlt_message_header_flags() with flags=DLT_HEADER_SHOW_ALL + * @param msg pointer to structure of organising access to DLT messages + * @param text pointer to a ASCII string, in which the header is written + * @param textlength maximal size of text buffer + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_header(DltMessage *msg, char *text, int textlength, int verbose); +/** + * Print Header into an ASCII string, selective. + * @param msg pointer to structure of organising access to DLT messages + * @param text pointer to a ASCII string, in which the header is written + * @param textlength maximal size of text buffer + * @param flags select, bit-field to select, what should be printed (DLT_HEADER_SHOW_...) + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_header_flags(DltMessage *msg, char *text, int textlength, int flags, int verbose); +/** + * Print Payload into an ASCII string. + * @param msg pointer to structure of organising access to DLT messages + * @param text pointer to a ASCII string, in which the header is written + * @param textlength maximal size of text buffer + * @param type 1 = payload as hex, 2 = payload as ASCII. + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength, int type, int verbose); +/** + * Check if message is filtered or not. All filters are applied (logical OR). + * @param msg pointer to structure of organising access to DLT messages + * @param filter pointer to filter + * @param verbose if set to true verbose information is printed out. + * @return 1 = filter matches, 0 = filter does not match, negative value if there was an error + */ +DltReturnValue dlt_message_filter_check(DltMessage *msg, DltFilter *filter, int verbose); + +/** + * Read message from memory buffer. + * Message in buffer has no storage header. + * @param msg pointer to structure of organising access to DLT messages + * @param buffer pointer to memory buffer + * @param length length of message in buffer + * @param resync if set to true resync to serial header is enforced + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int resync, int verbose); + +/** + * Get standard header extra parameters + * @param msg pointer to structure of organising access to DLT messages + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_get_extraparameters(DltMessage *msg, int verbose); + +/** + * Set standard header extra parameters + * @param msg pointer to structure of organising access to DLT messages + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_set_extraparameters(DltMessage *msg, int verbose); + +/** + * Initialise the structure used to access a DLT file. + * This function must be called before using further dlt_file functions. + * @param file pointer to structure of organising access to DLT file + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_file_init(DltFile *file, int verbose); +/** + * Set a list to filters. + * This function should be called before loading a DLT file, if filters should be used. + * A filter list is an array of filters. Several filters are combined logically by or operation. + * The filter list is not copied, so take care to keep list in memory. + * @param file pointer to structure of organising access to DLT file + * @param filter pointer to filter list array + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_file_set_filter(DltFile *file, DltFilter *filter, int verbose); +/** + * Initialising loading a DLT file. + * @param file pointer to structure of organising access to DLT file + * @param filename filename of DLT file + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_file_open(DltFile *file, const char *filename, int verbose); +/** + * Find next message in the DLT file and parse them. + * This function finds the next message in the DLT file. + * If a filter is set, the filter list is used. + * @param file pointer to structure of organising access to DLT file + * @param verbose if set to true verbose information is printed out. + * @return 0 = message does not match filter, 1 = message was read, negative value if there was an error + */ +DltReturnValue dlt_file_read(DltFile *file, int verbose); +/** + * Find next message in the DLT file in RAW format (without storage header) and parse them. + * This function finds the next message in the DLT file. + * If a filter is set, the filter list is used. + * @param file pointer to structure of organising access to DLT file + * @param resync Resync to serial header when set to true + * @param verbose if set to true verbose information is printed out. + * @return 0 = message does not match filter, 1 = message was read, negative value if there was an error + */ +DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose); +/** + * Closing loading a DLT file. + * @param file pointer to structure of organising access to DLT file + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_file_close(DltFile *file, int verbose); +/** + * Load standard header of a message from file + * @param file pointer to structure of organising access to DLT file + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_file_read_header(DltFile *file, int verbose); +/** + * Load standard header of a message from file in RAW format (without storage header) + * @param file pointer to structure of organising access to DLT file + * @param resync Resync to serial header when set to true + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_file_read_header_raw(DltFile *file, int resync, int verbose); +/** + * Load, if available in message, extra standard header fields and + * extended header of a message from file + * (dlt_file_read_header() must have been called before this call!) + * @param file pointer to structure of organising access to DLT file + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_file_read_header_extended(DltFile *file, int verbose); +/** + * Load payload of a message from file + * (dlt_file_read_header() must have been called before this call!) + * @param file pointer to structure of organising access to DLT file + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_file_read_data(DltFile *file, int verbose); +/** + * Load headers and payload of a message selected by the index. + * If filters are set, index is based on the filtered list. + * @param file pointer to structure of organising access to DLT file + * @param index position of message in the files beginning from zero + * @param verbose if set to true verbose information is printed out. + * @return number of messages loaded, negative value if there was an error + */ +DltReturnValue dlt_file_message(DltFile *file, int index, int verbose); +/** + * Free the used memory by the organising structure of file. + * @param file pointer to structure of organising access to DLT file + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_file_free(DltFile *file, int verbose); + +/** + * Set internal logging filename if mode 2 + * @param filename the filename + */ +void dlt_log_set_filename(const char *filename); +/** + * Set internal logging level + * @param level the level + */ +void dlt_log_set_level(int level); +/** + * Initialize (external) logging facility + * @param mode positive, 0 = log to stdout, 1 = log to syslog, 2 = log to file + */ +void dlt_log_init(int mode); +/** + * Log ASCII string with null-termination to (external) logging facility + * @param prio priority (see syslog() call) + * @param s Pointer to ASCII string with null-termination + * @return negative value if there was an error + */ +DltReturnValue dlt_log(int prio, char *s); +/** + * Log with variable arguments to (external) logging facility (like printf) + * @param prio priority (see syslog() call) + * @param format format string for log message + * @return negative value if there was an error + */ +DltReturnValue dlt_vlog(int prio, const char *format, ...); +/** + * Log size bytes with variable arguments to (external) logging facility (similar to snprintf) + * @param prio priority (see syslog() call) + * @param size number of bytes to log + * @param format format string for log message + * @return negative value if there was an error + */ +DltReturnValue dlt_vnlog(int prio, size_t size, const char *format, ...); +/** + * De-Initialize (external) logging facility + */ +void dlt_log_free(void); + +/** + * Initialising a dlt receiver structure + * @param receiver pointer to dlt receiver structure + * @param _fd handle to file/socket/fifo, fram which the data should be received + * @param _buffersize size of data buffer for storing the received data + * @return negative value if there was an error + */ +DltReturnValue dlt_receiver_init(DltReceiver *receiver, int _fd, int _buffersize); +/** + * De-Initialize a dlt receiver structure + * @param receiver pointer to dlt receiver structure + * @return negative value if there was an error + */ +DltReturnValue dlt_receiver_free(DltReceiver *receiver); +/** + * Initialising a dlt receiver structure + * @param receiver pointer to dlt receiver structure + * @param fd handle to file/socket/fifo, fram which the data should be received + * @param buffer data buffer for storing the received data + * @return negative value if there was an error and zero if success + */ +DltReturnValue dlt_receiver_init_unix_socket(DltReceiver *receiver, int fd, char **buffer); +/** + * De-Initialize a dlt receiver structure + * @param receiver pointer to dlt receiver structure + * @return negative value if there was an error and zero if success + */ +DltReturnValue dlt_receiver_free_unix_socket(DltReceiver *receiver); +/** + * Receive data from socket or file/fifo using the dlt receiver structure + * @param receiver pointer to dlt receiver structure + * @param from_src specify whether received data is from socket or file/fifo + * @return number of received bytes or negative value if there was an error + */ +int dlt_receiver_receive(DltReceiver *receiver, DltReceiverType from_src); +/** + * Remove a specific size of bytes from the received data + * @param receiver pointer to dlt receiver structure + * @param size amount of bytes to be removed + * @return negative value if there was an error + */ +DltReturnValue dlt_receiver_remove(DltReceiver *receiver, int size); +/** + * Move data from last receive call to front of receive buffer + * @param receiver pointer to dlt receiver structure + * @return negative value if there was an error + */ +DltReturnValue dlt_receiver_move_to_begin(DltReceiver *receiver); + +/** + * Check whether to_get amount of data is available in receiver and + * copy it to dest. Skip the DltUserHeader if skip_header is set to 1. + * @param receiver pointer to dlt receiver structure + * @param dest pointer to the destination buffer + * @param to_get size of the data to copy in dest + * @skip_header whether if the DltUserHeader must be skipped. + */ +int dlt_receiver_check_and_get(DltReceiver *receiver, + void *dest, + unsigned int to_get, + unsigned int skip_header); + +/** + * Fill out storage header of a dlt message + * @param storageheader pointer to storage header of a dlt message + * @param ecu name of ecu to be set in storage header + * @return negative value if there was an error + */ +DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu); +/** + * Check if a storage header contains its marker + * @param storageheader pointer to storage header of a dlt message + * @return 0 no, 1 yes, negative value if there was an error + */ +DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader); + + +/** + * Initialise static ringbuffer with a size of size. + * Initialise as server. Init counters. + * Memory is already allocated. + * @param buf Pointer to ringbuffer structure + * @param ptr Ptr to ringbuffer memory + * @param size Maximum size of buffer in bytes + * @return negative value if there was an error + */ +DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size); + +/** + * Initialize static ringbuffer with a size of size. + * Initialise as a client. Do not change counters. + * Memory is already allocated. + * @param buf Pointer to ringbuffer structure + * @param ptr Ptr to ringbuffer memory + * @param size Maximum size of buffer in bytes + * @return negative value if there was an error + */ +DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size); + +/** + * Initialize dynamic ringbuffer with a size of size. + * Initialise as a client. Do not change counters. + * Memory will be allocated starting with min_size. + * If more memory is needed size is increased wit step_size. + * The maximum size is max_size. + * @param buf Pointer to ringbuffer structure + * @param min_size Minimum size of buffer in bytes + * @param max_size Maximum size of buffer in bytes + * @param step_size size of which ringbuffer is increased + * @return negative value if there was an error + */ +DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size, uint32_t step_size); + +/** + * Deinitilaise usage of static ringbuffer + * @param buf Pointer to ringbuffer structure + * @return negative value if there was an error + */ +DltReturnValue dlt_buffer_free_static(DltBuffer *buf); + +/** + * Release and free memory used by dynamic ringbuffer + * @param buf Pointer to ringbuffer structure + * @return negative value if there was an error + */ +DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf); + +/** + * Check if message fits into buffer. + * @param buf Pointer to buffer structure + * @return DLT_RETURN_OK if enough space, DLT_RETURN_ERROR otherwise + */ +DltReturnValue dlt_buffer_check_size(DltBuffer *buf, int needed); + +/** + * Write one entry to ringbuffer + * @param buf Pointer to ringbuffer structure + * @param data Pointer to data to be written to ringbuffer + * @param size Size of data in bytes to be written to ringbuffer + * @return negative value if there was an error + */ +DltReturnValue dlt_buffer_push(DltBuffer *buf, const unsigned char *data, unsigned int size); + +/** + * Write up to three entries to ringbuffer. + * Entries are joined to one block. + * @param dlt Pointer to ringbuffer structure + * @param data1 Pointer to data to be written to ringbuffer + * @param size1 Size of data in bytes to be written to ringbuffer + * @param data2 Pointer to data to be written to ringbuffer + * @param size2 Size of data in bytes to be written to ringbuffer + * @param data3 Pointer to data to be written to ringbuffer + * @param size3 Size of data in bytes to be written to ringbuffer + * @return negative value if there was an error + */ +DltReturnValue dlt_buffer_push3(DltBuffer *buf, + const unsigned char *data1, + unsigned int size1, + const unsigned char *data2, + unsigned int size2, + const unsigned char *data3, + unsigned int size3); + +/** + * Read one entry from ringbuffer. + * Remove it from ringbuffer. + * @param buf Pointer to ringbuffer structure + * @param data Pointer to data read from ringbuffer + * @param max_size Max size of read data in bytes from ringbuffer + * @return size of read data, zero if no data available, negative value if there was an error + */ +int dlt_buffer_pull(DltBuffer *buf, unsigned char *data, int max_size); + +/** + * Read one entry from ringbuffer. + * Do not remove it from ringbuffer. + * @param buf Pointer to ringbuffer structure + * @param data Pointer to data read from ringbuffer + * @param max_size Max size of read data in bytes from ringbuffer + * @return size of read data, zero if no data available, negative value if there was an error + */ +int dlt_buffer_copy(DltBuffer *buf, unsigned char *data, int max_size); + +/** + * Remove entry from ringbuffer. + * @param buf Pointer to ringbuffer structure + * @return size of read data, zero if no data available, negative value if there was an error + */ +int dlt_buffer_remove(DltBuffer *buf); + +/** + * Print information about buffer and log to internal DLT log. + * @param buf Pointer to ringbuffer structure + */ +void dlt_buffer_info(DltBuffer *buf); + +/** + * Print status of buffer and log to internal DLT log. + * @param buf Pointer to ringbuffer structure + */ +void dlt_buffer_status(DltBuffer *buf); + +/** + * Get total size in bytes of ringbuffer. + * If buffer is dynamic, max size is returned. + * @param buf Pointer to ringbuffer structure + * @return total size of buffer + */ +uint32_t dlt_buffer_get_total_size(DltBuffer *buf); + +/** + * Get used size in bytes of ringbuffer. + * @param buf Pointer to ringbuffer structure + * @return used size of buffer + */ +int dlt_buffer_get_used_size(DltBuffer *buf); + +/** + * Get number of entries in ringbuffer. + * @param buf Pointer to ringbuffer structure + * @return number of entries + */ +int dlt_buffer_get_message_count(DltBuffer *buf); + +# if !defined (__WIN32__) + +/** + * Helper function: Setup serial connection + * @param fd File descriptor of serial tty device + * @param speed Serial line speed, as defined in termios.h + * @return negative value if there was an error + */ +DltReturnValue dlt_setup_serial(int fd, speed_t speed); + +/** + * Helper function: Convert serial line baudrate (as number) to line speed (as defined in termios.h) + * @param baudrate Serial line baudrate (as number) + * @return Serial line speed, as defined in termios.h + */ +speed_t dlt_convert_serial_speed(int baudrate); + +/** + * Print dlt version and dlt svn version to buffer + * @param buf Pointer to buffer + * @param size size of buffer + */ +void dlt_get_version(char *buf, size_t size); + +/** + * Print dlt major version to buffer + * @param buf Pointer to buffer + * @param size size of buffer + */ +void dlt_get_major_version(char *buf, size_t size); + +/** + * Print dlt minor version to buffer + * @param buf Pointer to buffer + * @param size size of buffer + */ +void dlt_get_minor_version(char *buf, size_t size); + +# endif + +/* Function prototypes which should be used only internally */ +/* */ + +/** + * Common part of initialisation + * @return negative value if there was an error + */ +DltReturnValue dlt_init_common(void); + +/** + * Return the uptime of the system in 0.1 ms resolution + * @return 0 if there was an error + */ +uint32_t dlt_uptime(void); + +/** + * Print header of a DLT message + * @param message pointer to structure of organising access to DLT messages + * @param text pointer to a ASCII string, in which the header is written + * @param size maximal size of text buffer + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_print_header(DltMessage *message, char *text, uint32_t size, int verbose); + +/** + * Print payload of a DLT message as Hex-Output + * @param message pointer to structure of organising access to DLT messages + * @param text pointer to a ASCII string, in which the output is written + * @param size maximal size of text buffer + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_print_hex(DltMessage *message, char *text, uint32_t size, int verbose); + +/** + * Print payload of a DLT message as ASCII-Output + * @param message pointer to structure of organising access to DLT messages + * @param text pointer to a ASCII string, in which the output is written + * @param size maximal size of text buffer + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_print_ascii(DltMessage *message, char *text, uint32_t size, int verbose); + +/** + * Print payload of a DLT message as Mixed-Ouput (Hex and ASCII), for plain text output + * @param message pointer to structure of organising access to DLT messages + * @param text pointer to a ASCII string, in which the output is written + * @param size maximal size of text buffer + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_print_mixed_plain(DltMessage *message, char *text, uint32_t size, int verbose); + +/** + * Print payload of a DLT message as Mixed-Ouput (Hex and ASCII), for HTML text output + * @param message pointer to structure of organising access to DLT messages + * @param text pointer to a ASCII string, in which the output is written + * @param size maximal size of text buffer + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_print_mixed_html(DltMessage *message, char *text, uint32_t size, int verbose); + +/** + * Decode and print a argument of a DLT message + * @param msg pointer to structure of organising access to DLT messages + * @param type_info Type of argument + * @param ptr pointer to pointer to data (pointer to data is changed within this function) + * @param datalength pointer to datalength (datalength is changed within this function) + * @param text pointer to a ASCII string, in which the output is written + * @param textlength maximal size of text buffer + * @param byteLength If argument is a string, and this value is 0 or greater, this value will be taken as string length + * @param verbose if set to true verbose information is printed out. + * @return negative value if there was an error + */ +DltReturnValue dlt_message_argument_print(DltMessage *msg, + uint32_t type_info, + uint8_t **ptr, + int32_t *datalength, + char *text, + int textlength, + int byteLength, + int verbose); + +/** + * Check environment variables. + */ +void dlt_check_envvar(); + +/** + * Parse the response text and identifying service id and its options. + * + * @param resp_text char * + * @param service_id int * + * @param service_opt int * + * @return pointer to resp_text + */ +int dlt_set_loginfo_parse_service_id(char *resp_text, uint32_t *service_id, uint8_t *service_opt); + +/** + * Convert get log info from ASCII to uint16 + * + * @param rp char + * @param rp_count int + * @return length + */ +int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count); + +/** + * Convert get log info from ASCII to int16 + * + * @param rp char + * @param rp_count int + * @return length + */ +int16_t dlt_getloginfo_conv_ascii_to_int16_t(char *rp, int *rp_count); + +/** + * Convert get log info from ASCII to ID + * + * @param rp char + * @param rp_count int + * @param wp char + * @param length int + */ +void dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len); + +/** + * Convert from hex ASCII to binary + * @param ptr const char + * @param binary uint8_t + * @param size int + */ +void dlt_hex_ascii_to_binary(const char *ptr, uint8_t *binary, int *size); + +# ifndef DLT_USE_UNIX_SOCKET_IPC +/** + * Create the specified path, recursive if necessary + * behaves like calling mkdir -p on the console + */ +int dlt_mkdir_recursive(const char *dir); +# endif + +# ifdef __cplusplus } -#endif +# endif /** - \} -*/ + \} + */ #endif /* DLT_COMMON_H */ diff --git a/include/dlt/dlt_common_api.h b/include/dlt/dlt_common_api.h index 701105f..5927ac7 100644 --- a/include/dlt/dlt_common_api.h +++ b/include/dlt/dlt_common_api.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_common_api.h -*/ + */ /******************************************************************************* ** ** @@ -93,8 +93,8 @@ * @param APPID context id with maximal four characters * @param DESCRIPTION ASCII string containing description */ -#define DLT_REGISTER_CONTEXT_APP(CONTEXT,CONTEXTID,APPID,DESCRIPTION) \ - DLT_REGISTER_CONTEXT(CONTEXT,CONTEXTID,DESCRIPTION) +#define DLT_REGISTER_CONTEXT_APP(CONTEXT, CONTEXTID, APPID, DESCRIPTION) \ + DLT_REGISTER_CONTEXT(CONTEXT, CONTEXTID, DESCRIPTION) /** * Send log message with variable list of messages (intended for verbose mode) @@ -104,56 +104,193 @@ * @param ARGS variable list of arguments */ /*****************************************/ -#define DLT_LOG0(CONTEXT,LOGLEVEL) \ - DLT_LOG(CONTEXT, LOGLEVEL ) +#define DLT_LOG0(CONTEXT, LOGLEVEL) \ + DLT_LOG(CONTEXT, LOGLEVEL) /*****************************************/ -#define DLT_LOG1(CONTEXT,LOGLEVEL, ARGS1) \ +#define DLT_LOG1(CONTEXT, LOGLEVEL, ARGS1) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1) /*****************************************/ -#define DLT_LOG2(CONTEXT,LOGLEVEL, ARGS1, ARGS2) \ +#define DLT_LOG2(CONTEXT, LOGLEVEL, ARGS1, ARGS2) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2) /*****************************************/ -#define DLT_LOG3(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3) \ +#define DLT_LOG3(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3) /*****************************************/ -#define DLT_LOG4(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4) \ +#define DLT_LOG4(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4) /*****************************************/ -#define DLT_LOG5(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) \ +#define DLT_LOG5(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) /*****************************************/ -#define DLT_LOG6(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) \ +#define DLT_LOG6(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) /*****************************************/ -#define DLT_LOG7(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) \ +#define DLT_LOG7(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) /*****************************************/ -#define DLT_LOG8(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) \ +#define DLT_LOG8(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) /*****************************************/ -#define DLT_LOG9(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) \ +#define DLT_LOG9(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) /*****************************************/ -#define DLT_LOG10(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) \ +#define DLT_LOG10(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) /*****************************************/ -#define DLT_LOG11(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11) \ +#define DLT_LOG11(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11) /*****************************************/ -#define DLT_LOG12(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12) \ +#define DLT_LOG12(CONTEXT, \ + LOGLEVEL, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12) \ DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12) /*****************************************/ -#define DLT_LOG13(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13) \ - DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13) -/*****************************************/ -#define DLT_LOG14(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14) \ - DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14) -/*****************************************/ -#define DLT_LOG15(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15) \ - DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15) -/*****************************************/ -#define DLT_LOG16(CONTEXT,LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15, ARGS16) \ - DLT_LOG(CONTEXT, LOGLEVEL, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15, ARGS16) +#define DLT_LOG13(CONTEXT, \ + LOGLEVEL, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13) \ + DLT_LOG(CONTEXT, \ + LOGLEVEL, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13) +/*****************************************/ +#define DLT_LOG14(CONTEXT, \ + LOGLEVEL, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14) \ + DLT_LOG(CONTEXT, \ + LOGLEVEL, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14) +/*****************************************/ +#define DLT_LOG15(CONTEXT, \ + LOGLEVEL, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14, \ + ARGS15) \ + DLT_LOG(CONTEXT, \ + LOGLEVEL, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14, \ + ARGS15) +/*****************************************/ +#define DLT_LOG16(CONTEXT, \ + LOGLEVEL, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14, \ + ARGS15, \ + ARGS16) \ + DLT_LOG(CONTEXT, \ + LOGLEVEL, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14, \ + ARGS15, \ + ARGS16) /** * Send log message with variable list of messages (intended for non-verbose mode) @@ -162,60 +299,233 @@ * @param LOGLEVEL the log level of the log message * @param MSGID the message id of log message * @param ARGS variable list of arguments: - calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(), - DLT_INT(), DLT_UINT(), DLT_RAW() + * calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(), + * DLT_INT(), DLT_UINT(), DLT_RAW() */ /*****************************************/ -#define DLT_LOG_ID0(CONTEXT,LOGLEVEL,MSGID) \ - DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID ) +#define DLT_LOG_ID0(CONTEXT, LOGLEVEL, MSGID) \ + DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID) /*****************************************/ -#define DLT_LOG_ID1(CONTEXT,LOGLEVEL,MSGID, ARGS1) \ +#define DLT_LOG_ID1(CONTEXT, LOGLEVEL, MSGID, ARGS1) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1) /*****************************************/ -#define DLT_LOG_ID2(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2) \ +#define DLT_LOG_ID2(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2) /*****************************************/ -#define DLT_LOG_ID3(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3) \ +#define DLT_LOG_ID3(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3) /*****************************************/ -#define DLT_LOG_ID4(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4) \ +#define DLT_LOG_ID4(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4) /*****************************************/ -#define DLT_LOG_ID5(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) \ +#define DLT_LOG_ID5(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5) /*****************************************/ -#define DLT_LOG_ID6(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) \ +#define DLT_LOG_ID6(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6) /*****************************************/ -#define DLT_LOG_ID7(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) \ +#define DLT_LOG_ID7(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7) /*****************************************/ -#define DLT_LOG_ID8(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) \ +#define DLT_LOG_ID8(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8) /*****************************************/ -#define DLT_LOG_ID9(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) \ +#define DLT_LOG_ID9(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9) /*****************************************/ -#define DLT_LOG_ID10(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) \ +#define DLT_LOG_ID10(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10) /*****************************************/ -#define DLT_LOG_ID11(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11) \ +#define DLT_LOG_ID11(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11) \ DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11) /*****************************************/ -#define DLT_LOG_ID12(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12) \ - DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12) -/*****************************************/ -#define DLT_LOG_ID13(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13) \ - DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13) -/*****************************************/ -#define DLT_LOG_ID14(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14) \ - DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14) -/*****************************************/ -#define DLT_LOG_ID15(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15) \ - DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15) -/*****************************************/ -#define DLT_LOG_ID16(CONTEXT,LOGLEVEL,MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15, ARGS16) \ - DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS1, ARGS2, ARGS3, ARGS4, ARGS5, ARGS6, ARGS7, ARGS8, ARGS9, ARGS10, ARGS11, ARGS12, ARGS13, ARGS14, ARGS15, ARGS16) +#define DLT_LOG_ID12(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12) \ + DLT_LOG_ID(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12) +/*****************************************/ +#define DLT_LOG_ID13(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13) \ + DLT_LOG_ID(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13) +/*****************************************/ +#define DLT_LOG_ID14(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14) \ + DLT_LOG_ID(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14) +/*****************************************/ +#define DLT_LOG_ID15(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14, \ + ARGS15) \ + DLT_LOG_ID(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14, \ + ARGS15) +/*****************************************/ +#define DLT_LOG_ID16(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14, \ + ARGS15, \ + ARGS16) \ + DLT_LOG_ID(CONTEXT, \ + LOGLEVEL, \ + MSGID, \ + ARGS1, \ + ARGS2, \ + ARGS3, \ + ARGS4, \ + ARGS5, \ + ARGS6, \ + ARGS7, \ + ARGS8, \ + ARGS9, \ + ARGS10, \ + ARGS11, \ + ARGS12, \ + ARGS13, \ + ARGS14, \ + ARGS15, \ + ARGS16) /** * Unregister context. diff --git a/include/dlt/dlt_filetransfer.h b/include/dlt/dlt_filetransfer.h index 2f2089f..1cc96cc 100644 --- a/include/dlt/dlt_filetransfer.h +++ b/include/dlt/dlt_filetransfer.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_filetransfer.h -*/ + */ #include /* Needed for LONG_MAX */ #include /* Needed for struct stat st*/ @@ -134,4 +134,4 @@ extern int dlt_user_log_file_data(DltContext *fileContext, const char *filename, * @param deleteFlag Flag to delete the file after the whole file is transferred (logged to dlt).1->delete,0->NotDelete * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned. */ -extern int dlt_user_log_file_end(DltContext *fileContext, const char *filename,int deleteFlag); +extern int dlt_user_log_file_end(DltContext *fileContext, const char *filename, int deleteFlag); diff --git a/include/dlt/dlt_offline_trace.h b/include/dlt/dlt_offline_trace.h index 7612b90..a8cf1ee 100644 --- a/include/dlt/dlt_offline_trace.h +++ b/include/dlt/dlt_offline_trace.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_offline_trace.h -*/ + */ /******************************************************************************* @@ -68,17 +68,17 @@ #define DLT_OFFLINETRACE_FILENAME_TO_COMPARE "dlt_offlinetrace_" /* "dlt_offlinetrace.4294967295.dlt" -> MAX 32byte include NULL terminate */ #define DLT_OFFLINETRACE_FILENAME_MAX_SIZE (sizeof(DLT_OFFLINETRACE_FILENAME_BASE) + \ - sizeof(DLT_OFFLINETRACE_FILENAME_DELI) + \ - DLT_OFFLINETRACE_INDEX_MAX_SIZE + \ - sizeof(DLT_OFFLINETRACE_FILENAME_EXT) + 1) + sizeof(DLT_OFFLINETRACE_FILENAME_DELI) + \ + DLT_OFFLINETRACE_INDEX_MAX_SIZE + \ + sizeof(DLT_OFFLINETRACE_FILENAME_EXT) + 1) typedef struct { char directory[NAME_MAX + 1];/**< (String) Store DLT messages to local directory */ char filename[NAME_MAX + 1]; /**< (String) Filename of currently used log file */ - int fileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */ - int maxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */ - int filenameTimestampBased; /**< (int) timestamp based or index based (Default: 1 Timestamp based) */ + int fileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */ + int maxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */ + int filenameTimestampBased; /**< (int) timestamp based or index based (Default: 1 Timestamp based) */ int ohandle; } DltOfflineTrace; @@ -95,7 +95,11 @@ typedef struct *.@param filenameTimestampBased filename to be created on timestamp based or index based * @return negative value if there was an error */ -extern DltReturnValue dlt_offline_trace_init(DltOfflineTrace *trace,const char *directory,int fileSize,int maxSize,int filenameTimestampBased); +extern DltReturnValue dlt_offline_trace_init(DltOfflineTrace *trace, + const char *directory, + int fileSize, + int maxSize, + int filenameTimestampBased); /** * Uninitialise the offline trace @@ -120,7 +124,13 @@ extern DltReturnValue dlt_offline_trace_free(DltOfflineTrace *buf); * @param size3 size in bytes of third data block to be written, 0 if not used * @return negative value if there was an error */ -extern DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace,unsigned char *data1,int size1,unsigned char *data2,int size2,unsigned char *data3,int size3); +extern DltReturnValue dlt_offline_trace_write(DltOfflineTrace *trace, + unsigned char *data1, + int size1, + unsigned char *data2, + int size2, + unsigned char *data3, + int size3); /** * Get size of currently used offline trace buffer diff --git a/include/dlt/dlt_protocol.h b/include/dlt/dlt_protocol.h index 45df907..4a96128 100644 --- a/include/dlt/dlt_protocol.h +++ b/include/dlt/dlt_protocol.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_protocol.h -*/ + */ /******************************************************************************* @@ -64,17 +64,17 @@ * $LastChangedRevision$ * $LastChangedDate$ * $LastChangedBy$ - Initials Date Comment - aw 13.01.2010 initial + * Initials Date Comment + * aw 13.01.2010 initial */ #ifndef DLT_PROTOCOL_H #define DLT_PROTOCOL_H /** - \defgroup protocolapi DLT Protocol API - \addtogroup protocolapi - \{ -*/ + * \defgroup protocolapi DLT Protocol API + * \addtogroup protocolapi + \{ + */ /* * Definitions of the htyp parameter in standard header. @@ -92,7 +92,7 @@ #define DLT_IS_HTYP_WSID(htyp) ((htyp) & DLT_HTYP_WSID) #define DLT_IS_HTYP_WTMS(htyp) ((htyp) & DLT_HTYP_WTMS) -#define DLT_HTYP_PROTOCOL_VERSION1 (1<<5) +#define DLT_HTYP_PROTOCOL_VERSION1 (1 << 5) /* * Definitions of msin parameter in extended header. @@ -138,9 +138,12 @@ #define DLT_CONTROL_RESPONSE 0x02 /**< Response to request message */ #define DLT_CONTROL_TIME 0x03 /**< keep-alive message */ -#define DLT_MSIN_CONTROL_REQUEST ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | (DLT_CONTROL_REQUEST << DLT_MSIN_MTIN_SHIFT)) -#define DLT_MSIN_CONTROL_RESPONSE ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | (DLT_CONTROL_RESPONSE << DLT_MSIN_MTIN_SHIFT)) -#define DLT_MSIN_CONTROL_TIME ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | (DLT_CONTROL_TIME << DLT_MSIN_MTIN_SHIFT)) +#define DLT_MSIN_CONTROL_REQUEST ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | \ + (DLT_CONTROL_REQUEST << DLT_MSIN_MTIN_SHIFT)) +#define DLT_MSIN_CONTROL_RESPONSE ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | \ + (DLT_CONTROL_RESPONSE << DLT_MSIN_MTIN_SHIFT)) +#define DLT_MSIN_CONTROL_TIME ((DLT_TYPE_CONTROL << DLT_MSIN_MSTP_SHIFT) | \ + (DLT_CONTROL_TIME << DLT_MSIN_MTIN_SHIFT)) /* * Definitions of types of arguments in payload. @@ -248,7 +251,7 @@ extern const char *dlt_get_service_name(unsigned int id); /** - \} -*/ + \} + */ #endif /* DLT_PROTOCOL_H */ diff --git a/include/dlt/dlt_shm.h b/include/dlt/dlt_shm.h index 20f9110..93cbe14 100644 --- a/include/dlt/dlt_shm.h +++ b/include/dlt/dlt_shm.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_shm.h -*/ + */ /******************************************************************************* @@ -89,8 +89,8 @@ typedef struct int size; } DltShmBlockHead; -#define DLT_SHM_SEM_GET(id) dlt_shm_pv(id,-1) -#define DLT_SHM_SEM_FREE(id) dlt_shm_pv(id,1) +#define DLT_SHM_SEM_GET(id) dlt_shm_pv(id, -1) +#define DLT_SHM_SEM_FREE(id) dlt_shm_pv(id, 1) /** * Initialise the shared memory on the client side. @@ -99,7 +99,7 @@ typedef struct * @param key the identifier of the shm, must be the same for server and client * @return negative value if there was an error */ -extern DltReturnValue dlt_shm_init_client(DltShm *buf,int key); +extern DltReturnValue dlt_shm_init_client(DltShm *buf, int key); /** * Initialise the shared memory on the server side. @@ -109,7 +109,7 @@ extern DltReturnValue dlt_shm_init_client(DltShm *buf,int key); * @param size the requested size of the shm * @return negative value if there was an error */ -extern DltReturnValue dlt_shm_init_server(DltShm *buf,int key,int size); +extern DltReturnValue dlt_shm_init_server(DltShm *buf, int key, int size); /** * Push data from client onto the shm. @@ -122,7 +122,13 @@ extern DltReturnValue dlt_shm_init_server(DltShm *buf,int key,int size); * @param size3 size in bytes of third data block to be written, 0 if not used * @return negative value if there was an error */ -extern int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const unsigned char *data2,unsigned int size2,const unsigned char *data3,unsigned int size3); +extern int dlt_shm_push(DltShm *buf, + const unsigned char *data1, + unsigned int size1, + const unsigned char *data2, + unsigned int size2, + const unsigned char *data3, + unsigned int size3); /** * Pull data from shm. @@ -133,7 +139,7 @@ extern int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size * @param size maximum size to be written into buffer * @return negative value if there was an error */ -extern int dlt_shm_pull(DltShm *buf,unsigned char *data, int size); +extern int dlt_shm_pull(DltShm *buf, unsigned char *data, int size); /** * Copy message from shm. @@ -144,7 +150,7 @@ extern int dlt_shm_pull(DltShm *buf,unsigned char *data, int size); * @param size maximum size to be written into buffer * @return negative value if there was an error */ -extern int dlt_shm_copy(DltShm *buf,unsigned char *data, int size); +extern int dlt_shm_copy(DltShm *buf, unsigned char *data, int size); /** * Delete message from shm. diff --git a/include/dlt/dlt_types.h b/include/dlt/dlt_types.h index 2393174..6a46c08 100644 --- a/include/dlt/dlt_types.h +++ b/include/dlt/dlt_types.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_types.h -*/ + */ /******************************************************************************* @@ -63,21 +63,21 @@ typedef __int64 int64_t; typedef __int32 int32_t; typedef __int16 int16_t; -typedef __int8 int8_t; +typedef __int8 int8_t; typedef unsigned __int64 uint64_t; typedef unsigned __int32 uint32_t; typedef unsigned __int16 uint16_t; -typedef unsigned __int8 uint8_t; +typedef unsigned __int8 uint8_t; typedef int pid_t; typedef unsigned int speed_t; -#define UINT16_MAX 0xFFFF +# define UINT16_MAX 0xFFFF -#include +# include #else -#include +# include #endif /** @@ -87,13 +87,13 @@ typedef enum { DLT_RETURN_LOGGING_DISABLED = -7, DLT_RETURN_USER_BUFFER_FULL = -6, - DLT_RETURN_WRONG_PARAMETER = -5, - DLT_RETURN_BUFFER_FULL = -4, - DLT_RETURN_PIPE_FULL = -3, - DLT_RETURN_PIPE_ERROR = -2, - DLT_RETURN_ERROR = -1, - DLT_RETURN_OK = 0, - DLT_RETURN_TRUE = 1 + DLT_RETURN_WRONG_PARAMETER = -5, + DLT_RETURN_BUFFER_FULL = -4, + DLT_RETURN_PIPE_FULL = -3, + DLT_RETURN_PIPE_ERROR = -2, + DLT_RETURN_ERROR = -1, + DLT_RETURN_OK = 0, + DLT_RETURN_TRUE = 1 } DltReturnValue; /** @@ -101,14 +101,14 @@ typedef enum */ typedef enum { - DLT_LOG_DEFAULT = -1, /**< Default log level */ - DLT_LOG_OFF = 0x00, /**< Log level off */ - DLT_LOG_FATAL = 0x01, /**< fatal system error */ - DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */ - DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */ - DLT_LOG_INFO = 0x04, /**< informational */ - DLT_LOG_DEBUG = 0x05, /**< debug */ - DLT_LOG_VERBOSE = 0x06, /**< highest grade of information */ + DLT_LOG_DEFAULT = -1, /**< Default log level */ + DLT_LOG_OFF = 0x00, /**< Log level off */ + DLT_LOG_FATAL = 0x01, /**< fatal system error */ + DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */ + DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */ + DLT_LOG_INFO = 0x04, /**< informational */ + DLT_LOG_DEBUG = 0x05, /**< debug */ + DLT_LOG_VERBOSE = 0x06, /**< highest grade of information */ DLT_LOG_MAX /**< maximum value, used for range check */ } DltLogLevelType; @@ -117,13 +117,13 @@ typedef enum */ typedef enum { - DLT_FORMAT_DEFAULT = 0x00, /**< no sepecial format */ - DLT_FORMAT_HEX8 = 0x01, /**< Hex 8 */ - DLT_FORMAT_HEX16 = 0x02, /**< Hex 16 */ - DLT_FORMAT_HEX32 = 0x03, /**< Hex 32 */ - DLT_FORMAT_HEX64 = 0x04, /**< Hex 64 */ - DLT_FORMAT_BIN8 = 0x05, /**< Binary 8 */ - DLT_FORMAT_BIN16 = 0x06, /**< Binary 16 */ + DLT_FORMAT_DEFAULT = 0x00, /**< no sepecial format */ + DLT_FORMAT_HEX8 = 0x01, /**< Hex 8 */ + DLT_FORMAT_HEX16 = 0x02, /**< Hex 16 */ + DLT_FORMAT_HEX32 = 0x03, /**< Hex 32 */ + DLT_FORMAT_HEX64 = 0x04, /**< Hex 64 */ + DLT_FORMAT_BIN8 = 0x05, /**< Binary 8 */ + DLT_FORMAT_BIN16 = 0x06, /**< Binary 16 */ DLT_FORMAT_MAX /**< maximum value, used for range check */ } DltFormatType; @@ -132,9 +132,9 @@ typedef enum */ typedef enum { - DLT_TRACE_STATUS_DEFAULT = -1, /**< Default trace status */ - DLT_TRACE_STATUS_OFF = 0x00, /**< Trace status: Off */ - DLT_TRACE_STATUS_ON = 0x01, /**< Trace status: On */ + DLT_TRACE_STATUS_DEFAULT = -1, /**< Default trace status */ + DLT_TRACE_STATUS_OFF = 0x00, /**< Trace status: Off */ + DLT_TRACE_STATUS_ON = 0x01, /**< Trace status: On */ DLT_TRACE_STATUS_MAX /**< maximum value, used for range check */ } DltTraceStatusType; @@ -144,21 +144,21 @@ typedef enum */ typedef enum { - DLT_NW_TRACE_IPC = 0x01, /**< Interprocess communication */ - DLT_NW_TRACE_CAN = 0x02, /**< Controller Area Network Bus */ - DLT_NW_TRACE_FLEXRAY = 0x03, /**< Flexray Bus */ - DLT_NW_TRACE_MOST = 0x04, /**< Media Oriented System Transport Bus */ - DLT_NW_TRACE_RESERVED0 = 0x05, - DLT_NW_TRACE_RESERVED1 = 0x06, - DLT_NW_TRACE_RESERVED2 = 0x07, - DLT_NW_TRACE_USER_DEFINED0 = 0x08, - DLT_NW_TRACE_USER_DEFINED1 = 0x09, - DLT_NW_TRACE_USER_DEFINED2 = 0x0A, - DLT_NW_TRACE_USER_DEFINED3 = 0x0B, - DLT_NW_TRACE_USER_DEFINED4 = 0x0C, - DLT_NW_TRACE_USER_DEFINED5 = 0x0D, - DLT_NW_TRACE_USER_DEFINED6 = 0x0E, - DLT_NW_TRACE_USER_DEFINED7 = 0x0F, + DLT_NW_TRACE_IPC = 0x01, /**< Interprocess communication */ + DLT_NW_TRACE_CAN = 0x02, /**< Controller Area Network Bus */ + DLT_NW_TRACE_FLEXRAY = 0x03, /**< Flexray Bus */ + DLT_NW_TRACE_MOST = 0x04, /**< Media Oriented System Transport Bus */ + DLT_NW_TRACE_RESERVED0 = 0x05, + DLT_NW_TRACE_RESERVED1 = 0x06, + DLT_NW_TRACE_RESERVED2 = 0x07, + DLT_NW_TRACE_USER_DEFINED0 = 0x08, + DLT_NW_TRACE_USER_DEFINED1 = 0x09, + DLT_NW_TRACE_USER_DEFINED2 = 0x0A, + DLT_NW_TRACE_USER_DEFINED3 = 0x0B, + DLT_NW_TRACE_USER_DEFINED4 = 0x0C, + DLT_NW_TRACE_USER_DEFINED5 = 0x0D, + DLT_NW_TRACE_USER_DEFINED6 = 0x0E, + DLT_NW_TRACE_USER_DEFINED7 = 0x0F, DLT_NW_TRACE_MAX /**< maximum value, used for range check */ } DltNetworkTraceType; @@ -167,15 +167,15 @@ typedef enum */ typedef enum { - DLT_USER_MODE_UNDEFINED = -1, - DLT_USER_MODE_OFF = 0, - DLT_USER_MODE_EXTERNAL , - DLT_USER_MODE_INTERNAL , - DLT_USER_MODE_BOTH , + DLT_USER_MODE_UNDEFINED = -1, + DLT_USER_MODE_OFF = 0, + DLT_USER_MODE_EXTERNAL, + DLT_USER_MODE_INTERNAL, + DLT_USER_MODE_BOTH, DLT_USER_MODE_MAX /**< maximum value, used for range check */ } DltUserLogMode; -typedef float float32_t; +typedef float float32_t; typedef double float64_t; /** diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h index 997c1c4..d736032 100644 --- a/include/dlt/dlt_user.h +++ b/include/dlt/dlt_user.h @@ -22,7 +22,7 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_user.h -*/ + */ /******************************************************************************* ** ** @@ -63,39 +63,39 @@ * $LastChangedRevision: 1670 $ * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $ * $LastChangedBy$ - Initials Date Comment - aw 13.01.2010 initial + * Initials Date Comment + * aw 13.01.2010 initial */ #ifndef DLT_USER_H -#define DLT_USER_H +# define DLT_USER_H /** - \defgroup userapi DLT User API - \addtogroup userapi - \{ -*/ -#include + * \defgroup userapi DLT User API + * \addtogroup userapi + \{ + */ +# include -#if !defined (__WIN32__) -#include -#endif +# if !defined (__WIN32__) +# include +# endif -#include "dlt_types.h" -#include "dlt_user_macros.h" -#include "dlt_shm.h" +# include "dlt_types.h" +# include "dlt_user_macros.h" +# include "dlt_shm.h" -#ifdef __cplusplus +# ifdef __cplusplus extern "C" { -#endif +# endif -#define DLT_USER_BUF_MAX_SIZE 1390 /**< maximum size of each user buffer, also used for injection buffer */ +# define DLT_USER_BUF_MAX_SIZE 1390 /**< maximum size of each user buffer, also used for injection buffer */ -#define DLT_USER_RESENDBUF_MAX_SIZE (DLT_USER_BUF_MAX_SIZE + 100) /**< Size of resend buffer; Max DLT message size is 1390 bytes plus some extra header space */ +# define DLT_USER_RESENDBUF_MAX_SIZE (DLT_USER_BUF_MAX_SIZE + 100) /**< Size of resend buffer; Max DLT message size is 1390 bytes plus some extra header space */ /* Use a semaphore or mutex from your OS to prevent concurrent access to the DLT buffer. */ -#define DLT_SEM_LOCK() { sem_wait(&dlt_mutex); } -#define DLT_SEM_FREE() { sem_post(&dlt_mutex); } +# define DLT_SEM_LOCK() { sem_wait(&dlt_mutex); } +# define DLT_SEM_FREE() { sem_post(&dlt_mutex); } /** * This structure is used for every context used in an application. @@ -120,7 +120,7 @@ typedef struct int32_t log_level; /**< log level */ int32_t trace_status; /**< trace status */ int32_t args_num; /**< number of arguments for extended header*/ - char* context_description; /**< description of context */ + char *context_description; /**< description of context */ } DltContextData; typedef struct @@ -136,7 +136,7 @@ typedef struct char contextID[DLT_ID_SIZE]; /**< Context ID */ int8_t log_level; /**< Log level */ int8_t trace_status; /**< Trace status */ - void (*log_level_changed_callback) (char context_id[DLT_ID_SIZE],uint8_t log_level,uint8_t trace_status); + void (*log_level_changed_callback)(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status); } DltUserLogLevelChangedCallback; /** @@ -154,7 +154,7 @@ typedef struct uint32_t nrcallbacks; /* Log Level changed callback */ - void (*log_level_changed_callback) (char context_id[DLT_ID_SIZE],uint8_t log_level,uint8_t trace_status); + void (*log_level_changed_callback)(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status); } dlt_ll_ts_type; @@ -174,7 +174,7 @@ typedef struct */ typedef struct { - dlt_env_ll_item * item; + dlt_env_ll_item *item; size_t array_size; size_t num_elem; } dlt_env_ll_set; @@ -196,7 +196,7 @@ typedef struct int8_t dlt_is_file; /**< Target of logging: 1 to file, 0 to daemon */ dlt_ll_ts_type *dlt_ll_ts; /** [MAX_DLT_LL_TS_ENTRIES]; < Internal management struct for all - contexts */ + * contexts */ uint32_t dlt_ll_ts_max_num_entries; /**< Maximum number of contexts */ uint32_t dlt_ll_ts_num_entries; /**< Number of used contexts */ @@ -218,9 +218,9 @@ typedef struct int8_t local_print_mode; /**< Local print mode, controlled by environment variable */ int8_t log_state; /**< Log state of external connection: - 1 client connected, - 0 not connected, - -1 unknown */ + * 1 client connected, + * 0 not connected, + * -1 unknown */ DltBuffer startup_buffer; /**< Ring-buffer for buffering messages during startup and missing connection */ /* Buffer used for resending, locked by DLT semaphore */ @@ -229,14 +229,14 @@ typedef struct uint32_t timeout_at_exit_handler; /**< timeout used in dlt_user_atexit_blow_out_user_buffer, in 0.1 milliseconds */ dlt_env_ll_set initial_ll_set; -#ifdef DLT_SHM_ENABLE +# ifdef DLT_SHM_ENABLE DltShm dlt_shm; -#endif -#ifdef DLT_TEST_ENABLE +# endif +# ifdef DLT_TEST_ENABLE int corrupt_user_header; int corrupt_message_size; int16_t corrupt_message_size_size; -#endif +# endif DltUserConnectionState connection_state; uint16_t log_buf_len; /**< length of message buffer, by default: DLT_USER_BUF_MAX_SIZE */ } DltUser; @@ -271,7 +271,10 @@ DltReturnValue dlt_user_log_write_start(DltContext *handle, DltContextData *log, * @param messageid message id of message * @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is matching */ -DltReturnValue dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid); +DltReturnValue dlt_user_log_write_start_id(DltContext *handle, + DltContextData *log, + DltLogLevelType loglevel, + uint32_t messageid); /** * Finishing the generation of a DLT log message and sending it to the DLT daemon. @@ -370,7 +373,7 @@ DltReturnValue dlt_user_log_write_int64(DltContextData *log, int64_t data); * @param text pointer to the parameter written into log message containing null termination. * @return Value from DltReturnValue enum */ -DltReturnValue dlt_user_log_write_string( DltContextData *log, const char *text); +DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text); /** * Write a constant null terminated ASCII string into a DLT log message. @@ -381,7 +384,7 @@ DltReturnValue dlt_user_log_write_string( DltContextData *log, const char *text) * @param text pointer to the parameter written into log message containing null termination. * @return Value from DltReturnValue enum */ -DltReturnValue dlt_user_log_write_constant_string( DltContextData *log, const char *text); +DltReturnValue dlt_user_log_write_constant_string(DltContextData *log, const char *text); /** * Write a null terminated UTF8 string into a DLT log message. @@ -402,7 +405,7 @@ DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *t * @param length length in bytes of the parameter written into log message. * @return Value from DltReturnValue enum */ -DltReturnValue dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t length); +DltReturnValue dlt_user_log_write_raw(DltContextData *log, void *data, uint16_t length); /** * Write a binary memory block into a DLT log message. @@ -414,7 +417,7 @@ DltReturnValue dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t le * @param type the format information. * @return Value from DltReturnValue enum */ -DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log,void *data,uint16_t length,DltFormatType type); +DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log, void *data, uint16_t length, DltFormatType type); /** * Trace network message @@ -426,7 +429,12 @@ DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log,void *data,u * @param payload pointer to network message payload * @return Value from DltReturnValue enum */ -DltReturnValue dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload); +DltReturnValue dlt_user_trace_network(DltContext *handle, + DltNetworkTraceType nw_trace_type, + uint16_t header_len, + void *header, + uint16_t payload_len, + void *payload); /** * Trace network message, truncated if necessary. @@ -439,7 +447,13 @@ DltReturnValue dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw * @param allow_truncate Set to > 0 to allow truncating of the message if it is too large. * @return Value from DltReturnValue enum */ -DltReturnValue dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload, int allow_truncate); +DltReturnValue dlt_user_trace_network_truncated(DltContext *handle, + DltNetworkTraceType nw_trace_type, + uint16_t header_len, + void *header, + uint16_t payload_len, + void *payload, + int allow_truncate); /** * Trace network message in segmented asynchronous mode. @@ -454,11 +468,16 @@ DltReturnValue dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTr * @param payload pointer to network message payload * @return Value from DltReturnValue enum */ -DltReturnValue dlt_user_trace_network_segmented(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload); +DltReturnValue dlt_user_trace_network_segmented(DltContext *handle, + DltNetworkTraceType nw_trace_type, + uint16_t header_len, + void *header, + uint16_t payload_len, + void *payload); /************************************************************************************************** - * The following API functions define a high level function interface for DLT - **************************************************************************************************/ +* The following API functions define a high level function interface for DLT +**************************************************************************************************/ /** * Initialize the user lib communication with daemon. @@ -488,7 +507,7 @@ DltReturnValue dlt_free(); * @param user_minor_version the minor version to be compared * @return Value from DltReturnValue enum, DLT_RETURN_ERROR if there is a mismatch */ -DltReturnValue dlt_check_library_version(const char * user_major_version, const char * user_minor_version); +DltReturnValue dlt_check_library_version(const char *user_major_version, const char *user_minor_version); /** * Register an application in the daemon. @@ -496,7 +515,7 @@ DltReturnValue dlt_check_library_version(const char * user_major_version, const * @param description long name of the application * @return Value from DltReturnValue enum */ -DltReturnValue dlt_register_app(const char *appid, const char * description); +DltReturnValue dlt_register_app(const char *appid, const char *description); /** * Unregister an application in the daemon. @@ -520,7 +539,7 @@ DltReturnValue dlt_unregister_app_flush_buffered_logs(void); * @param description long name of the context * @return Value from DltReturnValue enum */ -DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, const char * description); +DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, const char *description); /** * Register a context in the daemon with pre-defined log level and pre-defined trace status. @@ -529,12 +548,16 @@ DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, c * @param contextid four byte long character array with the context id * @param description long name of the context * @param loglevel This is the log level to be pre-set for this context - (DLT_LOG_DEFAULT is not allowed here) + * (DLT_LOG_DEFAULT is not allowed here) * @param tracestatus This is the trace status to be pre-set for this context - (DLT_TRACE_STATUS_DEFAULT is not allowed here) + * (DLT_TRACE_STATUS_DEFAULT is not allowed here) * @return Value from DltReturnValue enum */ -DltReturnValue dlt_register_context_ll_ts(DltContext *handle, const char *contextid, const char * description, int loglevel, int tracestatus); +DltReturnValue dlt_register_context_ll_ts(DltContext *handle, + const char *contextid, + const char *description, + int loglevel, + int tracestatus); /** * Register a context in the daemon with log level changed callback fn. @@ -547,7 +570,7 @@ DltReturnValue dlt_register_context_ll_ts(DltContext *handle, const char *contex */ DltReturnValue dlt_register_context_llccb(DltContext *handle, const char *contextid, - const char * description, + const char *description, void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status)); @@ -594,7 +617,9 @@ int dlt_get_log_state(); * @return Value from DltReturnValue enum */ DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t service_id, - int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length)); + int (*dlt_injection_callback)(uint32_t service_id, + void *data, + uint32_t length)); /** * Register callback function with private data called when injection message was received @@ -604,7 +629,10 @@ DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t serv * @return Value from DltReturnValue enum */ DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint32_t service_id, - int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length, void *priv_data), void *priv); + int (*dlt_injection_callback)(uint32_t service_id, + void *data, + uint32_t length, + void *priv_data), void *priv); /** * Register callback function called when log level of context was changed @@ -613,7 +641,10 @@ DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint3 * @return Value from DltReturnValue enum */ DltReturnValue dlt_register_log_level_changed_callback(DltContext *handle, - void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],uint8_t log_level, uint8_t trace_status)); + void (*dlt_log_level_changed_callback)( + char context_id[DLT_ID_SIZE], + uint8_t log_level, + uint8_t trace_status)); /** * Switch to verbose mode @@ -627,7 +658,7 @@ DltReturnValue dlt_verbose_mode(void); * @param Minor version number of application - see dlt_version.h * @return Value from DltReturnValue enum, DLT_RETURN_ERROR if there is a mismatch */ -DltReturnValue dlt_user_check_library_version(const char *user_major_version,const char *user_minor_version); +DltReturnValue dlt_user_check_library_version(const char *user_major_version, const char *user_minor_version); /** * Switch to non-verbose mode @@ -692,7 +723,10 @@ DltReturnValue dlt_set_application_ll_ts_limit(DltLogLevelType loglevel, DltTrac * * If no item matches or in case of error, the original log-level (\param ll) is returned */ -int dlt_env_adjust_ll_from_env(dlt_env_ll_set const * const ll_set, char const * const apid, char const * const ctid, int const ll); +int dlt_env_adjust_ll_from_env(dlt_env_ll_set const *const ll_set, + char const *const apid, + char const *const ctid, + int const ll); /** * @brief extract log-level settings from given string @@ -706,9 +740,9 @@ int dlt_env_adjust_ll_from_env(dlt_env_ll_set const * const ll_set, char const * * @return 0 on success * @return -1 on failure */ -int dlt_env_extract_ll_set(char ** const env, dlt_env_ll_set * const ll_set); +int dlt_env_extract_ll_set(char **const env, dlt_env_ll_set *const ll_set); -void dlt_env_free_ll_set(dlt_env_ll_set * const ll_set); +void dlt_env_free_ll_set(dlt_env_ll_set *const ll_set); /** * Enable local printing of messages @@ -729,7 +763,7 @@ DltReturnValue dlt_disable_local_print(void); * @param text pointer to the ASCII string written into log message containing null termination. * @return Value from DltReturnValue enum */ -DltReturnValue dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const char *text); +DltReturnValue dlt_log_string(DltContext *handle, DltLogLevelType loglevel, const char *text); /** * Write a null terminated ASCII string and an integer value into a DLT log message. @@ -739,7 +773,7 @@ DltReturnValue dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const * @param data integer value written into the log message * @return Value from DltReturnValue enum */ -DltReturnValue dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, const char *text, int data); +DltReturnValue dlt_log_string_int(DltContext *handle, DltLogLevelType loglevel, const char *text, int data); /** * Write a null terminated ASCII string and an unsigned integer value into a DLT log message. @@ -749,7 +783,7 @@ DltReturnValue dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, c * @param data unsigned integer value written into the log message * @return Value from DltReturnValue enum */ -DltReturnValue dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, const char *text, unsigned int data); +DltReturnValue dlt_log_string_uint(DltContext *handle, DltLogLevelType loglevel, const char *text, unsigned int data); /** * Write an integer value into a DLT log message. @@ -758,7 +792,7 @@ DltReturnValue dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, * @param data integer value written into the log message * @return Value from DltReturnValue enum */ -DltReturnValue dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data); +DltReturnValue dlt_log_int(DltContext *handle, DltLogLevelType loglevel, int data); /** * Write an unsigned integer value into a DLT log message. @@ -767,7 +801,7 @@ DltReturnValue dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data * @param data unsigned integer value written into the log message * @return Value from DltReturnValue enum */ -DltReturnValue dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigned int data); +DltReturnValue dlt_log_uint(DltContext *handle, DltLogLevelType loglevel, unsigned int data); /** * Write an unsigned integer value into a DLT log message. @@ -777,7 +811,7 @@ DltReturnValue dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigne * @param length length in bytes of the parameter written into log message. * @return Value from DltReturnValue enum */ -DltReturnValue dlt_log_raw(DltContext *handle,DltLogLevelType loglevel, void *data,uint16_t length); +DltReturnValue dlt_log_raw(DltContext *handle, DltLogLevelType loglevel, void *data, uint16_t length); /** * Write marker message to DLT. @@ -791,7 +825,7 @@ DltReturnValue dlt_log_marker(); * @param size Size of DLT message * @return Value from DltReturnValue enum */ -DltReturnValue dlt_forward_msg(void *msgdata,size_t size); +DltReturnValue dlt_forward_msg(void *msgdata, size_t size); /** * Get the total size and available size of the shared memory buffer between daemon and applications. @@ -825,37 +859,31 @@ DltReturnValue dlt_user_log_resend_buffer(void); * @param loglevel this is the current log level of the log message to be sent * @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is enabled */ -static inline DltReturnValue dlt_user_is_logLevel_enabled(DltContext *handle,DltLogLevelType loglevel) +static inline DltReturnValue dlt_user_is_logLevel_enabled(DltContext *handle, DltLogLevelType loglevel) { - if (loglevel < DLT_LOG_DEFAULT || loglevel >= DLT_LOG_MAX) - { + if ((loglevel < DLT_LOG_DEFAULT) || (loglevel >= DLT_LOG_MAX)) return DLT_RETURN_WRONG_PARAMETER; - } - if (handle == NULL || handle->log_level_ptr == NULL) - { + if ((handle == NULL) || (handle->log_level_ptr == NULL)) return DLT_RETURN_WRONG_PARAMETER; - } - if (loglevel <= (DltLogLevelType)(*(handle->log_level_ptr)) && loglevel != DLT_LOG_OFF) - { + if ((loglevel <= (DltLogLevelType)(*(handle->log_level_ptr))) && (loglevel != DLT_LOG_OFF)) return DLT_RETURN_TRUE; - } return DLT_RETURN_LOGGING_DISABLED; } -#ifdef DLT_TEST_ENABLE - void dlt_user_test_corrupt_user_header(int enable); - void dlt_user_test_corrupt_message_size(int enable,int16_t size); -#endif /* DLT_TEST_ENABLE */ +# ifdef DLT_TEST_ENABLE +void dlt_user_test_corrupt_user_header(int enable); +void dlt_user_test_corrupt_message_size(int enable, int16_t size); +# endif /* DLT_TEST_ENABLE */ -#ifdef __cplusplus +# ifdef __cplusplus } -#endif +# endif /** - \} -*/ + \} + */ #endif /* DLT_USER_H */ diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h index 7455811..74e5cf5 100644 --- a/include/dlt/dlt_user_macros.h +++ b/include/dlt/dlt_user_macros.h @@ -22,49 +22,49 @@ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. * * \file dlt_user_macros.h -*/ + */ /******************************************************************************* - ** ** - ** SRC-MODULE: dlt_user_macros.h ** - ** ** - ** TARGET : linux ** - ** ** - ** PROJECT : DLT ** - ** ** - ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** - ** Markus Klein ** - ** ** - ** PURPOSE : ** - ** ** - ** REMARKS : ** - ** ** - ** PLATFORM DEPENDANT [yes/no]: yes ** - ** ** - ** TO BE CHANGED BY USER [yes/no]: no ** - ** ** - *******************************************************************************/ +** ** +** SRC-MODULE: dlt_user_macros.h ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** +** Markus Klein ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ /******************************************************************************* - ** Author Identity ** - ******************************************************************************** - ** ** - ** Initials Name Company ** - ** -------- ------------------------- ---------------------------------- ** - ** aw Alexander Wenzel BMW ** - ** mk Markus Klein Fraunhofer ESK ** - *******************************************************************************/ +** Author Identity ** +******************************************************************************** +** ** +** Initials Name Company ** +** -------- ------------------------- ---------------------------------- ** +** aw Alexander Wenzel BMW ** +** mk Markus Klein Fraunhofer ESK ** +*******************************************************************************/ /******************************************************************************* - ** Revision Control History ** - *******************************************************************************/ +** Revision Control History ** +*******************************************************************************/ /* * $LastChangedRevision: 1515 $ * $LastChangedDate: 2010-12-13 09:18:54 +0100 (Mon, 13 Dec 2010) $ * $LastChangedBy$ - Initials Date Comment - aw 13.01.2010 initial + * Initials Date Comment + * aw 13.01.2010 initial */ #ifndef DLT_USER_MACROS_H @@ -73,14 +73,14 @@ #include "dlt_version.h" /** - \defgroup userapi DLT User API - \addtogroup userapi - \{ -*/ + * \defgroup userapi DLT User API + * \addtogroup userapi + \{ + */ /************************************************************************************************** - * The folowing macros define a macro interface for DLT - **************************************************************************************************/ +* The folowing macros define a macro interface for DLT +**************************************************************************************************/ /** * Create an object for a new context. @@ -109,22 +109,22 @@ * @param APPID application id with maximal four characters * @param DESCRIPTION ASCII string containing description */ -#define DLT_REGISTER_APP(APPID,DESCRIPTION) do {\ - (void)dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION ); \ - (void)dlt_register_app( APPID, DESCRIPTION);} while(0) +#define DLT_REGISTER_APP(APPID, DESCRIPTION) do { \ + (void)dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION); \ + (void)dlt_register_app(APPID, DESCRIPTION); } while (0) /** * Unregister application. */ -#define DLT_UNREGISTER_APP() do{\ - (void)dlt_unregister_app();} while(0) +#define DLT_UNREGISTER_APP() do { \ + (void)dlt_unregister_app(); } while (0) /** * Unregister application and flush the logs buffered in startup buffer if any. */ -#define DLT_UNREGISTER_APP_FLUSH_BUFFERED_LOGS() do{\ - (void)dlt_unregister_app_flush_buffered_logs();} while(0) +#define DLT_UNREGISTER_APP_FLUSH_BUFFERED_LOGS() do { \ + (void)dlt_unregister_app_flush_buffered_logs(); } while (0) /** * Register context (with default log level and default trace status) @@ -132,8 +132,8 @@ * @param CONTEXTID context id with maximal four characters * @param DESCRIPTION ASCII string containing description */ -#define DLT_REGISTER_CONTEXT(CONTEXT,CONTEXTID,DESCRIPTION) do{\ - (void)dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION);} while(0) +#define DLT_REGISTER_CONTEXT(CONTEXT, CONTEXTID, DESCRIPTION) do { \ + (void)dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION); } while (0) /** * Register context with pre-defined log level and pre-defined trace status. @@ -141,12 +141,12 @@ * @param CONTEXTID context id with maximal four characters * @param DESCRIPTION ASCII string containing description * @param LOGLEVEL log level to be pre-set for this context - (DLT_LOG_DEFAULT is not allowed here) + * (DLT_LOG_DEFAULT is not allowed here) * @param TRACESTATUS trace status to be pre-set for this context - (DLT_TRACE_STATUS_DEFAULT is not allowed here) + * (DLT_TRACE_STATUS_DEFAULT is not allowed here) */ -#define DLT_REGISTER_CONTEXT_LL_TS(CONTEXT,CONTEXTID,DESCRIPTION,LOGLEVEL,TRACESTATUS) do{\ - (void)dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS);} while(0) +#define DLT_REGISTER_CONTEXT_LL_TS(CONTEXT, CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS) do { \ + (void)dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS); } while (0) /** * Register context (with default log level and default trace status and log level change callback) @@ -155,15 +155,15 @@ * @param DESCRIPTION ASCII string containing description * @param CBK log level change callback to be registered */ -#define DLT_REGISTER_CONTEXT_LLCCB(CONTEXT, CONTEXTID, DESCRIPTION, CBK) do{\ - (void)dlt_register_context_llccb(&(CONTEXT), CONTEXTID, DESCRIPTION, CBK);} while(0) +#define DLT_REGISTER_CONTEXT_LLCCB(CONTEXT, CONTEXTID, DESCRIPTION, CBK) do { \ + (void)dlt_register_context_llccb(&(CONTEXT), CONTEXTID, DESCRIPTION, CBK); } while (0) /** * Unregister context. * @param CONTEXT object containing information about one special logging context */ -#define DLT_UNREGISTER_CONTEXT(CONTEXT) do{\ - (void)dlt_unregister_context(&(CONTEXT));} while(0) +#define DLT_UNREGISTER_CONTEXT(CONTEXT) do { \ + (void)dlt_unregister_context(&(CONTEXT)); } while (0) /** * Register callback function called when injection message was received @@ -171,8 +171,8 @@ * @param SERVICEID service id of the injection message * @param CALLBACK function pointer to callback function */ -#define DLT_REGISTER_INJECTION_CALLBACK(CONTEXT, SERVICEID, CALLBACK) do{\ - (void)dlt_register_injection_callback(&(CONTEXT),SERVICEID, CALLBACK);} while(0) +#define DLT_REGISTER_INJECTION_CALLBACK(CONTEXT, SERVICEID, CALLBACK) do { \ + (void)dlt_register_injection_callback(&(CONTEXT), SERVICEID, CALLBACK); } while (0) /** * Register callback function called when injection message was received @@ -181,16 +181,16 @@ * @param CALLBACK function pointer to callback function * @param PRIV_DATA data specific to context */ -#define DLT_REGISTER_INJECTION_CALLBACK_WITH_ID(CONTEXT, SERVICEID, CALLBACK, PRIV_DATA) do{\ - (void)dlt_register_injection_callback_with_id(&(CONTEXT),SERVICEID, CALLBACK, PRIV_DATA);} while(0) +#define DLT_REGISTER_INJECTION_CALLBACK_WITH_ID(CONTEXT, SERVICEID, CALLBACK, PRIV_DATA) do { \ + (void)dlt_register_injection_callback_with_id(&(CONTEXT), SERVICEID, CALLBACK, PRIV_DATA); } while (0) /** * Register callback function called when log level of context was changed * @param CONTEXT object containing information about one special logging context * @param CALLBACK function pointer to callback function */ -#define DLT_REGISTER_LOG_LEVEL_CHANGED_CALLBACK(CONTEXT, CALLBACK) do{\ - (void)dlt_register_log_level_changed_callback(&(CONTEXT),CALLBACK);} while(0) +#define DLT_REGISTER_LOG_LEVEL_CHANGED_CALLBACK(CONTEXT, CALLBACK) do { \ + (void)dlt_register_log_level_changed_callback(&(CONTEXT), CALLBACK); } while (0) /** * Send log message with variable list of messages (intended for verbose mode) @@ -205,17 +205,17 @@ /* DLT_LOG is not supported by MS Visual C++ */ /* use function interface instead */ #else -#define DLT_LOG(CONTEXT,LOGLEVEL,ARGS...) \ +# define DLT_LOG(CONTEXT, LOGLEVEL, ARGS ...) \ do { \ DltContextData log_local; \ int dlt_local; \ - dlt_local = dlt_user_log_write_start(&CONTEXT,&log_local,LOGLEVEL); \ + dlt_local = dlt_user_log_write_start(&CONTEXT, &log_local, LOGLEVEL); \ if (dlt_local == DLT_RETURN_TRUE) \ { \ ARGS; \ (void)dlt_user_log_write_finish(&log_local); \ } \ - } while(0) + } while (0) #endif /** @@ -224,8 +224,8 @@ * @param LOGLEVEL the log level of the log message * @param MSGID the message id of log message * @param ARGS variable list of arguments: - calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(), - DLT_INT(), DLT_UINT(), DLT_RAW() + * calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(), + * DLT_INT(), DLT_UINT(), DLT_RAW() * @note To avoid the MISRA warning "The comma operator has been used outside a for statement" * use a semicolon instead of a comma to separate the ARGS. * Example: DLT_LOG_ID(hContext, DLT_LOG_INFO, 0x1234, DLT_STRING("Hello world"); DLT_INT(123)); @@ -234,17 +234,17 @@ /* DLT_LOG_ID is not supported by MS Visual C++ */ /* use function interface instead */ #else -#define DLT_LOG_ID(CONTEXT,LOGLEVEL,MSGID,ARGS...) \ +# define DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ARGS ...) \ do { \ DltContextData log_local; \ int dlt_local; \ - dlt_local = dlt_user_log_write_start_id(&CONTEXT,&log_local,LOGLEVEL,MSGID); \ + dlt_local = dlt_user_log_write_start_id(&CONTEXT, &log_local, LOGLEVEL, MSGID); \ if (dlt_local == DLT_RETURN_TRUE) \ { \ ARGS; \ (void)dlt_user_log_write_finish(&log_local); \ } \ - } while(0) + } while (0) #endif /** @@ -252,100 +252,100 @@ * @param TEXT ASCII string */ #define DLT_STRING(TEXT) \ - (void)dlt_user_log_write_string(&log_local,TEXT) + (void)dlt_user_log_write_string(&log_local, TEXT) /** * Add constant string parameter to the log messsage. * @param TEXT Constant ASCII string */ #define DLT_CSTRING(TEXT) \ - (void)dlt_user_log_write_constant_string(&log_local,TEXT) + (void)dlt_user_log_write_constant_string(&log_local, TEXT) /** * Add utf8-encoded string parameter to the log messsage. * @param TEXT UTF8-encoded string */ #define DLT_UTF8(TEXT) \ - (void)dlt_user_log_write_utf8_string(&log_local,TEXT) + (void)dlt_user_log_write_utf8_string(&log_local, TEXT) /** * Add boolean parameter to the log messsage. * @param BOOL_VAR Boolean value (mapped to uint8) */ #define DLT_BOOL(BOOL_VAR) \ - (void)dlt_user_log_write_bool(&log_local,BOOL_VAR) + (void)dlt_user_log_write_bool(&log_local, BOOL_VAR) /** * Add float32 parameter to the log messsage. * @param FLOAT32_VAR Float32 value (mapped to float) */ #define DLT_FLOAT32(FLOAT32_VAR) \ - (void)dlt_user_log_write_float32(&log_local,FLOAT32_VAR) + (void)dlt_user_log_write_float32(&log_local, FLOAT32_VAR) /** * Add float64 parameter to the log messsage. * @param FLOAT64_VAR Float64 value (mapped to double) */ #define DLT_FLOAT64(FLOAT64_VAR) \ - (void)dlt_user_log_write_float64(&log_local,FLOAT64_VAR) + (void)dlt_user_log_write_float64(&log_local, FLOAT64_VAR) /** * Add integer parameter to the log messsage. * @param INT_VAR integer value */ #define DLT_INT(INT_VAR) \ - (void)dlt_user_log_write_int(&log_local,INT_VAR) + (void)dlt_user_log_write_int(&log_local, INT_VAR) #define DLT_INT8(INT_VAR) \ - (void)dlt_user_log_write_int8(&log_local,INT_VAR) + (void)dlt_user_log_write_int8(&log_local, INT_VAR) #define DLT_INT16(INT_VAR) \ - (void)dlt_user_log_write_int16(&log_local,INT_VAR) + (void)dlt_user_log_write_int16(&log_local, INT_VAR) #define DLT_INT32(INT_VAR) \ - (void)dlt_user_log_write_int32(&log_local,INT_VAR) + (void)dlt_user_log_write_int32(&log_local, INT_VAR) #define DLT_INT64(INT_VAR) \ - (void)dlt_user_log_write_int64(&log_local,INT_VAR) + (void)dlt_user_log_write_int64(&log_local, INT_VAR) /** * Add unsigned integer parameter to the log messsage. * @param UINT_VAR unsigned integer value */ #define DLT_UINT(UINT_VAR) \ - (void)dlt_user_log_write_uint(&log_local,UINT_VAR) + (void)dlt_user_log_write_uint(&log_local, UINT_VAR) #define DLT_UINT8(UINT_VAR) \ - (void)dlt_user_log_write_uint8(&log_local,UINT_VAR) + (void)dlt_user_log_write_uint8(&log_local, UINT_VAR) #define DLT_UINT16(UINT_VAR) \ - (void)dlt_user_log_write_uint16(&log_local,UINT_VAR) + (void)dlt_user_log_write_uint16(&log_local, UINT_VAR) #define DLT_UINT32(UINT_VAR) \ - (void)dlt_user_log_write_uint32(&log_local,UINT_VAR) + (void)dlt_user_log_write_uint32(&log_local, UINT_VAR) #define DLT_UINT64(UINT_VAR) \ - (void)dlt_user_log_write_uint64(&log_local,UINT_VAR) + (void)dlt_user_log_write_uint64(&log_local, UINT_VAR) /** * Add binary memory block to the log messages. * @param BUF pointer to memory block * @param LEN length of memory block */ -#define DLT_RAW(BUF,LEN) \ - (void)dlt_user_log_write_raw(&log_local,BUF,LEN) +#define DLT_RAW(BUF, LEN) \ + (void)dlt_user_log_write_raw(&log_local, BUF, LEN) #define DLT_HEX8(UINT_VAR) \ - (void)dlt_user_log_write_uint8_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX8) + (void)dlt_user_log_write_uint8_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX8) #define DLT_HEX16(UINT_VAR) \ - (void)dlt_user_log_write_uint16_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX16) + (void)dlt_user_log_write_uint16_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX16) #define DLT_HEX32(UINT_VAR) \ - (void)dlt_user_log_write_uint32_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX32) + (void)dlt_user_log_write_uint32_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX32) #define DLT_HEX64(UINT_VAR) \ - (void)dlt_user_log_write_uint64_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX64) + (void)dlt_user_log_write_uint64_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX64) #define DLT_BIN8(UINT_VAR) \ - (void)dlt_user_log_write_uint8_formatted(&log_local,UINT_VAR,DLT_FORMAT_BIN8) + (void)dlt_user_log_write_uint8_formatted(&log_local, UINT_VAR, DLT_FORMAT_BIN8) #define DLT_BIN16(UINT_VAR) \ - (void)dlt_user_log_write_uint16_formatted(&log_local,UINT_VAR,DLT_FORMAT_BIN16) + (void)dlt_user_log_write_uint16_formatted(&log_local, UINT_VAR, DLT_FORMAT_BIN16) /** * Architecture independent macro to print pointers @@ -362,13 +362,13 @@ * @param PAYLOADLEN length of network message payload * @param PAYLOAD pointer to network message payload */ -#define DLT_TRACE_NETWORK(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \ +#define DLT_TRACE_NETWORK(CONTEXT, TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD) \ do { \ - if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \ + if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr) == DLT_TRACE_STATUS_ON) \ { \ - (void)dlt_user_trace_network(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \ + (void)dlt_user_trace_network(&(CONTEXT), TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD); \ } \ - }while(0) + } while (0) /** * Trace network message, allow truncation @@ -379,13 +379,13 @@ * @param PAYLOADLEN length of network message payload * @param PAYLOAD pointer to network message payload */ -#define DLT_TRACE_NETWORK_TRUNCATED(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \ +#define DLT_TRACE_NETWORK_TRUNCATED(CONTEXT, TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD) \ do { \ - if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \ + if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr) == DLT_TRACE_STATUS_ON) \ { \ - (void)dlt_user_trace_network_truncated(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD, 1); \ + (void)dlt_user_trace_network_truncated(&(CONTEXT), TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD, 1); \ } \ - }while(0) + } while (0) /** * Trace network message, segment large messages @@ -396,13 +396,13 @@ * @param PAYLOADLEN length of network message payload * @param PAYLOAD pointer to network message payload */ -#define DLT_TRACE_NETWORK_SEGMENTED(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \ +#define DLT_TRACE_NETWORK_SEGMENTED(CONTEXT, TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD) \ do { \ - if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \ + if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr) == DLT_TRACE_STATUS_ON) \ { \ - (void)dlt_user_trace_network_segmented(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \ + (void)dlt_user_trace_network_segmented(&(CONTEXT), TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD); \ } \ - }while(0) + } while (0) /** * Send log message with string parameter. @@ -410,13 +410,13 @@ * @param LOGLEVEL the log level of the log message * @param TEXT ASCII string */ -#define DLT_LOG_STRING(CONTEXT,LOGLEVEL,TEXT) \ +#define DLT_LOG_STRING(CONTEXT, LOGLEVEL, TEXT) \ do { \ - if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \ + if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \ { \ (void)dlt_log_string(&(CONTEXT), LOGLEVEL, TEXT); \ } \ - } while(0) + } while (0) /** * Send log message with string parameter and integer parameter. @@ -425,13 +425,13 @@ * @param TEXT ASCII string * @param INT_VAR integer value */ -#define DLT_LOG_STRING_INT(CONTEXT,LOGLEVEL,TEXT,INT_VAR) \ +#define DLT_LOG_STRING_INT(CONTEXT, LOGLEVEL, TEXT, INT_VAR) \ do { \ - if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \ + if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \ { \ (void)dlt_log_string_int(&(CONTEXT), LOGLEVEL, TEXT, INT_VAR); \ } \ - } while(0) + } while (0) /** * Send log message with string parameter and unsigned integer parameter. @@ -440,13 +440,13 @@ * @param TEXT ASCII string * @param UINT_VAR unsigned integer value */ -#define DLT_LOG_STRING_UINT(CONTEXT,LOGLEVEL,TEXT,UINT_VAR) \ +#define DLT_LOG_STRING_UINT(CONTEXT, LOGLEVEL, TEXT, UINT_VAR) \ do { \ - if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \ + if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \ { \ - (void)dlt_log_string_uint(&(CONTEXT),LOGLEVEL,TEXT,UINT_VAR); \ + (void)dlt_log_string_uint(&(CONTEXT), LOGLEVEL, TEXT, UINT_VAR); \ } \ - } while(0) + } while (0) /** * Send log message with unsigned integer parameter. @@ -454,13 +454,13 @@ * @param LOGLEVEL the log level of the log message * @param UINT_VAR unsigned integer value */ -#define DLT_LOG_UINT(CONTEXT,LOGLEVEL,UINT_VAR) \ +#define DLT_LOG_UINT(CONTEXT, LOGLEVEL, UINT_VAR) \ do { \ - if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \ + if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \ { \ - (void)dlt_log_uint(&(CONTEXT),LOGLEVEL,UINT_VAR); \ + (void)dlt_log_uint(&(CONTEXT), LOGLEVEL, UINT_VAR); \ } \ - } while(0) + } while (0) /** * Send log message with integer parameter. @@ -468,13 +468,13 @@ * @param LOGLEVEL the log level of the log message * @param INT_VAR integer value */ -#define DLT_LOG_INT(CONTEXT,LOGLEVEL,INT_VAR) \ +#define DLT_LOG_INT(CONTEXT, LOGLEVEL, INT_VAR) \ do { \ - if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \ + if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \ { \ - (void)dlt_log_int(&(CONTEXT),LOGLEVEL,INT_VAR); \ + (void)dlt_log_int(&(CONTEXT), LOGLEVEL, INT_VAR); \ } \ - } while(0) + } while (0) /** * Send log message with binary memory block. @@ -483,13 +483,13 @@ * @param BUF pointer to memory block * @param LEN length of memory block */ -#define DLT_LOG_RAW(CONTEXT,LOGLEVEL,BUF,LEN) \ +#define DLT_LOG_RAW(CONTEXT, LOGLEVEL, BUF, LEN) \ do { \ - if(dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL)==DLT_RETURN_TRUE) \ + if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \ { \ - (void)dlt_log_raw(&(CONTEXT),LOGLEVEL,BUF,LEN); \ + (void)dlt_log_raw(&(CONTEXT), LOGLEVEL, BUF, LEN); \ } \ - } while(0) + } while (0) /** * Send log message with marker. @@ -497,21 +497,21 @@ #define DLT_LOG_MARKER() \ do { \ (void)dlt_log_marker(); \ - } while(0) + } while (0) /** * Switch to verbose mode * */ #define DLT_VERBOSE_MODE() do { \ - (void)dlt_verbose_mode();} while(0) + (void)dlt_verbose_mode(); } while (0) /** * Switch to non-verbose mode * */ -#define DLT_NONVERBOSE_MODE() do {\ - (void)dlt_nonverbose_mode();} while(0) +#define DLT_NONVERBOSE_MODE() do { \ + (void)dlt_nonverbose_mode(); } while (0) /** * Set maximum logged log level and trace status of application @@ -519,22 +519,22 @@ * @param LOGLEVEL This is the log level to be set for the whole application * @param TRACESTATUS This is the trace status to be set for the whole application */ -#define DLT_SET_APPLICATION_LL_TS_LIMIT(LOGLEVEL, TRACESTATUS) do {\ - (void)dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS);} while(0) +#define DLT_SET_APPLICATION_LL_TS_LIMIT(LOGLEVEL, TRACESTATUS) do { \ + (void)dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS); } while (0) /** * Enable local printing of messages * */ -#define DLT_ENABLE_LOCAL_PRINT() do {\ - (void)dlt_enable_local_print();} while(0) +#define DLT_ENABLE_LOCAL_PRINT() do { \ + (void)dlt_enable_local_print(); } while (0) /** * Disable local printing of messages * */ -#define DLT_DISABLE_LOCAL_PRINT() do {\ - (void)dlt_disable_local_print();} while(0) +#define DLT_DISABLE_LOCAL_PRINT() do { \ + (void)dlt_disable_local_print(); } while (0) /** * Check if log level is enabled @@ -542,11 +542,11 @@ * @param CONTEXT object containing information about one special logging context * @param LOGLEVEL the log level of the log message */ -#define DLT_IS_LOG_LEVEL_ENABLED(CONTEXT,LOGLEVEL) \ - (dlt_user_is_logLevel_enabled(&CONTEXT,LOGLEVEL) == DLT_RETURN_TRUE) +#define DLT_IS_LOG_LEVEL_ENABLED(CONTEXT, LOGLEVEL) \ + (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) /** - \} -*/ + \} + */ #endif /* DLT_USER_MACROS_H */ -- cgit v1.2.1