automotive-dlt
dlt_common.h
Go to the documentation of this file.
1 /*
2  * @licence app begin@
3  * SPDX license identifier: MPL-2.0
4  *
5  * Copyright (C) 2011-2015, BMW AG
6  *
7  * This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
8  *
9  * This Source Code Form is subject to the terms of the
10  * Mozilla Public License (MPL), v. 2.0.
11  * If a copy of the MPL was not distributed with this file,
12  * You can obtain one at http://mozilla.org/MPL/2.0/.
13  *
14  * For further information see http://www.genivi.org/.
15  * @licence end@
16  */
17 
27 /*******************************************************************************
28 ** **
29 ** SRC-MODULE: dlt_common.h **
30 ** **
31 ** TARGET : linux **
32 ** **
33 ** PROJECT : DLT **
34 ** **
35 ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
36 ** Markus Klein **
37 ** **
38 ** PURPOSE : **
39 ** **
40 ** REMARKS : **
41 ** **
42 ** PLATFORM DEPENDANT [yes/no]: yes **
43 ** **
44 ** TO BE CHANGED BY USER [yes/no]: no **
45 ** **
46 *******************************************************************************/
47 
48 /*******************************************************************************
49 ** Author Identity **
50 ********************************************************************************
51 ** **
52 ** Initials Name Company **
53 ** -------- ------------------------- ---------------------------------- **
54 ** aw Alexander Wenzel BMW **
55 ** mk Markus Klein Fraunhofer ESK **
56 *******************************************************************************/
57 
58 /*******************************************************************************
59 ** Revision Control History **
60 *******************************************************************************/
61 
62 /*
63  * $LastChangedRevision: 1670 $
64  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
65  * $LastChangedBy$
66  Initials Date Comment
67  aw 13.01.2010 initial
68  */
69 #ifndef DLT_COMMON_H
70 #define DLT_COMMON_H
71 
78 #include <stdio.h>
79 #include <linux/limits.h>
80 
81 #if !defined(_MSC_VER)
82 #include <unistd.h>
83 #include <time.h>
84 #endif
85 
86 #if !defined (__WIN32__) && !defined(_MSC_VER)
87 #include <termios.h>
88 #endif
89 
90 #include "dlt_types.h"
91 #include "dlt_protocol.h"
92 
93 #if !defined (PACKED)
94 #define PACKED __attribute__((aligned(1),packed))
95 #endif
96 
97 #if defined (__MSDOS__) || defined (_MSC_VER)
98 /* set instead /Zp8 flag in Visual C++ configuration */
99 #undef PACKED
100 #define PACKED
101 #endif
102 
103 /*
104  * Macros to swap the byte order.
105  */
106 #define DLT_SWAP_64(value) ((((uint64_t)DLT_SWAP_32((value)&0xffffffffull))<<32) | (DLT_SWAP_32((value)>>32)))
107 
108 #define DLT_SWAP_16(value) ((((value) >> 8)&0xff) | (((value) << 8)&0xff00))
109 #define DLT_SWAP_32(value) ((((value) >> 24)&0xff) | (((value) << 8)&0xff0000) | (((value) >> 8)&0xff00) | (((value) << 24)&0xff000000))
110 
111 /* Set Big Endian and Little Endian to a initial value, if not defined */
112 #if !defined __USE_BSD
113 #ifndef LITTLE_ENDIAN
114 #define LITTLE_ENDIAN 1234
115 #endif
116 
117 #ifndef BIG_ENDIAN
118 #define BIG_ENDIAN 4321
119 #endif
120 #endif /* __USE_BSD */
121 
122 /* If byte order is not defined, default to little endian */
123 #if !defined __USE_BSD
124 #ifndef BYTE_ORDER
125 #define BYTE_ORDER LITTLE_ENDIAN
126 #endif
127 #endif /* __USE_BSD */
128 
129 /* Check for byte-order */
130 #if (BYTE_ORDER==BIG_ENDIAN)
131 /* #warning "Big Endian Architecture!" */
132 #define DLT_HTOBE_16(x) ((x))
133 #define DLT_HTOLE_16(x) DLT_SWAP_16((x))
134 #define DLT_BETOH_16(x) ((x))
135 #define DLT_LETOH_16(x) DLT_SWAP_16((x))
136 
137 #define DLT_HTOBE_32(x) ((x))
138 #define DLT_HTOLE_32(x) DLT_SWAP_32((x))
139 #define DLT_BETOH_32(x) ((x))
140 #define DLT_LETOH_32(x) DLT_SWAP_32((x))
141 
142 #define DLT_HTOBE_64(x) ((x))
143 #define DLT_HTOLE_64(x) DLT_SWAP_64((x))
144 #define DLT_BETOH_64(x) ((x))
145 #define DLT_LETOH_64(x) DLT_SWAP_64((x))
146 #else
147 /* #warning "Litte Endian Architecture!" */
148 #define DLT_HTOBE_16(x) DLT_SWAP_16((x))
149 #define DLT_HTOLE_16(x) ((x))
150 #define DLT_BETOH_16(x) DLT_SWAP_16((x))
151 #define DLT_LETOH_16(x) ((x))
152 
153 #define DLT_HTOBE_32(x) DLT_SWAP_32((x))
154 #define DLT_HTOLE_32(x) ((x))
155 #define DLT_BETOH_32(x) DLT_SWAP_32((x))
156 #define DLT_LETOH_32(x) ((x))
157 
158 #define DLT_HTOBE_64(x) DLT_SWAP_64((x))
159 #define DLT_HTOLE_64(x) ((x))
160 #define DLT_BETOH_64(x) DLT_SWAP_64((x))
161 #define DLT_LETOH_64(x) ((x))
162 #endif
163 
164 #define DLT_ENDIAN_GET_16(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_16(x):DLT_LETOH_16(x))
165 #define DLT_ENDIAN_GET_32(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_32(x):DLT_LETOH_32(x))
166 #define DLT_ENDIAN_GET_64(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_64(x):DLT_LETOH_64(x))
167 
168 #if defined (__WIN32__) || defined (_MSC_VER)
169 #define LOG_EMERG 0
170 #define LOG_ALERT 1
171 #define LOG_CRIT 2
172 #define LOG_ERR 3
173 #define LOG_WARNING 4
174 #define LOG_NOTICE 5
175 #define LOG_INFO 6
176 #define LOG_DEBUG 7
177 
178 #define LOG_PID 0x01
179 #define LOG_DAEMON (3<<3)
180 #endif
181 
182 enum {
187 };
188 
192 #define DLT_DAEMON_TCP_PORT 3490
193 
194 
195 /* Initial value for file descriptor */
196 #define DLT_FD_INIT -1
197 
198 /* Minimum value for a file descriptor except the POSIX Standards: stdin=0, stdout=1, stderr=2 */
199 #define DLT_FD_MINIMUM 3
200 
204 #define DLT_ID_SIZE 4
205 
206 #define DLT_SIZE_WEID DLT_ID_SIZE
207 #define DLT_SIZE_WSID (sizeof(uint32_t))
208 #define DLT_SIZE_WTMS (sizeof(uint32_t))
209 
213 #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) )
214 
215 
216 #if defined (__MSDOS__) || defined (_MSC_VER)
217 #define __func__ __FUNCTION__
218 #endif
219 
220 #define PRINT_FUNCTION_VERBOSE(_verbose) \
221 { \
222  static char _strbuf[255]; \
223  \
224  if(_verbose) \
225  { \
226  snprintf(_strbuf, 255, "%s()\n",__func__); \
227  dlt_log(LOG_INFO, _strbuf); \
228  } \
229 }
230 
231 #ifndef NULL
232 #define NULL (char*)0
233 #endif
234 
235 #define DLT_MSG_IS_CONTROL(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
236  (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL))
237 
238 #define DLT_MSG_IS_CONTROL_REQUEST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
239  (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \
240  (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_REQUEST))
241 
242 #define DLT_MSG_IS_CONTROL_RESPONSE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
243  (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \
244  (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_RESPONSE))
245 
246 #define DLT_MSG_IS_CONTROL_TIME(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
247  (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \
248  (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_TIME))
249 
250 #define DLT_MSG_IS_NW_TRACE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
251  (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE))
252 
253 #define DLT_MSG_IS_TRACE_MOST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
254  (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE) && \
255  (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_NW_TRACE_MOST))
256 
257 #define DLT_MSG_IS_NONVERBOSE(MSG) (!(DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) || \
258  ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && (!(DLT_IS_MSIN_VERB((MSG)->extendedheader->msin)))))
259 
260 /*
261 
262  * Definitions of DLT message buffer overflow
263  */
264 #define DLT_MESSAGE_BUFFER_NO_OVERFLOW 0x00
265 #define DLT_MESSAGE_BUFFER_OVERFLOW 0x01
267 /*
268  * Definition of DLT output variants
269  */
270 #define DLT_OUTPUT_HEX 1
271 #define DLT_OUTPUT_ASCII 2
272 #define DLT_OUTPUT_MIXED_FOR_PLAIN 3
273 #define DLT_OUTPUT_MIXED_FOR_HTML 4
274 #define DLT_OUTPUT_ASCII_LIMITED 5
275 
276 #define DLT_FILTER_MAX 30
278 #define DLT_MSG_READ_VALUE(dst,src,length,type) \
279 { \
280  if((length<0) || ((length)<((int32_t)sizeof(type)))) \
281  { length = -1; } \
282  else \
283  { dst = *((type*)src);src+=sizeof(type);length-=sizeof(type); } \
284 }
285 
286 #define DLT_MSG_READ_ID(dst,src,length) \
287 { \
288  if((length<0) || ((length)<DLT_ID_SIZE)) \
289  { length = -1; } \
290  else \
291  { memcpy(dst,src,DLT_ID_SIZE);src+=DLT_ID_SIZE;length-=DLT_ID_SIZE; } \
292 }
293 
294 #define DLT_MSG_READ_STRING(dst,src,maxlength,length) \
295 { \
296  if(((maxlength)<0) || ((length)<0) || ((maxlength)<(length))) \
297  { maxlength = -1; } \
298  else \
299  { memcpy(dst,src,length);dlt_clean_string(dst,length);dst[length]=0; \
300  src+=length;maxlength-=length; } \
301 }
302 
303 #define DLT_MSG_READ_NULL(src,maxlength,length) \
304 { \
305  if(((maxlength)<0) || ((length)<0) || ((maxlength)<(length))) \
306  { length = -1; } \
307  else \
308  { src+=length;maxlength-=length; } \
309 }
310 
311 #define DLT_HEADER_SHOW_NONE 0x0000
312 #define DLT_HEADER_SHOW_TIME 0x0001
313 #define DLT_HEADER_SHOW_TMSTP 0x0002
314 #define DLT_HEADER_SHOW_MSGCNT 0x0004
315 #define DLT_HEADER_SHOW_ECUID 0x0008
316 #define DLT_HEADER_SHOW_APID 0x0010
317 #define DLT_HEADER_SHOW_CTID 0x0020
318 #define DLT_HEADER_SHOW_MSGTYPE 0x0040
319 #define DLT_HEADER_SHOW_MSGSUBTYPE 0x0080
320 #define DLT_HEADER_SHOW_VNVSTATUS 0x0100
321 #define DLT_HEADER_SHOW_NOARG 0x0200
322 #define DLT_HEADER_SHOW_ALL 0xFFFF
323 
324 /* dlt_receiver_check_and_get flags */
325 #define DLT_RCV_NONE 0
326 #define DLT_RCV_SKIP_HEADER (1 << 0)
327 #define DLT_RCV_REMOVE (1 << 1)
328 
332 #define DLT_MOUNT_PATH_MAX 1024
333 
337 #define DLT_ENTRY_MAX 100
338 
342 #ifndef DLT_UNIT_TESTS
343 #define STATIC static
344 #else
345 #define STATIC
346 #endif
347 
350 extern const char dltSerialHeader[DLT_ID_SIZE];
351 
355 extern char dltSerialHeaderChar[DLT_ID_SIZE];
356 
360 extern char dltFifoBaseDir[PATH_MAX + 1];
361 
365 typedef char ID4[DLT_ID_SIZE];
366 
370 typedef struct
371 {
372  char pattern[DLT_ID_SIZE];
373  uint32_t seconds;
374  int32_t microseconds;
375  char ecu[DLT_ID_SIZE];
376 } PACKED DltStorageHeader;
377 
381 typedef struct
382 {
383  uint8_t htyp;
384  uint8_t mcnt;
385  uint16_t len;
386 } PACKED DltStandardHeader;
387 
391 typedef struct
392 {
393  char ecu[DLT_ID_SIZE];
394  uint32_t seid;
395  uint32_t tmsp;
396 } PACKED DltStandardHeaderExtra;
397 
401 typedef struct
402 {
403  uint8_t msin;
404  uint8_t noar;
405  char apid[DLT_ID_SIZE];
406  char ctid[DLT_ID_SIZE];
407 } PACKED DltExtendedHeader;
408 
413 typedef struct sDltMessage
414 {
415  /* flags */
417 
418  /* offsets */
419  int32_t resync_offset;
420 
421  /* size parameters */
422  int32_t headersize;
423  int32_t datasize;
425  /* buffer for current loaded message */
426  uint8_t headerbuffer[sizeof(DltStorageHeader)+
427  sizeof(DltStandardHeader)+sizeof(DltStandardHeaderExtra)+sizeof(DltExtendedHeader)];
428  uint8_t *databuffer;
429  int32_t databuffersize;
430 
431  /* header values of current loaded message */
432  DltStorageHeader *storageheader;
433  DltStandardHeader *standardheader;
434  DltStandardHeaderExtra headerextra;
435  DltExtendedHeader *extendedheader;
436 } DltMessage;
437 
441 typedef struct
442 {
443  uint32_t service_id;
444  uint8_t options;
445  char apid[DLT_ID_SIZE];
446  char ctid[DLT_ID_SIZE];
447  char com[DLT_ID_SIZE];
448 } PACKED DltServiceGetLogInfoRequest;
449 
453 typedef struct
454 {
455 
456  uint32_t service_id;
457  char apid[DLT_ID_SIZE];
458  char ctid[DLT_ID_SIZE];
459  uint8_t log_level;
460  char com[DLT_ID_SIZE];
461 } PACKED DltServiceSetLogLevel;
462 
466 typedef struct
467 {
468  uint32_t service_id;
469  uint8_t log_level;
470  char com[DLT_ID_SIZE];
471 } PACKED DltServiceSetDefaultLogLevel;
472 
476 typedef struct
477 {
478  uint32_t service_id;
479  uint8_t new_status;
480 } PACKED DltServiceSetVerboseMode;
481 
485 typedef struct
486 {
487  uint32_t service_id;
488  char com[DLT_ID_SIZE];
489  uint8_t new_status;
490 } PACKED DltServiceSetCommunicationInterfaceStatus;
491 
495 typedef struct
496 {
497  uint32_t service_id;
498  char com[DLT_ID_SIZE];
499  uint32_t max_bandwidth;
500 } PACKED DltServiceSetCommunicationMaximumBandwidth;
501 
502 typedef struct
503 {
504  uint32_t service_id;
505  uint8_t status;
506 } PACKED DltServiceResponse;
507 
508 typedef struct
509 {
510  uint32_t service_id;
511  uint8_t status;
512  uint8_t log_level;
513 } PACKED DltServiceGetDefaultLogLevelResponse;
514 
515 typedef struct
516 {
517  uint32_t service_id;
518  uint8_t status;
519  uint8_t overflow;
520  uint32_t overflow_counter;
521 } PACKED DltServiceMessageBufferOverflowResponse;
522 
523 typedef struct
524 {
525  uint32_t service_id;
526 } PACKED DltServiceGetSoftwareVersion;
527 
528 typedef struct
529 {
530  uint32_t service_id;
531  uint8_t status;
532  uint32_t length;
533  /*char [] payload;*/
534 } PACKED DltServiceGetSoftwareVersionResponse;
535 
539 typedef struct
540 {
541  uint32_t service_id;
542  uint8_t status;
543  char apid[DLT_ID_SIZE];
544  char ctid[DLT_ID_SIZE];
545  char comid[DLT_ID_SIZE];
546 } PACKED DltServiceUnregisterContext;
547 
551 typedef struct
552 {
553  uint32_t service_id;
554  uint8_t status;
555  uint8_t state;
556  char comid[DLT_ID_SIZE];
557 } PACKED DltServiceConnectionInfo;
558 
562 typedef struct
563 {
564  uint32_t service_id;
565  uint8_t status;
566  int32_t timezone;
567  uint8_t isdst;
568 } PACKED DltServiceTimezone;
569 
573 typedef struct
574 {
575  uint32_t service_id;
576  uint8_t status;
577 } PACKED DltServiceMarker;
578 
579 /***
580  * The structure of the DLT Service Offline Logstorage
581  */
582 typedef struct
583 {
584  uint32_t service_id;
585  char mount_point[DLT_MOUNT_PATH_MAX];
586  uint8_t connection_type;
587  char comid[DLT_ID_SIZE];
588 } PACKED DltServiceOfflineLogstorage;
589 
593 typedef struct
594 {
595  uint32_t service_id;
596  uint8_t status;
597  char name[DLT_ENTRY_MAX];
598  uint32_t level;
599  uint32_t client_mask;
600  uint32_t ctrl_mask;
601  char injections[DLT_ENTRY_MAX];
602 } PACKED DltServiceGetCurrentFilterInfo;
603 
607 typedef struct
608 {
609  uint32_t service_id;
610  uint32_t connection_status;
611  char node_id[DLT_ID_SIZE];
612 } PACKED DltServicePassiveNodeConnect;
613 
617 typedef struct
618 {
619  uint32_t service_id;
620  uint8_t status;
621  uint32_t num_connections;
623  char node_id[DLT_ENTRY_MAX];
624 } PACKED DltServicePassiveNodeConnectionInfo;
625 
631 typedef struct
632 {
635  int counter;
636 } DltFilter;
637 
642 typedef struct sDltFile
643 {
644  /* file handle and index for fast access */
645  FILE *handle;
646  long *index;
648  /* size parameters */
649  int32_t counter;
650  int32_t counter_total;
651  int32_t position;
652  long file_length;
655  /* error counters */
656  int32_t error_messages;
658  /* filter parameters */
660  int32_t filter_counter;
662  /* current loaded message */
665 } DltFile;
666 
672 typedef struct
673 {
674  int32_t lastBytesRcvd;
675  int32_t bytesRcvd;
676  int32_t totalBytesRcvd;
677  char *buffer;
678  char *buf;
679  int fd;
680  int32_t buffersize;
681 } DltReceiver;
682 
683 typedef struct
684 {
685  unsigned char* shm; /* pointer to beginning of shared memory */
686  int size; /* size of data area in shared memory */
687  unsigned char* mem; /* pointer to data area in shared memory */
688 
689  uint32_t min_size;
690  uint32_t max_size;
691  uint32_t step_size;
692 } DltBuffer;
693 
694 typedef struct
695 {
696  int write;
697  int read;
698  int count;
699 } DltBufferHead;
700 
701 #define DLT_BUFFER_HEAD "SHM"
702 
703 typedef struct
704 {
705  char head[4];
706  unsigned char status;
707  int size;
709 
710 #define DLT_MESSAGE_ERROR_OK 0
711 #define DLT_MESSAGE_ERROR_UNKNOWN -1
712 #define DLT_MESSAGE_ERROR_SIZE -2
713 #define DLT_MESSAGE_ERROR_CONTENT -3
714 
715 #ifdef __cplusplus
716 extern "C"
717 {
718 #endif
719 
725  void dlt_print_hex(uint8_t *ptr,int size);
734  DltReturnValue dlt_print_hex_string(char *text,int textlength,uint8_t *ptr,int size);
744  DltReturnValue dlt_print_mixed_string(char *text,int textlength,uint8_t *ptr,int size,int html);
753  DltReturnValue dlt_print_char_string(char **text,int textlength,uint8_t *ptr,int size);
754 
760  void dlt_print_id(char *text,const char *id);
761 
767  void dlt_set_id(char *id,const char *text);
768 
774  void dlt_clean_string(char *text,int length);
775 
783  DltReturnValue dlt_filter_init(DltFilter *filter,int verbose);
790  DltReturnValue dlt_filter_free(DltFilter *filter,int verbose);
798  DltReturnValue dlt_filter_load(DltFilter *filter,const char *filename,int verbose);
806  DltReturnValue dlt_filter_save(DltFilter *filter,const char *filename,int verbose);
815  int dlt_filter_find(DltFilter *filter,const char *apid,const char *ctid, int verbose);
824  DltReturnValue dlt_filter_add(DltFilter *filter,const char *apid,const char *ctid,int verbose);
833  DltReturnValue dlt_filter_delete(DltFilter *filter,const char *apid,const char *ctid,int verbose);
834 
842  DltReturnValue dlt_message_init(DltMessage *msg,int verbose);
849  DltReturnValue dlt_message_free(DltMessage *msg,int verbose);
859  DltReturnValue dlt_message_header(DltMessage *msg,char *text,int textlength,int verbose);
869  DltReturnValue dlt_message_header_flags(DltMessage *msg,char *text,int textlength,int flags, int verbose);
879  DltReturnValue dlt_message_payload(DltMessage *msg,char *text,int textlength,int type,int verbose);
888 
899  int dlt_message_read(DltMessage *msg,uint8_t *buffer,unsigned int length,int resync,int verbose);
900 
908 
916 
924  DltReturnValue dlt_file_init(DltFile *file,int verbose);
935  DltReturnValue dlt_file_set_filter(DltFile *file,DltFilter *filter,int verbose);
943  DltReturnValue dlt_file_open(DltFile *file,const char *filename,int verbose);
952  DltReturnValue dlt_file_read(DltFile *file,int verbose);
962  DltReturnValue dlt_file_read_raw(DltFile *file,int resync,int verbose);
969  DltReturnValue dlt_file_close(DltFile *file,int verbose);
976  DltReturnValue dlt_file_read_header(DltFile *file,int verbose);
984  DltReturnValue dlt_file_read_header_raw(DltFile *file,int resync,int verbose);
1001  DltReturnValue dlt_file_read_data(DltFile *file, int verbose);
1010  DltReturnValue dlt_file_message(DltFile *file,int index,int verbose);
1017  DltReturnValue dlt_file_free(DltFile *file,int verbose);
1018 
1023  void dlt_log_set_filename(const char *filename);
1028  void dlt_log_set_level(int level);
1033  void dlt_log_init(int mode);
1040  DltReturnValue dlt_log(int prio, char *s);
1047  DltReturnValue dlt_vlog(int prio, const char *format, ...);
1055  DltReturnValue dlt_vnlog(int prio, size_t size, const char *format, ...);
1059  void dlt_log_free(void);
1060 
1068  DltReturnValue dlt_receiver_init(DltReceiver *receiver,int _fd, int _buffersize);
1086  int dlt_receiver_receive_fd(DltReceiver *receiver);
1093  DltReturnValue dlt_receiver_remove(DltReceiver *receiver,int size);
1100 
1110  void *dest,
1111  unsigned int to_get,
1112  unsigned int skip_header);
1113 
1120  DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu);
1126  DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader);
1127 
1128 
1138  DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size);
1139 
1149  DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size);
1150 
1163  DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size,uint32_t step_size);
1164 
1171 
1178 
1186  DltReturnValue dlt_buffer_push(DltBuffer *buf,const unsigned char *data,unsigned int size);
1187 
1200  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);
1201 
1210  int dlt_buffer_pull(DltBuffer *buf,unsigned char *data, int max_size);
1211 
1220  int dlt_buffer_copy(DltBuffer *buf,unsigned char *data, int max_size);
1221 
1227  int dlt_buffer_remove(DltBuffer *buf);
1228 
1233  void dlt_buffer_info(DltBuffer *buf);
1234 
1239  void dlt_buffer_status(DltBuffer *buf);
1240 
1247  uint32_t dlt_buffer_get_total_size(DltBuffer *buf);
1248 
1255 
1262 
1263 #if !defined (__WIN32__)
1264 
1271  DltReturnValue dlt_setup_serial(int fd, speed_t speed);
1272 
1278  speed_t dlt_convert_serial_speed(int baudrate);
1279 
1285  void dlt_get_version(char *buf, size_t size);
1286 
1292  void dlt_get_major_version(char *buf, size_t size);
1293 
1299  void dlt_get_minor_version(char *buf, size_t size);
1300 
1301 #endif
1302 
1303  /* Function prototypes which should be used only internally */
1304  /* */
1305 
1311 
1316  uint32_t dlt_uptime(void);
1317 
1326  DltReturnValue dlt_message_print_header(DltMessage *message, char *text, uint32_t size, int verbose);
1327 
1336  DltReturnValue dlt_message_print_hex(DltMessage *message, char *text, uint32_t size, int verbose);
1337 
1346  DltReturnValue dlt_message_print_ascii(DltMessage *message, char *text, uint32_t size, int verbose);
1347 
1356  DltReturnValue dlt_message_print_mixed_plain(DltMessage *message, char *text, uint32_t size, int verbose);
1357 
1366  DltReturnValue dlt_message_print_mixed_html(DltMessage *message, char *text, uint32_t size, int verbose);
1367 
1380  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);
1381 
1385  void dlt_check_envvar();
1386 
1391  int dlt_mkdir_recursive(const char *dir);
1392 
1393 #ifdef __cplusplus
1394 }
1395 #endif
1396 
1401 #endif /* DLT_COMMON_H */
int32_t datasize
Definition: dlt_common.h:423
DltReturnValue dlt_file_open(DltFile *file, const char *filename, int verbose)
Definition: dlt_common.c:1594
int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int resync, int verbose)
Definition: dlt_common.c:1091
DltReturnValue dlt_file_read_data(DltFile *file, int verbose)
Definition: dlt_common.c:1551
DltReturnValue dlt_buffer_push(DltBuffer *buf, const unsigned char *data, unsigned int size)
Definition: dlt_common.c:2686
int dlt_receiver_receive_socket(DltReceiver *receiver)
Definition: dlt_common.c:2173
DltReturnValue dlt_file_read_header(DltFile *file, int verbose)
Definition: dlt_common.c:1346
DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size, uint32_t step_size)
Definition: dlt_common.c:2430
#define DLT_ID_SIZE
Definition: dlt_common.h:204
int8_t found_serialheader
Definition: dlt_common.h:416
DltReturnValue dlt_message_print_header(DltMessage *message, char *text, uint32_t size, int verbose)
Definition: dlt_common.c:3297
DltStorageHeader * storageheader
Definition: dlt_common.h:432
uint32_t dlt_buffer_get_total_size(DltBuffer *buf)
Definition: dlt_common.c:2943
uint32_t num_connections
Definition: dlt_common.h:621
connection_status
DltReturnValue
Definition: dlt_types.h:86
DltReturnValue dlt_filter_save(DltFilter *filter, const char *filename, int verbose)
Definition: dlt_common.c:496
void dlt_check_envvar()
Definition: dlt_common.c:3867
DltReturnValue dlt_file_message(DltFile *file, int index, int verbose)
Definition: dlt_common.c:1895
int32_t buffersize
Definition: dlt_common.h:680
DltReturnValue dlt_init_common(void)
Definition: dlt_user.c:443
uint8_t htyp
Definition: dlt_common.h:383
void dlt_get_minor_version(char *buf, size_t size)
Definition: dlt_common.c:3262
void dlt_set_id(char *id, const char *text)
Definition: dlt_common.c:324
void dlt_buffer_info(DltBuffer *buf)
Definition: dlt_common.c:2899
DltReturnValue dlt_file_set_filter(DltFile *file, DltFilter *filter, int verbose)
Definition: dlt_common.c:1331
int dlt_receiver_check_and_get(DltReceiver *receiver, void *dest, unsigned int to_get, unsigned int skip_header)
Definition: dlt_common.c:2277
DltReturnValue dlt_buffer_free_static(DltBuffer *buf)
Definition: dlt_common.c:2479
DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose)
Definition: dlt_common.c:1782
DltReturnValue dlt_file_read_header_raw(DltFile *file, int resync, int verbose)
Definition: dlt_common.c:1397
int counter
Definition: dlt_common.h:635
DltReturnValue dlt_filter_delete(DltFilter *filter, const char *apid, const char *ctid, int verbose)
Definition: dlt_common.c:617
void dlt_log_free(void)
Definition: dlt_common.c:2022
DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf)
Definition: dlt_common.c:2494
DltReturnValue dlt_print_mixed_string(char *text, int textlength, uint8_t *ptr, int size, int html)
Definition: dlt_common.c:153
void dlt_clean_string(char *text, int length)
Definition: dlt_common.c:372
DltReturnValue dlt_file_read_header_extended(DltFile *file, int verbose)
Definition: dlt_common.c:1499
uint8_t connection_type
Definition: dlt_common.h:586
DltReturnValue dlt_receiver_remove(DltReceiver *receiver, int size)
Definition: dlt_common.c:2232
unsigned char status
Definition: dlt_common.h:706
DltReturnValue dlt_message_filter_check(DltMessage *msg, DltFilter *filter, int verbose)
Definition: dlt_common.c:1057
char * buf
Definition: dlt_common.h:678
uint32_t client_mask
Definition: dlt_common.h:599
uint32_t max_bandwidth
Definition: dlt_common.h:499
uint8_t new_status
Definition: dlt_common.h:479
DltReturnValue dlt_log(int prio, char *s)
Definition: dlt_common.c:2029
DltReturnValue dlt_file_read(DltFile *file, int verbose)
Definition: dlt_common.c:1647
struct sDltMessage DltMessage
DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
Definition: dlt_common.c:2376
int dlt_receiver_receive_fd(DltReceiver *receiver)
Definition: dlt_common.c:2203
DltReturnValue dlt_print_hex_string(char *text, int textlength, uint8_t *ptr, int size)
Definition: dlt_common.c:120
DltReturnValue dlt_filter_init(DltFilter *filter, int verbose)
Definition: dlt_common.c:390
DltFilter * filter
Definition: dlt_common.h:659
DltReturnValue dlt_message_init(DltMessage *msg, int verbose)
Definition: dlt_common.c:666
unsigned char * mem
Definition: dlt_common.h:687
int32_t bytesRcvd
Definition: dlt_common.h:675
uint32_t connection_status
Definition: dlt_common.h:610
DltReturnValue dlt_receiver_move_to_begin(DltReceiver *receiver)
Definition: dlt_common.c:2257
int32_t filter_counter
Definition: dlt_common.h:660
DltExtendedHeader * extendedheader
Definition: dlt_common.h:435
DltReturnValue dlt_message_print_ascii(DltMessage *message, char *text, uint32_t size, int verbose)
Definition: dlt_common.c:3325
uint32_t tmsp
Definition: dlt_common.h:395
#define DLT_MOUNT_PATH_MAX
Definition: dlt_common.h:332
DltReturnValue dlt_print_char_string(char **text, int textlength, uint8_t *ptr, int size)
Definition: dlt_common.c:260
DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
Definition: dlt_common.c:2407
int dlt_buffer_copy(DltBuffer *buf, unsigned char *data, int max_size)
Definition: dlt_common.c:2889
uint32_t seconds
Definition: dlt_common.h:373
static char * service_id[]
Definition: dlt_common.c:85
int dlt_buffer_get_used_size(DltBuffer *buf)
Definition: dlt_common.c:2952
DltReturnValue dlt_message_set_extraparameters(DltMessage *msg, int verbose)
Definition: dlt_common.c:1273
uint8_t noar
Definition: dlt_common.h:404
static char data[kDataSize]
Definition: city-test.cc:40
DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu)
Definition: dlt_common.c:2315
int32_t databuffersize
Definition: dlt_common.h:429
char * buffer
Definition: dlt_common.h:677
DltReturnValue dlt_receiver_init(DltReceiver *receiver, int _fd, int _buffersize)
Definition: dlt_common.c:2126
DltReturnValue dlt_filter_free(DltFilter *filter, int verbose)
Definition: dlt_common.c:404
int32_t position
Definition: dlt_common.h:651
int dlt_filter_find(DltFilter *filter, const char *apid, const char *ctid, int verbose)
Definition: dlt_common.c:544
unsigned char * shm
Definition: dlt_common.h:685
uint8_t isdst
Definition: dlt_common.h:567
uint16_t len
Definition: dlt_common.h:385
int dlt_mkdir_recursive(const char *dir)
Definition: dlt_common.c:3905
unsigned char buffer[BUFFER_SIZE]
Buffer for dlt file transfer. The size is defined by BUFFER_SIZE.
uint32_t ctrl_mask
Definition: dlt_common.h:600
uint32_t dlt_uptime(void)
Definition: dlt_common.c:3274
uint8_t state
Definition: dlt_common.h:555
char ID4[DLT_ID_SIZE]
Definition: dlt_common.h:365
FILE * handle
Definition: dlt_common.h:645
int32_t counter_total
Definition: dlt_common.h:650
uint32_t max_size
Definition: dlt_common.h:690
void dlt_log_set_filename(const char *filename)
Definition: dlt_common.c:1981
DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verbose)
Definition: dlt_common.c:416
int32_t headersize
Definition: dlt_common.h:422
void dlt_buffer_status(DltBuffer *buf)
Definition: dlt_common.c:2916
int32_t timezone
Definition: dlt_common.h:566
const char dltSerialHeader[DLT_ID_SIZE]
Definition: dlt_common.c:70
#define DLT_ENTRY_MAX
Definition: dlt_common.h:337
uint8_t headerbuffer[sizeof(DltStorageHeader)+sizeof(DltStandardHeader)+sizeof(DltStandardHeaderExtra)+sizeof(DltExtendedHeader)]
Definition: dlt_common.h:427
long * index
Definition: dlt_common.h:646
uint32_t level
Definition: dlt_common.h:598
int dlt_buffer_remove(DltBuffer *buf)
Definition: dlt_common.c:2894
int32_t error_messages
Definition: dlt_common.h:656
int dlt_buffer_get_message_count(DltBuffer *buf)
Definition: dlt_common.c:2977
int32_t microseconds
Definition: dlt_common.h:374
DltStandardHeaderExtra headerextra
Definition: dlt_common.h:434
uint8_t overflow
Definition: dlt_common.h:519
DltMessage msg
Definition: dlt_common.h:663
DltReturnValue dlt_filter_add(DltFilter *filter, const char *apid, const char *ctid, int verbose)
Definition: dlt_common.c:583
DltReturnValue dlt_file_init(DltFile *file, int verbose)
Definition: dlt_common.c:1305
DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength, int type, int verbose)
Definition: dlt_common.c:891
DltReturnValue dlt_message_print_mixed_html(DltMessage *message, char *text, uint32_t size, int verbose)
Definition: dlt_common.c:3355
void dlt_print_id(char *text, const char *id)
Definition: dlt_common.c:301
uint32_t length
Definition: dlt_common.h:532
DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader)
Definition: dlt_common.c:2353
int32_t resync_offset
Definition: dlt_common.h:419
char dltFifoBaseDir[PATH_MAX+1]
Definition: dlt_common.c:72
DltReturnValue dlt_file_free(DltFile *file, int verbose)
Definition: dlt_common.c:1942
DltReturnValue dlt_setup_serial(int fd, speed_t speed)
Definition: dlt_common.c:2992
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)
DltReturnValue dlt_vnlog(int prio, size_t size, const char *format,...)
Definition: dlt_common.c:2099
DltStandardHeader * standardheader
Definition: dlt_common.h:433
DltReturnValue dlt_message_free(DltMessage *msg, int verbose)
Definition: dlt_common.c:691
speed_t dlt_convert_serial_speed(int baudrate)
Definition: dlt_common.c:3067
char dltSerialHeaderChar[DLT_ID_SIZE]
Definition: dlt_common.c:71
void dlt_print_hex(uint8_t *ptr, int size)
Definition: dlt_common.c:100
int32_t counter
Definition: dlt_common.h:649
uint8_t msin
Definition: dlt_common.h:403
int32_t lastBytesRcvd
Definition: dlt_common.h:674
uint8_t options
Definition: dlt_common.h:444
uint8_t mcnt
Definition: dlt_common.h:384
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)
Definition: dlt_common.c:2691
void dlt_get_version(char *buf, size_t size)
Definition: dlt_common.c:3239
void dlt_log_set_level(int level)
Definition: dlt_common.c:1968
struct sDltFile DltFile
long file_length
Definition: dlt_common.h:652
DltReturnValue dlt_message_header(DltMessage *msg, char *text, int textlength, int verbose)
Definition: dlt_common.c:710
int dlt_buffer_pull(DltBuffer *buf, unsigned char *data, int max_size)
Definition: dlt_common.c:2884
uint32_t seid
Definition: dlt_common.h:394
DltReturnValue dlt_message_print_hex(DltMessage *message, char *text, uint32_t size, int verbose)
Definition: dlt_common.c:3310
uint8_t * databuffer
Definition: dlt_common.h:428
#define DLT_FILTER_MAX
Definition: dlt_common.h:276
long file_position
Definition: dlt_common.h:653
DltReturnValue dlt_message_get_extraparameters(DltMessage *msg, int verbose)
Definition: dlt_common.c:1241
uint8_t status
Definition: dlt_common.h:505
DltReturnValue dlt_file_close(DltFile *file, int verbose)
Definition: dlt_common.c:1876
DltReturnValue dlt_vlog(int prio, const char *format,...)
Definition: dlt_common.c:2078
DltReturnValue dlt_message_header_flags(DltMessage *msg, char *text, int textlength, int flags, int verbose)
Definition: dlt_common.c:715
void dlt_get_major_version(char *buf, size_t size)
Definition: dlt_common.c:3251
int32_t totalBytesRcvd
Definition: dlt_common.h:676
uint32_t min_size
Definition: dlt_common.h:689
uint32_t step_size
Definition: dlt_common.h:691
DltReturnValue dlt_message_print_mixed_plain(DltMessage *message, char *text, uint32_t size, int verbose)
Definition: dlt_common.c:3340
void dlt_log_init(int mode)
Definition: dlt_common.c:2000
DltReturnValue dlt_receiver_free(DltReceiver *receiver)
Definition: dlt_common.c:2153