d09adae131015c15727b938cbc66cde3bb477e40
[profile/ivi/dlt-daemon.git] / include / dlt / dlt_user.h
1 /**
2  * @licence app begin@
3  * Copyright (C) 2012  BMW AG
4  *
5  * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
6  *
7  * Contributions are licensed to the GENIVI Alliance under one or more
8  * Contribution License Agreements.
9  *
10  * \copyright
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/.
14  *
15  *
16  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de> BMW 2011-2012
17  *
18  * \file dlt_user.h
19  * For further information see http://www.genivi.org/.
20  * @licence end@
21  */
22
23
24 /*******************************************************************************
25 **                                                                            **
26 **  SRC-MODULE: dlt_user.h                                                    **
27 **                                                                            **
28 **  TARGET    : linux                                                         **
29 **                                                                            **
30 **  PROJECT   : DLT                                                           **
31 **                                                                            **
32 **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
33 **              Markus Klein                                                  **
34 **                                                                            **
35 **  PURPOSE   :                                                               **
36 **                                                                            **
37 **  REMARKS   :                                                               **
38 **                                                                            **
39 **  PLATFORM DEPENDANT [yes/no]: yes                                          **
40 **                                                                            **
41 **  TO BE CHANGED BY USER [yes/no]: no                                        **
42 **                                                                            **
43 *******************************************************************************/
44
45 /*******************************************************************************
46 **                      Author Identity                                       **
47 ********************************************************************************
48 **                                                                            **
49 ** Initials     Name                       Company                            **
50 ** --------     -------------------------  ---------------------------------- **
51 **  aw          Alexander Wenzel           BMW                                **
52 **  mk          Markus Klein               Fraunhofer ESK                     **
53 *******************************************************************************/
54
55 /*******************************************************************************
56 **                      Revision Control History                              **
57 *******************************************************************************/
58
59 /*
60  * $LastChangedRevision: 1670 $
61  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
62  * $LastChangedBy$
63  Initials    Date         Comment
64  aw          13.01.2010   initial
65  */
66
67 #ifndef DLT_USER_H
68 #define DLT_USER_H
69
70 /**
71   \defgroup userapi DLT User API
72   \addtogroup userapi
73   \{
74 */
75 #include "dlt_types.h"
76 #include "dlt_common.h"
77 #include "dlt_user_macros.h"
78 #include "dlt_shm.h"
79 #include <mqueue.h>
80
81 #if !defined (__WIN32__)
82 #include <semaphore.h>
83 #endif
84
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88
89 /**
90  * Definitions of DLT log level
91  */
92 typedef enum
93 {
94         DLT_LOG_DEFAULT =                 -1,   /**< Default log level */
95         DLT_LOG_OFF     =               0x00,   /**< Log level off */
96         DLT_LOG_FATAL   =               0x01,   /**< fatal system error */
97         DLT_LOG_ERROR   =               0x02,   /**< error with impact to correct functionality */
98         DLT_LOG_WARN    =               0x03,   /**< warning, correct behaviour could not be ensured */
99         DLT_LOG_INFO    =               0x04,   /**< informational */
100         DLT_LOG_DEBUG   =               0x05,   /**< debug  */
101         DLT_LOG_VERBOSE =               0x06    /**< highest grade of information */
102 } DltLogLevelType;
103
104 /**
105  * Definitions of DLT trace status
106  */
107 typedef enum
108 {
109         DLT_TRACE_STATUS_DEFAULT =   -1,        /**< Default trace status */
110         DLT_TRACE_STATUS_OFF     = 0x00,        /**< Trace status: Off */
111         DLT_TRACE_STATUS_ON      = 0x01         /**< Trace status: On */
112 } DltTraceStatusType;
113
114 /**
115  * Definitions for  dlt_user_trace_network/DLT_TRACE_NETWORK()
116  * as defined in the DLT protocol
117  */
118 typedef enum
119 {
120         DLT_NW_TRACE_IPC     = 0x01,    /**< Interprocess communication */
121         DLT_NW_TRACE_CAN     = 0x02,    /**< Controller Area Network Bus */
122         DLT_NW_TRACE_FLEXRAY = 0x03,    /**< Flexray Bus */
123         DLT_NW_TRACE_MOST    = 0x04,    /**< Media Oriented System Transport Bus */
124         DLT_NW_TRACE_RESERVED0 = 0x05,
125         DLT_NW_TRACE_RESERVED1 = 0x06,
126         DLT_NW_TRACE_RESERVED2 = 0x07,
127         DLT_NW_TRACE_USER_DEFINED0 = 0x08,
128         DLT_NW_TRACE_USER_DEFINED1 = 0x09,
129         DLT_NW_TRACE_USER_DEFINED2 = 0x0A,
130         DLT_NW_TRACE_USER_DEFINED3 = 0x0B,
131         DLT_NW_TRACE_USER_DEFINED4 = 0x0C,
132         DLT_NW_TRACE_USER_DEFINED5 = 0x0D,
133         DLT_NW_TRACE_USER_DEFINED6 = 0x0E,
134         DLT_NW_TRACE_USER_DEFINED7 = 0x0F
135 } DltNetworkTraceType;
136
137 /**
138  * This are the log modes.
139  */
140 typedef enum
141 {
142         DLT_USER_MODE_UNDEFINED   =  -1,
143         DLT_USER_MODE_OFF         =  0,
144         DLT_USER_MODE_EXTERNAL            ,
145         DLT_USER_MODE_INTERNAL            ,
146         DLT_USER_MODE_BOTH
147 } DltUserLogMode;
148
149 #define DLT_USER_BUF_MAX_SIZE 2048               /**< maximum size of each user buffer, also used for injection buffer */
150
151 #define DLT_USER_RESENDBUF_MAX_SIZE (DLT_USER_BUF_MAX_SIZE + 100)               /**< Size of resend buffer; Max DLT message size is 2K plus some extra header space  */
152
153 /* Use a semaphore or mutex from your OS to prevent concurrent access to the DLT buffer. */
154 #define DLT_SEM_LOCK() { sem_wait(&dlt_mutex); }
155 #define DLT_SEM_FREE() { sem_post(&dlt_mutex); }
156
157 /**
158  * This structure is used for every context used in an application.
159  */
160 typedef struct
161 {
162         char contextID[4];                            /**< context id */
163         int32_t log_level_pos;                        /**< offset in user-application context field */
164         int8_t *log_level_ptr;                        /**< pointer to the log level */
165         int8_t *trace_status_ptr;                     /**< pointer to the trace status */
166         uint8_t mcnt;                                 /**< message counter */
167 } DltContext;
168
169 /**
170  * This structure is used for context data used in an application.
171  */
172 typedef struct
173 {
174     DltContext *handle;                           /**< pointer to DltContext */
175         unsigned char buffer[DLT_USER_BUF_MAX_SIZE];  /**< buffer for building log message*/
176         int32_t size;                                 /**< payload size */
177         int32_t log_level;                            /**< log level */
178         int32_t trace_status;                         /**< trace status */
179         int32_t args_num;                             /**< number of arguments for extended header*/
180         char* context_description;                    /**< description of context */
181 } DltContextData;
182
183 typedef struct
184 {
185         uint32_t service_id;
186         int (*injection_callback)(uint32_t service_id, void *data, uint32_t length);
187 } DltUserInjectionCallback;
188
189 /**
190  * This structure is used in a table managing all contexts and the corresponding log levels in an application.
191  */
192 typedef struct
193 {
194     char contextID[DLT_ID_SIZE];      /**< Context ID */
195     int8_t log_level;                 /**< Log level */
196     int8_t *log_level_ptr;             /**< Ptr to the log level */
197     int8_t trace_status;              /**< Trace status */
198     int8_t *trace_status_ptr;             /**< Ptr to the trace status */
199     char *context_description;        /**< description of context */
200     DltUserInjectionCallback *injection_table; /**< Table with pointer to injection functions and service ids */
201     uint32_t nrcallbacks;
202 } dlt_ll_ts_type;
203
204 /**
205  * This structure is used once for one application.
206  */
207 typedef struct
208 {
209     char ecuID[DLT_ID_SIZE];             /**< ECU ID */
210     char appID[DLT_ID_SIZE];             /**< Application ID */
211     int dlt_log_handle;                  /**< Handle to fifo of dlt daemon */
212     int dlt_user_handle;                 /**< Handle to own fifo */
213     mqd_t dlt_segmented_queue_read_handle;    /**< Handle message queue */
214     mqd_t dlt_segmented_queue_write_handle;    /**< Handle message queue */
215     pthread_t dlt_segmented_nwt_handle;  /**< thread handle of segmented sending */
216
217     int8_t dlt_is_file;                  /**< Target of logging: 1 to file, 0 to daemon */
218
219     dlt_ll_ts_type *dlt_ll_ts; //[MAX_DLT_LL_TS_ENTRIES]; /**< Internal management struct for all contexts */
220     uint32_t dlt_ll_ts_max_num_entries;   /**< Maximum number of contexts */
221
222     uint32_t dlt_ll_ts_num_entries;       /**< Number of used contexts */
223
224     int8_t overflow;                     /**< Overflow marker, set to 1 on overflow, 0 otherwise */
225     uint32_t overflow_counter;           /**< Counts the number of lost messages */
226
227     char *application_description;        /**< description of application */
228
229     DltReceiver receiver;                 /**< Receiver for internal user-defined messages from daemon */
230
231     int8_t verbose_mode;                                  /**< Verbose mode enabled: 1 enabled, 0 disabled */
232
233     int8_t enable_local_print;            /**< Local printing of log messages: 1 enabled, 0 disabled */
234     int8_t local_print_mode;              /**< Local print mode, controlled by environment variable */
235
236     int8_t log_state;                                     /**< Log state of external connection: 1 client connected, 0 not connected, -1 unknown */
237
238     //DltRingBuffer rbuf;                 
239         DltBuffer startup_buffer; /**< Ring-buffer for buffering messages during startup and missing connection */
240     
241         // Buffer used for resending, locked by DLT semaphore
242         uint8_t resend_buffer[DLT_USER_RESENDBUF_MAX_SIZE];
243
244 #ifdef DLT_SHM_ENABLE
245     DltShm dlt_shm;
246 #endif
247 #ifdef DLT_TEST_ENABLE
248     int corrupt_user_header;
249     int corrupt_message_size;
250     int16_t corrupt_message_size_size;
251 #endif
252 } DltUser;
253
254 /**************************************************************************************************
255 * The folowing API functions define a low level function interface for DLT
256 **************************************************************************************************/
257
258 /**
259  * Initialise the generation of a DLT log message (intended for usage in non-verbose mode)
260  * This function has to be called first, when an application wants to send a new log messages.
261  * @param handle pointer to an object containing information about one special logging context
262  * @param log pointer to an object containing information about logging context data
263  * @param loglevel this is the current log level of the log message to be sent
264  * @return negative value if there was an error
265  */
266 int dlt_user_log_write_start(DltContext *handle, DltContextData *log, DltLogLevelType loglevel);
267
268 /**
269  * Initialise the generation of a DLT log message (intended for usage in verbose mode)
270  * This function has to be called first, when an application wants to send a new log messages.
271  * @param handle pointer to an object containing information about one special logging context
272  * @param log pointer to an object containing information about logging context data
273  * @param loglevel this is the current log level of the log message to be sent
274  * @param messageid message id of message
275  * @return negative value if there was an error
276  */
277 int dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid);
278
279 /**
280  * Finishing the generation of a DLT log message and sending it to the DLT daemon.
281  * This function has to be called after writing all the log attributes of a log message.
282  * @param log pointer to an object containing information about logging context data
283  * @return negative value if there was an error
284  */
285 int dlt_user_log_write_finish(DltContextData *log);
286
287 /**
288  * Write a boolean parameter into a DLT log message.
289  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
290  * Finish sending log message by calling dlt_user_log_write_finish.
291  * @param log pointer to an object containing information about logging context data
292  * @param data boolean parameter written into log message (mapped to uint8)
293  * @return negative value if there was an error
294  */
295 int dlt_user_log_write_bool(DltContextData *log, uint8_t data);
296
297 /**
298  * Write a float parameter into a DLT log message.
299  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
300  * Finish sending log message by calling dlt_user_log_write_finish.
301  * @param log pointer to an object containing information about logging context data
302  * @param data float32_t parameter written into log message.
303  * @return negative value if there was an error
304  */
305 int dlt_user_log_write_float32(DltContextData *log, float32_t data);
306
307 /**
308  * Write a double parameter into a DLT log message.
309  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
310  * Finish sending log message by calling dlt_user_log_write_finish.
311  * @param log pointer to an object containing information about logging context data
312  * @param data float64_t parameter written into log message.
313  * @return negative value if there was an error
314  */
315 int dlt_user_log_write_float64(DltContextData *log, double data);
316
317 /**
318  * Write a uint parameter into a DLT log message.
319  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
320  * Finish sending log message by calling dlt_user_log_write_finish.
321  * @param log pointer to an object containing information about logging context data
322  * @param data unsigned int parameter written into log message.
323  * @return negative value if there was an error
324  */
325 int dlt_user_log_write_uint(DltContextData *log, unsigned int data);
326 int dlt_user_log_write_uint8(DltContextData *log, uint8_t data);
327 int dlt_user_log_write_uint16(DltContextData *log, uint16_t data);
328 int dlt_user_log_write_uint32(DltContextData *log, uint32_t data);
329 int dlt_user_log_write_uint64(DltContextData *log, uint64_t data);
330 /**
331  * Write a int parameter into a DLT log message.
332  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
333  * Finish sending log message by calling dlt_user_log_write_finish.
334  * @param log pointer to an object containing information about logging context data
335  * @param data int parameter written into log message.
336  * @return negative value if there was an error
337  */
338 int dlt_user_log_write_int(DltContextData *log, int data);
339 int dlt_user_log_write_int8(DltContextData *log, int8_t data);
340 int dlt_user_log_write_int16(DltContextData *log, int16_t data);
341 int dlt_user_log_write_int32(DltContextData *log, int32_t data);
342 int dlt_user_log_write_int64(DltContextData *log, int64_t data);
343 /**
344  * Write a null terminated ASCII string into a DLT log message.
345  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
346  * Finish sending log message by calling dlt_user_log_write_finish.
347  * @param log pointer to an object containing information about logging context data
348  * @param text pointer to the parameter written into log message containing null termination.
349  * @return negative value if there was an error
350  */
351 int dlt_user_log_write_string( DltContextData *log, const char *text);
352
353  /**
354  * Write a null terminated UTF8 string into a DLT log message.
355  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
356  * Finish sending log message by calling dlt_user_log_write_finish.
357  * @param log pointer to an object containing information about logging context data
358  * @param text pointer to the parameter written into log message containing null termination.
359  * @return negative value if there was an error
360  */
361 int dlt_user_log_write_utf8_string(DltContextData *log, const char *text);
362
363 /**
364  * Write a binary memory block into a DLT log message.
365  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
366  * Finish sending log message by calling dlt_user_log_write_finish.
367  * @param log pointer to an object containing information about logging context data
368  * @param data pointer to the parameter written into log message.
369  * @param length length in bytes of the parameter written into log message.
370  * @return negative value if there was an error
371  */
372 int dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t length);
373
374 /**
375  * Trace network message
376  * @param handle pointer to an object containing information about one special logging context
377  * @param nw_trace_type type of network trace (DLT_NW_TRACE_IPC, DLT_NW_TRACE_CAN, DLT_NW_TRACE_FLEXRAY, or DLT_NW_TRACE_MOST)
378  * @param header_len length of network message header
379  * @param header pointer to network message header
380  * @param payload_len length of network message payload
381  * @param payload pointer to network message payload
382  * @return negative value if there was an error
383  */
384 int dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
385
386 /**
387  * Trace network message, truncated if necessary.
388  * @param handle pointer to an object containing information about logging context
389  * @param nw_trace_type type of network trace (DLT_NW_TRACE_IPC, DLT_NW_TRACE_CAN, DLT_NW_TRACE_FLEXRAY, or DLT_NW_TRACE_MOST)
390  * @param header_len length of network message header
391  * @param header pointer to network message header
392  * @param payload_len length of network message payload
393  * @param payload pointer to network message payload
394  * @param allow_truncate Set to > 0 to allow truncating of the message if it is too large.
395  * @return negative value if there was an error
396  */
397 int 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);
398
399 /**
400  * Trace network message in segmented asynchronous mode.
401  * The sending of the data is done in a separate thread.
402  * Please note that handle must exist for the lifetime of the application, because
403  * data chunks are sent asynchronously in undetermined future time.
404  * @param handle pointer to an object containing information about logging context
405  * @param nw_trace_type type of network trace (DLT_NW_TRACE_IPC, DLT_NW_TRACE_CAN, DLT_NW_TRACE_FLEXRAY, or DLT_NW_TRACE_MOST)
406  * @param header_len length of network message header
407  * @param header pointer to network message header
408  * @param payload_len length of network message payload
409  * @param payload pointer to network message payload
410  * @return 0 on success, -1 on failure
411  */
412 int dlt_user_trace_network_segmented(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
413
414 /**************************************************************************************************
415 * The folowing API functions define a high level function interface for DLT
416 **************************************************************************************************/
417
418 /**
419  * Initialise the user lib communication with daemon.
420  * This function has to be called first, before using any DLT user lib functions.
421  * @return negative value if there was an error
422  */
423 int dlt_init();
424
425 /**
426  * Initialise the user lib writing only to file.
427  * This function has to be called first, before using any DLT user lib functions.
428  * @param name name of an optional log file
429  * @return negative value if there was an error
430  */
431 int dlt_init_file(const char *name);
432
433 /**
434  * Terminate the user lib.
435  * This function has to be called when finishing using the DLT user lib.
436  * @return negative value if there was an error
437  */
438 int dlt_free();
439
440 /**
441  * Check the library version of DLT library.
442  * @param user_major_version the major version to be compared
443  * @param user_minor_version the minor version to be compared
444  * @return negative value if there was an error
445  */
446 int dlt_check_library_version(const char * user_major_version, const char * user_minor_version);
447
448 /**
449  * Register an application in the daemon.
450  * @param appid four byte long character array with the application id
451  * @param description long name of the application
452  * @return negative value if there was an error
453  */
454 int dlt_register_app(const char *appid, const char * description);
455
456 /**
457  * Unregister an application in the daemon.
458  * This function has to be called when finishing using an application.
459  * @return negative value if there was an error
460  */
461 int dlt_unregister_app(void);
462
463 /**
464  * Register a context in the daemon.
465  * This function has to be called before first usage of the context.
466  * @param handle pointer to an object containing information about one special logging context
467  * @param contextid four byte long character array with the context id
468  * @param description long name of the context
469  * @return negative value if there was an error
470  */
471 int dlt_register_context(DltContext *handle, const char *contextid, const char * description);
472
473 /**
474  * Register a context in the daemon with pre-defined log level and pre-defined trace status.
475  * This function has to be called before first usage of the context.
476  * @param handle pointer to an object containing information about one special logging context
477  * @param contextid four byte long character array with the context id
478  * @param description long name of the context
479  * @param loglevel This is the log level to be pre-set for this context
480           (DLT_LOG_DEFAULT is not allowed here)
481  * @param tracestatus This is the trace status to be pre-set for this context
482                   (DLT_TRACE_STATUS_DEFAULT is not allowed here)
483  * @return negative value if there was an error
484  */
485 int dlt_register_context_ll_ts(DltContext *handle, const char *contextid, const char * description, int loglevel, int tracestatus);
486
487 /**
488  * Unregister a context in the DLT daemon.
489  * This function has to be called when finishing using a context.
490  * @param handle pointer to an object containing information about one special logging context
491  * @return negative value if there was an error
492  */
493 int dlt_unregister_context(DltContext *handle);
494
495 /**
496  * Set the logging mode used by the daemon.
497  * The logging mode is stored persistantly by the daemon.
498  * @see DltUserLogMode
499  * @param mode the new logging mode used by the daemon: off, extern, internal, both. 
500  * @return negative value if there was an error
501  */
502 int dlt_set_log_mode(DltUserLogMode mode);
503
504 /**
505  * Get the state of the connected client to the daemon.
506  * The user application gets a message, when client is connected or disconnected.
507  * This value contains the last state.
508  * It needs some time until the application gets state from the daemon.
509  * Until then the state is "unknown state".
510  * @return -1 = unknown state, 0 = client not connected, 1 = client connected
511  */
512 int dlt_get_log_state();
513
514 /**
515  * Register callback function called when injection message was received
516  * @param handle pointer to an object containing information about one special logging context
517  * @param service_id the service id to be waited for
518  * @param (*dlt_injection_callback) function pointer to callback function
519  * @return negative value if there was an error
520  */
521 int dlt_register_injection_callback(DltContext *handle, uint32_t service_id,
522       int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length));
523
524 /**
525  * Switch to verbose mode
526  *
527  */
528 int dlt_verbose_mode(void);
529
530 /**
531  * Check the version of dlt library with library version used of the application.
532  * @param Major version number of application - see dlt_version.h
533  * @param Minor version number of application - see dlt_version.h
534  * @return negative value if there is a mismatch
535  */
536 int dlt_user_check_library_version(const char *user_major_version,const char *user_minor_version);
537
538 /**
539  * Switch to non-verbose mode
540  *
541  */
542 int dlt_nonverbose_mode(void);
543
544 /**
545  * Set maximum logged log level and trace status of application
546  *
547  * @param loglevel This is the log level to be set for the whole application
548  * @param tracestatus This is the trace status to be set for the whole application
549  * @return negative value if there was an error
550  */
551 int dlt_set_application_ll_ts_limit(DltLogLevelType loglevel, DltTraceStatusType tracestatus);
552
553 /**
554  * Enable local printing of messages
555  *
556  */
557 int dlt_enable_local_print(void);
558
559 /**
560  * Disable local printing of messages
561  *
562  */
563 int dlt_disable_local_print(void);
564
565 /**
566  * Write a null terminated ASCII string into a DLT log message.
567  * @param handle pointer to an object containing information about one special logging context
568  * @param loglevel this is the current log level of the log message to be sent
569  * @param text pointer to the ASCII string written into log message containing null termination.
570  * @return negative value if there was an error
571  */
572 int dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const char *text);
573
574 /**
575  * Write a null terminated ASCII string and an integer value into a DLT log message.
576  * @param handle pointer to an object containing information about one special logging context
577  * @param loglevel this is the current log level of the log message to be sent
578  * @param text pointer to the ASCII string written into log message containing null termination.
579  * @param data integer value written into the log message
580  * @return negative value if there was an error
581  */
582 int dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, const char *text, int data);
583
584 /**
585  * Write a null terminated ASCII string and an unsigned integer value into a DLT log message.
586  * @param handle pointer to an object containing information about one special logging context
587  * @param loglevel this is the current log level of the log message to be sent
588  * @param text pointer to the ASCII string written into log message containing null termination.
589  * @param data unsigned integer value written into the log message
590  * @return negative value if there was an error
591  */
592 int dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, const char *text, unsigned int data);
593
594 /**
595  * Write an integer value into a DLT log message.
596  * @param handle pointer to an object containing information about one special logging context
597  * @param loglevel this is the current log level of the log message to be sent
598  * @param data integer value written into the log message
599  * @return negative value if there was an error
600  */
601 int dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data);
602
603 /**
604  * Write an unsigned integer value into a DLT log message.
605  * @param handle pointer to an object containing information about one special logging context
606  * @param loglevel this is the current log level of the log message to be sent
607  * @param data unsigned integer value written into the log message
608  * @return negative value if there was an error
609  */
610 int dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigned int data);
611
612 /**
613  * Write an unsigned integer value into a DLT log message.
614  * @param handle pointer to an object containing information about one special logging context
615  * @param loglevel this is the current log level of the log message to be sent
616  * @param data pointer to the parameter written into log message.
617  * @param length length in bytes of the parameter written into log message.
618  * @return negative value if there was an error
619  */
620 int dlt_log_raw(DltContext *handle,DltLogLevelType loglevel, void *data,uint16_t length);
621
622
623 /**
624  * Forward a complete DLT message to the DLT daemon
625  * @param msgdata Message data of DLT message
626  * @param size Size of DLT message
627  * @return negative value if there was an error
628  */
629 int dlt_forward_msg(void *msgdata,size_t size);
630
631 /**
632  * Get the total size and available size of the shared memory buffer between daemon and applications.
633  * This information is useful to control the flow control between applications and daemon.
634  * For example only 50% of the buffer should be used for file transfer.
635  * @param total_size total size of buffer in bytes
636  * @param used_size used size of buffer in bytes
637  * @return negative value if there was an error
638  */
639 int dlt_user_check_buffer(int *total_size, int *used_size);
640
641 /**
642  * Try to resend log message in the user buffer. Stops if the dlt_uptime is bigger than
643  * dlt_uptime() + DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT. A pause between the resending
644  * attempts can be defined with DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP
645  * @return number of messages in the user buffer
646  */
647 int dlt_user_atexit_blow_out_user_buffer(void);
648
649 /**
650  * Try to resend log message in the user buffer.
651  * @return 0 on success, negative on failure.
652  */
653 int dlt_user_log_resend_buffer(void);
654
655 #ifdef DLT_TEST_ENABLE
656 void dlt_user_test_corrupt_user_header(int enable);
657 void dlt_user_test_corrupt_message_size(int enable,int16_t size);
658 #endif /* DLT_TEST_ENABLE */
659
660 #ifdef __cplusplus
661 }
662 #endif
663
664 /**
665   \}
666 */
667
668 #endif /* DLT_USER_H */