Bug 44 - Don't print "Buffer full" message from DLT daemon for each trace.
[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         uint8_t mcnt;                                 /**< message counter */
165 } DltContext;
166
167 /**
168  * This structure is used for context data used in an application.
169  */
170 typedef struct
171 {
172     DltContext *handle;                           /**< pointer to DltContext */
173         unsigned char buffer[DLT_USER_BUF_MAX_SIZE];  /**< buffer for building log message*/
174         int32_t size;                                 /**< payload size */
175         int32_t log_level;                            /**< log level */
176         int32_t trace_status;                         /**< trace status */
177         int32_t args_num;                             /**< number of arguments for extended header*/
178         char* context_description;                    /**< description of context */
179 } DltContextData;
180
181 typedef struct
182 {
183         uint32_t service_id;
184         int (*injection_callback)(uint32_t service_id, void *data, uint32_t length);
185 } DltUserInjectionCallback;
186
187 /**
188  * This structure is used in a table managing all contexts and the corresponding log levels in an application.
189  */
190 typedef struct
191 {
192     char contextID[DLT_ID_SIZE];      /**< Context ID */
193     int8_t log_level;                 /**< Log level */
194     int8_t trace_status;              /**< Trace status */
195     char *context_description;        /**< description of context */
196     DltUserInjectionCallback *injection_table; /**< Table with pointer to injection functions and service ids */
197     uint32_t nrcallbacks;
198 } dlt_ll_ts_type;
199
200 /**
201  * This structure is used once for one application.
202  */
203 typedef struct
204 {
205     char ecuID[DLT_ID_SIZE];             /**< ECU ID */
206     char appID[DLT_ID_SIZE];             /**< Application ID */
207     int dlt_log_handle;                  /**< Handle to fifo of dlt daemon */
208     int dlt_user_handle;                 /**< Handle to own fifo */
209     mqd_t dlt_segmented_queue_read_handle;    /**< Handle message queue */
210     mqd_t dlt_segmented_queue_write_handle;    /**< Handle message queue */
211     pthread_t dlt_segmented_nwt_handle;  /**< thread handle of segmented sending */
212
213     int8_t dlt_is_file;                  /**< Target of logging: 1 to file, 0 to daemon */
214
215     dlt_ll_ts_type *dlt_ll_ts; //[MAX_DLT_LL_TS_ENTRIES]; /**< Internal management struct for all contexts */
216     uint32_t dlt_ll_ts_max_num_entries;   /**< Maximum number of contexts */
217
218     uint32_t dlt_ll_ts_num_entries;       /**< Number of used contexts */
219
220     int8_t overflow;                     /**< Overflow marker, set to 1 on overflow, 0 otherwise */
221     uint32_t overflow_counter;           /**< Counts the number of lost messages */
222
223     char *application_description;        /**< description of application */
224
225     DltReceiver receiver;                 /**< Receiver for internal user-defined messages from daemon */
226
227     int8_t verbose_mode;                                  /**< Verbose mode enabled: 1 enabled, 0 disabled */
228
229     int8_t enable_local_print;            /**< Local printing of log messages: 1 enabled, 0 disabled */
230     int8_t local_print_mode;              /**< Local print mode, controlled by environment variable */
231
232     int8_t log_state;                                     /**< Log state of external connection: 1 client connected, 0 not connected, -1 unknown */
233
234     //DltRingBuffer rbuf;                 
235         DltBuffer startup_buffer; /**< Ring-buffer for buffering messages during startup and missing connection */
236     
237         // Buffer used for resending, locked by DLT semaphore
238         uint8_t resend_buffer[DLT_USER_RESENDBUF_MAX_SIZE];
239
240 #ifdef DLT_SHM_ENABLE
241     DltShm dlt_shm;
242 #endif
243 #ifdef DLT_TEST_ENABLE
244     int corrupt_user_header;
245     int corrupt_message_size;
246     int16_t corrupt_message_size_size;
247 #endif
248 } DltUser;
249
250 /**************************************************************************************************
251 * The folowing API functions define a low level function interface for DLT
252 **************************************************************************************************/
253
254 /**
255  * Initialise the generation of a DLT log message (intended for usage in non-verbose mode)
256  * This function has to be called first, when an application wants to send a new log messages.
257  * @param handle pointer to an object containing information about one special logging context
258  * @param log pointer to an object containing information about logging context data
259  * @param loglevel this is the current log level of the log message to be sent
260  * @return negative value if there was an error
261  */
262 int dlt_user_log_write_start(DltContext *handle, DltContextData *log, DltLogLevelType loglevel);
263
264 /**
265  * Initialise the generation of a DLT log message (intended for usage in verbose mode)
266  * This function has to be called first, when an application wants to send a new log messages.
267  * @param handle pointer to an object containing information about one special logging context
268  * @param log pointer to an object containing information about logging context data
269  * @param loglevel this is the current log level of the log message to be sent
270  * @param messageid message id of message
271  * @return negative value if there was an error
272  */
273 int dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid);
274
275 /**
276  * Finishing the generation of a DLT log message and sending it to the DLT daemon.
277  * This function has to be called after writing all the log attributes of a log message.
278  * @param log pointer to an object containing information about logging context data
279  * @return negative value if there was an error
280  */
281 int dlt_user_log_write_finish(DltContextData *log);
282
283 /**
284  * Write a boolean parameter into a DLT log message.
285  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
286  * Finish sending log message by calling dlt_user_log_write_finish.
287  * @param log pointer to an object containing information about logging context data
288  * @param data boolean parameter written into log message (mapped to uint8)
289  * @return negative value if there was an error
290  */
291 int dlt_user_log_write_bool(DltContextData *log, uint8_t data);
292
293 /**
294  * Write a float parameter into a DLT log message.
295  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
296  * Finish sending log message by calling dlt_user_log_write_finish.
297  * @param log pointer to an object containing information about logging context data
298  * @param data float32_t parameter written into log message.
299  * @return negative value if there was an error
300  */
301 int dlt_user_log_write_float32(DltContextData *log, float32_t data);
302
303 /**
304  * Write a double parameter into a DLT log message.
305  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
306  * Finish sending log message by calling dlt_user_log_write_finish.
307  * @param log pointer to an object containing information about logging context data
308  * @param data float64_t parameter written into log message.
309  * @return negative value if there was an error
310  */
311 int dlt_user_log_write_float64(DltContextData *log, double data);
312
313 /**
314  * Write a uint parameter into a DLT log message.
315  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
316  * Finish sending log message by calling dlt_user_log_write_finish.
317  * @param log pointer to an object containing information about logging context data
318  * @param data unsigned int parameter written into log message.
319  * @return negative value if there was an error
320  */
321 int dlt_user_log_write_uint(DltContextData *log, unsigned int data);
322 int dlt_user_log_write_uint8(DltContextData *log, uint8_t data);
323 int dlt_user_log_write_uint16(DltContextData *log, uint16_t data);
324 int dlt_user_log_write_uint32(DltContextData *log, uint32_t data);
325 int dlt_user_log_write_uint64(DltContextData *log, uint64_t data);
326 /**
327  * Write a int parameter into a DLT log message.
328  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
329  * Finish sending log message by calling dlt_user_log_write_finish.
330  * @param log pointer to an object containing information about logging context data
331  * @param data int parameter written into log message.
332  * @return negative value if there was an error
333  */
334 int dlt_user_log_write_int(DltContextData *log, int data);
335 int dlt_user_log_write_int8(DltContextData *log, int8_t data);
336 int dlt_user_log_write_int16(DltContextData *log, int16_t data);
337 int dlt_user_log_write_int32(DltContextData *log, int32_t data);
338 int dlt_user_log_write_int64(DltContextData *log, int64_t data);
339 /**
340  * Write a null terminated ASCII string into a DLT log message.
341  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
342  * Finish sending log message by calling dlt_user_log_write_finish.
343  * @param log pointer to an object containing information about logging context data
344  * @param text pointer to the parameter written into log message containing null termination.
345  * @return negative value if there was an error
346  */
347 int dlt_user_log_write_string( DltContextData *log, const char *text);
348
349  /**
350  * Write a null terminated UTF8 string into a DLT log message.
351  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
352  * Finish sending log message by calling dlt_user_log_write_finish.
353  * @param log pointer to an object containing information about logging context data
354  * @param text pointer to the parameter written into log message containing null termination.
355  * @return negative value if there was an error
356  */
357 int dlt_user_log_write_utf8_string(DltContextData *log, const char *text);
358
359 /**
360  * Write a binary memory block into a DLT log message.
361  * dlt_user_log_write_start has to be called before adding any attributes to the log message.
362  * Finish sending log message by calling dlt_user_log_write_finish.
363  * @param log pointer to an object containing information about logging context data
364  * @param data pointer to the parameter written into log message.
365  * @param length length in bytes of the parameter written into log message.
366  * @return negative value if there was an error
367  */
368 int dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t length);
369
370 /**
371  * Trace network message
372  * @param handle pointer to an object containing information about one special logging context
373  * @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)
374  * @param header_len length of network message header
375  * @param header pointer to network message header
376  * @param payload_len length of network message payload
377  * @param payload pointer to network message payload
378  * @return negative value if there was an error
379  */
380 int dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
381
382 /**
383  * Trace network message, truncated if necessary.
384  * @param handle pointer to an object containing information about logging context
385  * @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)
386  * @param header_len length of network message header
387  * @param header pointer to network message header
388  * @param payload_len length of network message payload
389  * @param payload pointer to network message payload
390  * @param allow_truncate Set to > 0 to allow truncating of the message if it is too large.
391  * @return negative value if there was an error
392  */
393 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);
394
395 /**
396  * Trace network message in segmented asynchronous mode.
397  * The sending of the data is done in a separate thread.
398  * Please note that handle must exist for the lifetime of the application, because
399  * data chunks are sent asynchronously in undetermined future time.
400  * @param handle pointer to an object containing information about logging context
401  * @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)
402  * @param header_len length of network message header
403  * @param header pointer to network message header
404  * @param payload_len length of network message payload
405  * @param payload pointer to network message payload
406  * @return 0 on success, -1 on failure
407  */
408 int dlt_user_trace_network_segmented(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
409
410 /**************************************************************************************************
411 * The folowing API functions define a high level function interface for DLT
412 **************************************************************************************************/
413
414 /**
415  * Initialise the user lib communication with daemon.
416  * This function has to be called first, before using any DLT user lib functions.
417  * @return negative value if there was an error
418  */
419 int dlt_init();
420
421 /**
422  * Initialise the user lib writing only to file.
423  * This function has to be called first, before using any DLT user lib functions.
424  * @param name name of an optional log file
425  * @return negative value if there was an error
426  */
427 int dlt_init_file(const char *name);
428
429 /**
430  * Terminate the user lib.
431  * This function has to be called when finishing using the DLT user lib.
432  * @return negative value if there was an error
433  */
434 int dlt_free();
435
436 /**
437  * Check the library version of DLT library.
438  * @param user_major_version the major version to be compared
439  * @param user_minor_version the minor version to be compared
440  * @return negative value if there was an error
441  */
442 int dlt_check_library_version(const char * user_major_version, const char * user_minor_version);
443
444 /**
445  * Register an application in the daemon.
446  * @param appid four byte long character array with the application id
447  * @param description long name of the application
448  * @return negative value if there was an error
449  */
450 int dlt_register_app(const char *appid, const char * description);
451
452 /**
453  * Unregister an application in the daemon.
454  * This function has to be called when finishing using an application.
455  * @return negative value if there was an error
456  */
457 int dlt_unregister_app(void);
458
459 /**
460  * Register a context in the daemon.
461  * This function has to be called before first usage of the context.
462  * @param handle pointer to an object containing information about one special logging context
463  * @param contextid four byte long character array with the context id
464  * @param description long name of the context
465  * @return negative value if there was an error
466  */
467 int dlt_register_context(DltContext *handle, const char *contextid, const char * description);
468
469 /**
470  * Register a context in the daemon with pre-defined log level and pre-defined trace status.
471  * This function has to be called before first usage of the context.
472  * @param handle pointer to an object containing information about one special logging context
473  * @param contextid four byte long character array with the context id
474  * @param description long name of the context
475  * @param loglevel This is the log level to be pre-set for this context
476           (DLT_LOG_DEFAULT is not allowed here)
477  * @param tracestatus This is the trace status to be pre-set for this context
478                   (DLT_TRACE_STATUS_DEFAULT is not allowed here)
479  * @return negative value if there was an error
480  */
481 int dlt_register_context_ll_ts(DltContext *handle, const char *contextid, const char * description, int loglevel, int tracestatus);
482
483 /**
484  * Unregister a context in the DLT daemon.
485  * This function has to be called when finishing using a context.
486  * @param handle pointer to an object containing information about one special logging context
487  * @return negative value if there was an error
488  */
489 int dlt_unregister_context(DltContext *handle);
490
491 /**
492  * Set the logging mode used by the daemon.
493  * The logging mode is stored persistantly by the daemon.
494  * @see DltUserLogMode
495  * @param mode the new logging mode used by the daemon: off, extern, internal, both. 
496  * @return negative value if there was an error
497  */
498 int dlt_set_log_mode(DltUserLogMode mode);
499
500 /**
501  * Get the state of the connected client to the daemon.
502  * The user application gets a message, when client is connected or disconnected.
503  * This value contains the last state.
504  * It needs some time until the application gets state from the daemon.
505  * Until then the state is "unknown state".
506  * @return -1 = unknown state, 0 = client not connected, 1 = client connected
507  */
508 int dlt_get_log_state();
509
510 /**
511  * Register callback function called when injection message was received
512  * @param handle pointer to an object containing information about one special logging context
513  * @param service_id the service id to be waited for
514  * @param (*dlt_injection_callback) function pointer to callback function
515  * @return negative value if there was an error
516  */
517 int dlt_register_injection_callback(DltContext *handle, uint32_t service_id,
518       int (*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length));
519
520 /**
521  * Switch to verbose mode
522  *
523  */
524 int dlt_verbose_mode(void);
525
526 /**
527  * Check the version of dlt library with library version used of the application.
528  * @param Major version number of application - see dlt_version.h
529  * @param Minor version number of application - see dlt_version.h
530  * @return negative value if there is a mismatch
531  */
532 int dlt_user_check_library_version(const char *user_major_version,const char *user_minor_version);
533
534 /**
535  * Switch to non-verbose mode
536  *
537  */
538 int dlt_nonverbose_mode(void);
539
540 /**
541  * Set maximum logged log level and trace status of application
542  *
543  * @param loglevel This is the log level to be set for the whole application
544  * @param tracestatus This is the trace status to be set for the whole application
545  * @return negative value if there was an error
546  */
547 int dlt_set_application_ll_ts_limit(DltLogLevelType loglevel, DltTraceStatusType tracestatus);
548
549 /**
550  * Enable local printing of messages
551  *
552  */
553 int dlt_enable_local_print(void);
554
555 /**
556  * Disable local printing of messages
557  *
558  */
559 int dlt_disable_local_print(void);
560
561 /**
562  * Write a null terminated ASCII string into a DLT log message.
563  * @param handle pointer to an object containing information about one special logging context
564  * @param loglevel this is the current log level of the log message to be sent
565  * @param text pointer to the ASCII string written into log message containing null termination.
566  * @return negative value if there was an error
567  */
568 int dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const char *text);
569
570 /**
571  * Write a null terminated ASCII string and an integer value into a DLT log message.
572  * @param handle pointer to an object containing information about one special logging context
573  * @param loglevel this is the current log level of the log message to be sent
574  * @param text pointer to the ASCII string written into log message containing null termination.
575  * @param data integer value written into the log message
576  * @return negative value if there was an error
577  */
578 int dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, const char *text, int data);
579
580 /**
581  * Write a null terminated ASCII string and an unsigned integer value into a DLT log message.
582  * @param handle pointer to an object containing information about one special logging context
583  * @param loglevel this is the current log level of the log message to be sent
584  * @param text pointer to the ASCII string written into log message containing null termination.
585  * @param data unsigned integer value written into the log message
586  * @return negative value if there was an error
587  */
588 int dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, const char *text, unsigned int data);
589
590 /**
591  * Write an integer value into a DLT log message.
592  * @param handle pointer to an object containing information about one special logging context
593  * @param loglevel this is the current log level of the log message to be sent
594  * @param data integer value written into the log message
595  * @return negative value if there was an error
596  */
597 int dlt_log_int(DltContext *handle,DltLogLevelType loglevel, int data);
598
599 /**
600  * Write an unsigned integer value into a DLT log message.
601  * @param handle pointer to an object containing information about one special logging context
602  * @param loglevel this is the current log level of the log message to be sent
603  * @param data unsigned integer value written into the log message
604  * @return negative value if there was an error
605  */
606 int dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigned int data);
607
608 /**
609  * Write an unsigned integer value into a DLT log message.
610  * @param handle pointer to an object containing information about one special logging context
611  * @param loglevel this is the current log level of the log message to be sent
612  * @param data pointer to the parameter written into log message.
613  * @param length length in bytes of the parameter written into log message.
614  * @return negative value if there was an error
615  */
616 int dlt_log_raw(DltContext *handle,DltLogLevelType loglevel, void *data,uint16_t length);
617
618
619 /**
620  * Forward a complete DLT message to the DLT daemon
621  * @param msgdata Message data of DLT message
622  * @param size Size of DLT message
623  * @return negative value if there was an error
624  */
625 int dlt_forward_msg(void *msgdata,size_t size);
626
627 /**
628  * Get the total size and available size of the shared memory buffer between daemon and applications.
629  * This information is useful to control the flow control between applications and daemon.
630  * For example only 50% of the buffer should be used for file transfer.
631  * @param total_size total size of buffer in bytes
632  * @param used_size used size of buffer in bytes
633  * @return negative value if there was an error
634  */
635 int dlt_user_check_buffer(int *total_size, int *used_size);
636
637 /**
638  * Try to resend log message in the user buffer. Stops if the dlt_uptime is bigger than
639  * dlt_uptime() + DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT. A pause between the resending
640  * attempts can be defined with DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP
641  * @return number of messages in the user buffer
642  */
643 int dlt_user_atexit_blow_out_user_buffer(void);
644
645 /**
646  * Try to resend log message in the user buffer.
647  * @return 0 on success, negative on failure.
648  */
649 int dlt_user_log_resend_buffer(void);
650
651 #ifdef DLT_TEST_ENABLE
652 void dlt_user_test_corrupt_user_header(int enable);
653 void dlt_user_test_corrupt_message_size(int enable,int16_t size);
654 #endif /* DLT_TEST_ENABLE */
655
656 #ifdef __cplusplus
657 }
658 #endif
659
660 /**
661   \}
662 */
663
664 #endif /* DLT_USER_H */