3 * Copyright (C) 2012 BMW AG
5 * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
7 * Contributions are licensed to the GENIVI Alliance under one or more
8 * Contribution License Agreements.
11 * This Source Code Form is subject to the terms of the
12 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
13 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
16 * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de> BMW 2011-2012
18 * \file dlt_user_macros.h
19 * For further information see http://www.genivi.org/.
23 /*******************************************************************************
25 ** SRC-MODULE: dlt_user_macros.h **
31 ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
38 ** PLATFORM DEPENDANT [yes/no]: yes **
40 ** TO BE CHANGED BY USER [yes/no]: no **
42 *******************************************************************************/
44 /*******************************************************************************
46 ********************************************************************************
48 ** Initials Name Company **
49 ** -------- ------------------------- ---------------------------------- **
50 ** aw Alexander Wenzel BMW **
51 ** mk Markus Klein Fraunhofer ESK **
52 *******************************************************************************/
54 /*******************************************************************************
55 ** Revision Control History **
56 *******************************************************************************/
59 * $LastChangedRevision: 1515 $
60 * $LastChangedDate: 2010-12-13 09:18:54 +0100 (Mon, 13 Dec 2010) $
66 #ifndef DLT_USER_MACROS_H
67 #define DLT_USER_MACORS_H
69 #include "dlt_version.h"
72 \defgroup userapi DLT User API
77 /**************************************************************************************************
78 * The folowing macros define a macro interface for DLT
79 **************************************************************************************************/
82 * Create an object for a new context.
83 * This macro has to be called first for every.
84 * @param CONTEXT object containing information about one special logging context
86 #define DLT_DECLARE_CONTEXT(CONTEXT) \
90 * Use an object of a new context created in another module.
91 * This macro has to be called first for every.
92 * @param CONTEXT object containing information about one special logging context
94 #define DLT_IMPORT_CONTEXT(CONTEXT) \
95 extern DltContext CONTEXT;
98 * Register application.
99 * @param APPID application id with maximal four characters
100 * @param DESCRIPTION ASCII string containing description
102 #define DLT_REGISTER_APP(APPID,DESCRIPTION) \
103 dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION ); \
104 dlt_register_app( APPID, DESCRIPTION);
108 * Unregister application.
110 #define DLT_UNREGISTER_APP() \
111 dlt_unregister_app();
114 * Register context (with default log level and default trace status)
115 * @param CONTEXT object containing information about one special logging context
116 * @param CONTEXTID context id with maximal four characters
117 * @param DESCRIPTION ASCII string containing description
119 #define DLT_REGISTER_CONTEXT(CONTEXT,CONTEXTID,DESCRIPTION) \
120 dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION);
123 * Register context with pre-defined log level and pre-defined trace status.
124 * @param CONTEXT object containing information about one special logging context
125 * @param CONTEXTID context id with maximal four characters
126 * @param DESCRIPTION ASCII string containing description
127 * @param LOGLEVEL log level to be pre-set for this context
128 (DLT_LOG_DEFAULT is not allowed here)
129 * @param TRACESTATUS trace status to be pre-set for this context
130 (DLT_TRACE_STATUS_DEFAULT is not allowed here)
132 #define DLT_REGISTER_CONTEXT_LL_TS(CONTEXT,CONTEXTID,DESCRIPTION,LOGLEVEL,TRACESTATUS) \
133 dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS);
136 * Unregister context.
137 * @param CONTEXT object containing information about one special logging context
139 #define DLT_UNREGISTER_CONTEXT(CONTEXT) \
140 dlt_unregister_context(&(CONTEXT));
143 * Register callback function called when injection message was received
144 * @param CONTEXT object containing information about one special logging context
145 * @param SERVICEID service id of the injection message
146 * @param CALLBACK function pointer to callback function
148 #define DLT_REGISTER_INJECTION_CALLBACK(CONTEXT, SERVICEID, CALLBACK) \
149 dlt_register_injection_callback(&(CONTEXT),SERVICEID, CALLBACK);
152 * Send log message with variable list of messages (intended for verbose mode)
153 * @param CONTEXT object containing information about one special logging context
154 * @param LOGLEVEL the log level of the log message
155 * @param ARGS variable list of arguments
158 /* DLT_LOG is not supported by MS Visual C++ */
159 /* use function interface instead */
161 #define DLT_LOG(CONTEXT,LOGLEVEL,ARGS...) \
163 DltContextData log; \
164 if (dlt_user_log_write_start(&CONTEXT,&log,LOGLEVEL)) \
167 dlt_user_log_write_finish(&log); \
173 * Send log message with variable list of messages (intended for non-verbose mode)
174 * @param CONTEXT object containing information about one special logging context
175 * @param LOGLEVEL the log level of the log message
176 * @param MSGID the message id of log message
177 * @param ARGS variable list of arguments:
178 calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
179 DLT_INT(), DLT_UINT(), DLT_RAW()
182 /* DLT_LOG_ID is not supported by MS Visual C++ */
183 /* use function interface instead */
185 #define DLT_LOG_ID(CONTEXT,LOGLEVEL,MSGID,ARGS...) \
187 DltContextData log; \
188 if (dlt_user_log_write_start_id(&CONTEXT,&log,LOGLEVEL,MSGID)) \
191 dlt_user_log_write_finish(&log); \
197 * Add string parameter to the log messsage.
198 * @param TEXT ASCII string
200 #define DLT_STRING(TEXT) ({ \
201 dlt_user_log_write_string(&log,TEXT); \
205 * Add boolean parameter to the log messsage.
206 * @param BOOL_VAR Boolean value (mapped to uint8)
208 #define DLT_BOOL(BOOL_VAR) ({ \
209 dlt_user_log_write_bool(&log,BOOL_VAR); \
213 * Add float32 parameter to the log messsage.
214 * @param FLOAT32_VAR Float32 value (mapped to float)
216 #define DLT_FLOAT32(FLOAT32_VAR) ({ \
217 dlt_user_log_write_float32(&log,FLOAT32_VAR); \
221 * Add float64 parameter to the log messsage.
222 * @param FLOAT64_VAR Float64 value (mapped to double)
224 #define DLT_FLOAT64(FLOAT64_VAR) ({ \
225 dlt_user_log_write_float64(&log,FLOAT64_VAR); \
229 * Add integer parameter to the log messsage.
230 * @param INT_VAR integer value
232 #define DLT_INT(INT_VAR) ({ \
233 dlt_user_log_write_int(&log,INT_VAR); \
235 #define DLT_INT8(INT_VAR) ({ \
236 dlt_user_log_write_int8(&log,INT_VAR); \
238 #define DLT_INT16(INT_VAR) ({ \
239 dlt_user_log_write_int16(&log,INT_VAR); \
241 #define DLT_INT32(INT_VAR) ({ \
242 dlt_user_log_write_int32(&log,INT_VAR); \
244 #define DLT_INT64(INT_VAR) ({ \
245 dlt_user_log_write_int64(&log,INT_VAR); \
249 * Add unsigned integer parameter to the log messsage.
250 * @param UINT_VAR unsigned integer value
252 #define DLT_UINT(UINT_VAR) ({ \
253 dlt_user_log_write_uint(&log,UINT_VAR); \
255 #define DLT_UINT8(UINT_VAR) ({ \
256 dlt_user_log_write_uint8(&log,UINT_VAR); \
258 #define DLT_UINT16(UINT_VAR) ({ \
259 dlt_user_log_write_uint16(&log,UINT_VAR); \
261 #define DLT_UINT32(UINT_VAR) ({ \
262 dlt_user_log_write_uint32(&log,UINT_VAR); \
264 #define DLT_UINT64(UINT_VAR) ({ \
265 dlt_user_log_write_uint64(&log,UINT_VAR); \
269 * Add binary memory block to the log messages.
270 * @param BUF pointer to memory block
271 * @param LEN length of memory block
273 #define DLT_RAW(BUF,LEN) ({ \
274 dlt_user_log_write_raw(&log,BUF,LEN); \
278 * Trace network message
279 * @param CONTEXT object containing information about one special logging context
280 * @param TYPE type of network trace message
281 * @param HEADERLEN length of network message header
282 * @param HEADER pointer to network message header
283 * @param PAYLOADLEN length of network message payload
284 * @param PAYLOAD pointer to network message payload
286 #define DLT_TRACE_NETWORK(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \
288 dlt_user_trace_network(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
292 * Send log message with string parameter.
293 * @param CONTEXT object containing information about one special logging context
294 * @param LOGLEVEL the log level of the log message
295 * @param TEXT ASCII string
297 #define DLT_LOG_STRING(CONTEXT,LOGLEVEL,TEXT) \
299 dlt_log_string(&(CONTEXT), LOGLEVEL, TEXT); \
303 * Send log message with string parameter and integer parameter.
304 * @param CONTEXT object containing information about one special logging context
305 * @param LOGLEVEL the log level of the log messages
306 * @param TEXT ASCII string
307 * @param INT_VAR integer value
309 #define DLT_LOG_STRING_INT(CONTEXT,LOGLEVEL,TEXT,INT_VAR) \
311 dlt_log_string_int(&(CONTEXT), LOGLEVEL, TEXT, INT_VAR); \
315 * Send log message with string parameter and unsigned integer parameter.
316 * @param CONTEXT object containing information about one special logging context
317 * @param LOGLEVEL the log level of the log message
318 * @param TEXT ASCII string
319 * @param UINT_VAR unsigned integer value
321 #define DLT_LOG_STRING_UINT(CONTEXT,LOGLEVEL,TEXT,UINT_VAR) \
323 dlt_log_string_uint(&(CONTEXT),LOGLEVEL,TEXT,UINT_VAR); \
327 * Send log message with unsigned integer parameter.
328 * @param CONTEXT object containing information about one special logging context
329 * @param LOGLEVEL the log level of the log message
330 * @param UINT_VAR unsigned integer value
332 #define DLT_LOG_UINT(CONTEXT,LOGLEVEL,UINT_VAR) \
334 dlt_log_uint(&(CONTEXT),LOGLEVEL,UINT_VAR); \
338 * Send log message with integer parameter.
339 * @param CONTEXT object containing information about one special logging context
340 * @param LOGLEVEL the log level of the log message
341 * @param INT_VAR integer value
343 #define DLT_LOG_INT(CONTEXT,LOGLEVEL,INT_VAR) \
345 dlt_log_int(&(CONTEXT),LOGLEVEL,INT_VAR); \
349 * Send log message with binary memory block.
350 * @param CONTEXT object containing information about one special logging context
351 * @param LOGLEVEL the log level of the log message
352 * @param BUF pointer to memory block
353 * @param LEN length of memory block
355 #define DLT_LOG_RAW(CONTEXT,LOGLEVEL,BUF,LEN) \
357 dlt_log_raw(&(CONTEXT),LOGLEVEL,BUF,LEN); \
361 * Switch to verbose mode
364 #define DLT_VERBOSE_MODE() \
368 * Switch to non-verbose mode
371 #define DLT_NONVERBOSE_MODE() \
372 dlt_nonverbose_mode();
375 * Set maximum logged log level and trace status of application
377 * @param LOGLEVEL This is the log level to be set for the whole application
378 * @param TRACESTATUS This is the trace status to be set for the whole application
380 #define DLT_SET_APPLICATION_LL_TS_LIMIT(LOGLEVEL, TRACESTATUS) \
381 dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS);
384 * Enable local printing of messages
387 #define DLT_ENABLE_LOCAL_PRINT() \
388 dlt_enable_local_print();
391 * Disable local printing of messages
394 #define DLT_DISABLE_LOCAL_PRINT() \
395 dlt_disable_local_print();
401 #endif /* DLT_USER_MACROS_H */