1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521
|
/*
* SPDX license identifier: MPL-2.0
*
* Copyright (C) 2011-2015, BMW AG
*
* This file is part of COVESA Project DLT - Diagnostic Log and Trace.
*
* This Source Code Form is subject to the terms of the
* Mozilla Public License (MPL), v. 2.0.
* If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* For further information see http://www.covesa.org/.
*/
/*!
* \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
*
* \copyright Copyright © 2011-2015 BMW AG. \n
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_user.h
*/
/*******************************************************************************
** **
** SRC-MODULE: dlt_user.h **
** **
** TARGET : linux **
** **
** PROJECT : DLT **
** **
** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
** Markus Klein **
** **
** PURPOSE : **
** **
** REMARKS : **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Company **
** -------- ------------------------- ---------------------------------- **
** aw Alexander Wenzel BMW **
** mk Markus Klein Fraunhofer ESK **
*******************************************************************************/
/*******************************************************************************
** Revision Control History **
*******************************************************************************/
/*
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
* Initials Date Comment
* aw 13.01.2010 initial
*/
#ifndef DLT_USER_H
# define DLT_USER_H
/**
* \defgroup userapi DLT User API
* \addtogroup userapi
\{
*/
#include <stdbool.h>
#ifndef DLT_NETWORK_TRACE_ENABLE
#cmakedefine DLT_NETWORK_TRACE_ENABLE
#endif
#cmakedefine01 DLT_DISABLE_MACRO
#ifdef DLT_NETWORK_TRACE_ENABLE
# include <mqueue.h>
#else
# include <sys/types.h>
# include <fcntl.h>
#endif
# include <pthread.h>
# if !defined (__WIN32__)
# include <semaphore.h>
# endif
# include "dlt_types.h"
# include "dlt_shm.h"
#if !DLT_DISABLE_MACRO
# include "dlt_user_macros.h"
#endif
# ifdef __cplusplus
extern "C" {
# endif
# define DLT_USER_BUF_MAX_SIZE 1390 /**< maximum size of each user buffer, also used for injection buffer */
# define DLT_USER_RESENDBUF_MAX_SIZE (DLT_USER_BUF_MAX_SIZE + 100) /**< Size of resend buffer; Max DLT message size is 1390 bytes plus some extra header space */
# define MAX_CONTEXT_LEN_V2 255 /**< maximum context id length */
/**
* This structure is used for every context used in an application.
*/
typedef struct
{
char contextID[DLT_ID_SIZE]; /**< context id */
uint8_t contextID2len; /**< version 2 context id length */
char *contextID2; /**< version 2 context id of variable length*/
int32_t log_level_pos; /**< offset in user-application context field */
int8_t *log_level_ptr; /**< pointer to the log level */
int8_t *trace_status_ptr; /**< pointer to the trace status */
uint8_t mcnt; /**< message counter */
} DltContext;
/**
* This structure is used for context data used in an application.
*/
typedef struct
{
DltContext *handle; /**< pointer to DltContext */
unsigned char *buffer; /**< buffer for building log message*/
int32_t size; /**< payload size */
int32_t log_level; /**< log level */
int32_t trace_status; /**< trace status */
int32_t args_num; /**< number of arguments for extended header*/
char *context_description; /**< description of context */
DltTimestampType use_timestamp; /**< whether to use user-supplied timestamps */
uint32_t user_timestamp; /**< user-supplied timestamp to use */
uint32_t msid; /**< Message ID */
int8_t verbose_mode; /**< verbose mode: 1 enabled, 0 disabled */
} DltContextData;
typedef struct
{
uint32_t service_id;
int (*injection_callback)(uint32_t service_id, void *data, uint32_t length);
int (*injection_callback_with_id)(uint32_t service_id, void *data, uint32_t length, void *priv_data);
void *data;
} DltUserInjectionCallback;
typedef struct
{
char contextID[DLT_ID_SIZE]; /**< Context ID */
uint8_t contextID2len; /**< Version 2 context id length */
char contextID2[DLT_V2_ID_SIZE]; /**< Version 2 context id fixed-size buffer */
int8_t log_level; /**< Log level */
int8_t trace_status; /**< Trace status */
void (*log_level_changed_callback)(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status);
void (*log_level_changed_callback_v2)(char *context_id, uint8_t log_level, uint8_t trace_status);
} DltUserLogLevelChangedCallback;
/**
* This structure is used in a table managing all contexts and the corresponding log levels in an application.
*/
typedef struct
{
char contextID[DLT_ID_SIZE]; /**< Context ID */
uint8_t contextID2len; /**< Version 2 context id length */
char contextID2[DLT_V2_ID_SIZE]; /**< Version 2 context id fixed-size buffer */
int8_t log_level; /**< Log level */
int8_t *log_level_ptr; /**< Ptr to the log level */
int8_t trace_status; /**< Trace status */
int8_t *trace_status_ptr; /**< Ptr to the trace status */
char *context_description; /**< description of context */
DltUserInjectionCallback *injection_table; /**< Table with pointer to injection functions and service ids */
uint32_t nrcallbacks;
/* Log Level changed callback */
void (*log_level_changed_callback)(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status);
void (*log_level_changed_callback_v2)(char *context_id, uint8_t log_level, uint8_t trace_status);
#ifdef DLT_TRACE_LOAD_CTRL_ENABLE
DltTraceLoadSettings *trace_load_settings; /**< trace load setting for the context */
#endif
} dlt_ll_ts_type;
/**
* @brief holds initial log-level for given appId:ctxId pair
*/
typedef struct
{
char appId[DLT_ID_SIZE]; /**< version 1 app id */
uint8_t appId2len; /**< version 2 app id length */
char *appId2; /**< version 2 app id of variable length*/
char ctxId[DLT_ID_SIZE]; /**< version 1 context id */
uint8_t ctxId2len; /**< version 2 context id length */
char *ctxId2; /**< version 2 context id of variable length*/
int8_t ll;
} dlt_env_ll_item;
/**
* @brief holds all initial log-levels given via environment variable DLT_INITIAL_LOG_LEVEL
*/
typedef struct
{
dlt_env_ll_item *item;
size_t array_size;
size_t num_elem;
} dlt_env_ll_set;
/**
* This structure is used once for one application.
*/
typedef struct
{
char ecuID[DLT_ID_SIZE]; /**< ECU ID */
uint8_t ecuID2len; /**< Version 2 ecu id length */
char ecuID2[DLT_V2_ID_SIZE]; /**< Version 2 ecu id of variable length*/
char appID[DLT_ID_SIZE]; /**< Application ID */
uint8_t appID2len; /**< Version 2 app id length */
char appID2[DLT_V2_ID_SIZE]; /**< Version 2 app id of variable length*/
int dlt_log_handle; /**< Handle to fifo of dlt daemon */
int dlt_user_handle; /**< Handle to own fifo */
#ifdef DLT_NETWORK_TRACE_ENABLE
mqd_t dlt_segmented_queue_read_handle; /**< Handle message queue */
mqd_t dlt_segmented_queue_write_handle; /**< Handle message queue */
pthread_t dlt_segmented_nwt_handle; /**< thread handle of segmented sending */
#endif
int8_t dlt_is_file; /**< Target of logging: 1 to file, 0 to daemon */
unsigned int filesize_max; /**< Maximum size of existing file in case dlt_is_file=1 */
uint8_t filenamelen; /**< Version 2 filename of length*/
char *filename; /**< Version 2 filename of variable length*/
uint32_t linenumber; /**< Linenumber of the log */
uint8_t numberoftags; /**< Number of tags */
DltTag *tag; /**< Pointer to tag structure for storing tags */
int tagbuffersize; /**< Buffer to hold tag lengths and names sequentially */
uint8_t prlv; /**< Privacy level */
dlt_ll_ts_type *dlt_ll_ts; /** [MAX_DLT_LL_TS_ENTRIES]; < Internal management struct for all
* contexts */
uint32_t dlt_ll_ts_max_num_entries; /**< Maximum number of contexts */
uint32_t dlt_ll_ts_num_entries; /**< Number of used contexts */
int8_t overflow; /**< Overflow marker, set to 1 on overflow, 0 otherwise */
uint32_t overflow_counter; /**< Counts the number of lost messages */
char *application_description; /**< description of application */
DltReceiver receiver; /**< Receiver for internal user-defined messages from daemon */
int8_t verbose_mode; /**< Verbose mode enabled: 1 enabled, 0 disabled */
int8_t use_extended_header_for_non_verbose; /**< Use extended header for non verbose: 1 enabled, 0 disabled */
int8_t with_session_id; /**< Send always session id: 1 enabled, 0 disabled */
int8_t with_timestamp; /**< Send always timestamp: 1 enabled, 0 disabled */
int8_t with_ecu_id; /**< Send always ecu id: 1 enabled, 0 disabled */
int8_t with_app_and_context_id; /**< Send always app and context id: 1 enabled, 0 disabled */
int8_t with_filename_and_line_number; /**< Send always source filename and line no.: 1 enabled, 0 disabled */
int8_t with_tags; /**< Send always tags: 1 enabled, 0 disabled */
int8_t with_privacy_level; /**< Send always privacy level: 1 enabled, 0 disabled */
int8_t with_segmentation; /**< Message is segmented: 1 enabled, 0 disabled */
int8_t enable_local_print; /**< Local printing of log messages: 1 enabled, 0 disabled */
int8_t local_print_mode; /**< Local print mode, controlled by environment variable */
int8_t disable_injection_msg; /**< Injection msg availability: 1 disabled, 0 enabled (default) */
int8_t log_state; /**< Log state of external connection:
* 1 client connected,
* 0 not connected,
* -1 unknown */
DltBuffer startup_buffer; /**< Ring-buffer for buffering messages during startup and missing connection */
/* Buffer used for resending, locked by DLT semaphore */
uint8_t *resend_buffer;
uint32_t timeout_at_exit_handler; /**< timeout used in dlt_user_atexit_blow_out_user_buffer, in 0.1 milliseconds */
dlt_env_ll_set initial_ll_set;
# ifdef DLT_SHM_ENABLE
DltShm dlt_shm;
# endif
# ifdef DLT_TEST_ENABLE
int corrupt_user_header;
int corrupt_message_size;
int16_t corrupt_message_size_size;
# endif
# if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
DltUserConnectionState connection_state;
# endif
uint16_t log_buf_len; /**< length of message buffer, by default: DLT_USER_BUF_MAX_SIZE */
#ifdef DLT_TRACE_LOAD_CTRL_ENABLE
pthread_rwlock_t trace_load_limit_lock;
#endif
pid_t local_pid; /**< Local DltUser process identifier cache */
} DltUser;
typedef int (*dlt_injection_callback_id)(uint32_t, void *, uint32_t, void *);
typedef int (*dlt_injection_callback)(uint32_t, void *, uint32_t);
typedef union {
int (*with_id)(uint32_t, void *, uint32_t, void *);
int (*without_id)(uint32_t, void *, uint32_t);
} dlt_injection_callback_internal;
/**************************************************************************************************
* The following API functions define a low level function interface for DLT
**************************************************************************************************/
/**
* Initialize the generation of a DLT log message (intended for usage in verbose mode)
* This function has to be called first, when an application wants to send a new log messages.
* Following functions like dlt_user_log_write_string and dlt_user_log_write_finish must only be called,
* when return value is bigger than zero.
* @param handle pointer to an object containing information about one special logging context
* @param log pointer to an object containing information about logging context data
* @param loglevel this is the current log level of the log message to be sent
* @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is matching
*/
DltReturnValue dlt_user_log_write_start(DltContext *handle, DltContextData *log, DltLogLevelType loglevel);
/**
* Initialize the generation of a DLT log message (intended for usage in non-verbose mode)
* This function has to be called first, when an application wants to send a new log messages.
* Following functions like dlt_user_log_write_string and dlt_user_log_write_finish must only be called,
* when return value is bigger than zero.
* @param handle pointer to an object containing information about one special logging context
* @param log pointer to an object containing information about logging context data
* @param loglevel this is the current log level of the log message to be sent
* @param messageid message id of message
* @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is matching
*/
DltReturnValue dlt_user_log_write_start_id(DltContext *handle,
DltContextData *log,
DltLogLevelType loglevel,
uint32_t messageid);
/**
* Initialize the generation of a DLT log message with given buffer from DLT application.
* This can be considered as replacement of dlt_user_log_write_start/dlt_user_log_write_start_id
* and other data functions like dlt_user_log_write_string. The fourth, fifth, and sixth arguments
* shall be prepared by DLT application; this function is only responsible for checking log
* level and setting the given values to context data. This function has to be called first,
* when an application is ready to send a new log message with given buffer. This function only
* works with combination of dlt_user_log_write_finish_w_given_buffer and the function must only be
* called, when return value is bigger than zero. The function only supports verbose mode as of now.
* @param handle pointer to an object containing information about one special logging context
* @param log pointer to an object containing information about logging context data
* @param loglevel this is the current log level of the log message to be sent
* @param buffer data with log message
* @param size buffer size
* @param args_num number of arguments in buffer
* @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is matching
*/
DltReturnValue dlt_user_log_write_start_w_given_buffer(DltContext *handle,
DltContextData *log,
DltLogLevelType loglevel,
char *buffer,
size_t size,
int32_t args_num);
/**
* Finishing the generation of a DLT log message and sending it to the DLT daemon.
* This function has to be called after writing all the log attributes of a log message.
* @param log pointer to an object containing information about logging context data
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_finish(DltContextData *log);
/**
* DLTv2 Finishing the generation of a DLT log message and sending it to the DLT daemon.
* This function has to be called after writing all the log attributes of a log message.
* @param log pointer to an object containing information about logging context data
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_finish_v2(DltContextData *log);
/**
* Finishing the generation of a DLT log message and sending it to the DLT daemon without
* freeing log buffer. This function only works with combination of
* dlt_user_log_write_start_w_given_buffer. This function has to be called after writing all
* the log attributes of a log message.
* @param log pointer to an object containing information about logging context data
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_finish_w_given_buffer(DltContextData *log);
/**
* DLTv2 Finishing the generation of a DLT log message and sending it to the DLT daemon without
* freeing log buffer. This function only works with combination of
* dlt_user_log_write_start_w_given_buffer. This function has to be called after writing all
* the log attributes of a log message.
* @param log pointer to an object containing information about logging context data
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_finish_w_given_buffer_v2(DltContextData *log);
/**
* Write a boolean parameter into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param data boolean parameter written into log message (mapped to uint8)
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_bool(DltContextData *log, uint8_t data);
/**
* Write a boolean parameter with "name" attribute into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param data boolean parameter written into log message (mapped to uint8)
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_bool_attr(DltContextData *log, uint8_t data, const char *name);
/**
* Write a float parameter into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param data float32_t parameter written into log message.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_float32(DltContextData *log, float32_t data);
/**
* Write a double parameter into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param data float64_t parameter written into log message.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_float64(DltContextData *log, double data);
/**
* Write a float parameter with attributes into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name or @a unit is NULL, this function will add a corresponding attribute field with length 0
* and no content to the message for that attribute.
*
* @param log pointer to an object containing information about logging context data
* @param data float32_t parameter written into log message
* @param name the "name" attribute (or NULL)
* @param unit the "unit" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_float32_attr(DltContextData *log, float32_t data, const char *name, const char *unit);
/**
* Write a double parameter with attributes into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name or @a unit is NULL, this function will add a corresponding attribute field with length 0
* and no content to the message for that attribute.
*
* @param log pointer to an object containing information about logging context data
* @param data float64_t parameter written into log message
* @param name the "name" attribute (or NULL)
* @param unit the "unit" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_float64_attr(DltContextData *log, float64_t data, const char *name, const char *unit);
/**
* Write a uint parameter into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param data unsigned int parameter written into log message.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_uint(DltContextData *log, unsigned int data);
DltReturnValue dlt_user_log_write_uint8(DltContextData *log, uint8_t data);
DltReturnValue dlt_user_log_write_uint16(DltContextData *log, uint16_t data);
DltReturnValue dlt_user_log_write_uint32(DltContextData *log, uint32_t data);
DltReturnValue dlt_user_log_write_uint64(DltContextData *log, uint64_t data);
/**
* Write a uint parameter with attributes into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name or @a unit is NULL, this function will add a corresponding attribute field with length 0
* and no content to the message for that attribute.
*
* @param log pointer to an object containing information about logging context data
* @param data unsigned int parameter written into log message
* @param name the "name" attribute (or NULL)
* @param unit the "unit" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_uint_attr(DltContextData *log, unsigned int data, const char *name, const char *unit);
DltReturnValue dlt_user_log_write_uint8_attr(DltContextData *log, uint8_t data, const char *name, const char *unit);
DltReturnValue dlt_user_log_write_uint16_attr(DltContextData *log, uint16_t data, const char *name, const char *unit);
DltReturnValue dlt_user_log_write_uint32_attr(DltContextData *log, uint32_t data, const char *name, const char *unit);
DltReturnValue dlt_user_log_write_uint64_attr(DltContextData *log, uint64_t data, const char *name, const char *unit);
/**
* Write a uint parameter into a DLT log message. The output will be formatted as given by the parameter type.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param data unsigned int parameter written into log message.
* @param type The formatting type of the string output.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_uint8_formatted(DltContextData *log, uint8_t data, DltFormatType type);
DltReturnValue dlt_user_log_write_uint16_formatted(DltContextData *log, uint16_t data, DltFormatType type);
DltReturnValue dlt_user_log_write_uint32_formatted(DltContextData *log, uint32_t data, DltFormatType type);
DltReturnValue dlt_user_log_write_uint64_formatted(DltContextData *log, uint64_t data, DltFormatType type);
/**
* Write a pointer value architecture independent.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param data void* parameter written into log message.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_ptr(DltContextData *log, void *data);
/**
* Write a int parameter into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param data int parameter written into log message.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_int(DltContextData *log, int data);
DltReturnValue dlt_user_log_write_int8(DltContextData *log, int8_t data);
DltReturnValue dlt_user_log_write_int16(DltContextData *log, int16_t data);
DltReturnValue dlt_user_log_write_int32(DltContextData *log, int32_t data);
DltReturnValue dlt_user_log_write_int64(DltContextData *log, int64_t data);
/**
* Write an int parameter with attributes into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name or @a unit is NULL, this function will add a corresponding attribute field with length 0
* and no content to the message for that attribute.
*
* @param log pointer to an object containing information about logging context data
* @param data int parameter written into log message
* @param name the "name" attribute (or NULL)
* @param unit the "unit" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_int_attr(DltContextData *log, int data, const char *name, const char *unit);
DltReturnValue dlt_user_log_write_int8_attr(DltContextData *log, int8_t data, const char *name, const char *unit);
DltReturnValue dlt_user_log_write_int16_attr(DltContextData *log, int16_t data, const char *name, const char *unit);
DltReturnValue dlt_user_log_write_int32_attr(DltContextData *log, int32_t data, const char *name, const char *unit);
DltReturnValue dlt_user_log_write_int64_attr(DltContextData *log, int64_t data, const char *name, const char *unit);
/**
* Write a null terminated ASCII string into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message containing null termination.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text);
/**
* Write a potentially non-null-terminated ASCII string into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message
* @param length length in bytes of @a text (without any termination character)
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_sized_string(DltContextData *log, const char *text, uint16_t length);
/**
* Write a constant null terminated ASCII string into a DLT log message.
* In non verbose mode DLT parameter will not be sent at all.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message containing null termination.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_constant_string(DltContextData *log, const char *text);
/**
* Write a constant, potentially non-null-terminated ASCII string into a DLT log message.
* In non verbose mode DLT parameter will not be sent at all.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message
* @param length length in bytes of @a text (without any termination character)
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_sized_constant_string(DltContextData *log, const char *text, uint16_t length);
/**
* Write a null terminated UTF8 string into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message containing null termination.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *text);
/**
* Write a potentially non-null-terminated UTF8 string into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message
* @param length length in bytes of @a text (without any termination character)
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_sized_utf8_string(DltContextData *log, const char *text, uint16_t length);
/**
* Write a constant null terminated UTF8 string into a DLT log message.
* In non verbose mode DLT parameter will not be sent at all.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message containing null termination.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_constant_utf8_string(DltContextData *log, const char *text);
/**
* Write a constant, potentially non-null-terminated UTF8 string into a DLT log message.
* In non verbose mode DLT parameter will not be sent at all.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message
* @param length length in bytes of @a text (without any termination character)
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_sized_constant_utf8_string(DltContextData *log, const char *text, uint16_t length);
/**
* Write a null-terminated ASCII string with "name" attribute into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message containing null termination
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_string_attr(DltContextData *log, const char *text, const char *name);
/**
* Write a potentially non-null-terminated ASCII string with "name" attribute into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message
* @param length length in bytes of @a text (without any termination character)
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_sized_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name);
/**
* Write a constant, null-terminated ASCII string with "name" attribute into a DLT log message.
* In non-verbose mode, this parameter will not be sent at all.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message containing null termination
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_constant_string_attr(DltContextData *log, const char *text, const char *name);
/**
* Write a constant, potentially non-null-terminated ASCII string with "name" attribute into a DLT log message.
* In non-verbose mode, this parameter will not be sent at all.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message
* @param length length in bytes of @a text (without any termination character)
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_sized_constant_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name);
/**
* Write a null-terminated UTF-8 string with "name" attribute into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message containing null termination
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_utf8_string_attr(DltContextData *log, const char *text, const char *name);
/**
* Write a potentially non-null-terminated UTF-8 string with "name" attribute into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message
* @param length length in bytes of @a text (without any termination character)
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_sized_utf8_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name);
/**
* Write a constant, null-terminated UTF8 string with "name" attribute into a DLT log message.
* In non-verbose mode, this parameter will not be sent at all.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message containing null termination
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_constant_utf8_string_attr(DltContextData *log, const char *text, const char *name);
/**
* Write a constant, potentially non-null-terminated UTF8 string with "name" attribute into a DLT log message.
* In non-verbose mode, this parameter will not be sent at all.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param text pointer to the parameter written into log message
* @param length length in bytes of @a text (without any termination character)
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_sized_constant_utf8_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name);
/**
* Write a binary memory block into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param data pointer to the parameter written into log message.
* @param length length in bytes of the parameter written into log message.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_raw(DltContextData *log, void *data, uint16_t length);
/**
* Write a binary memory block into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
* @param log pointer to an object containing information about logging context data
* @param data pointer to the parameter written into log message.
* @param length length in bytes of the parameter written into log message.
* @param type the format information.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log, void *data, uint16_t length, DltFormatType type);
/**
* Write a binary memory block with "name" attribute into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param data pointer to the parameter written into log message.
* @param length length in bytes of the parameter written into log message
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_raw_attr(DltContextData *log, const void *data, uint16_t length, const char *name);
/**
* Write a binary memory block with "name" attribute into a DLT log message.
* dlt_user_log_write_start has to be called before adding any parameters to the log message.
* Finish building a log message by calling dlt_user_log_write_finish.
*
* If @a name is NULL, this function will add an attribute field with length 0
* and no content to the message.
*
* @param log pointer to an object containing information about logging context data
* @param data pointer to the parameter written into log message.
* @param length length in bytes of the parameter written into log message
* @param type the format information
* @param name the "name" attribute (or NULL)
* @return value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_write_raw_formatted_attr(DltContextData *log, const void *data, uint16_t length, DltFormatType type, const char *name);
/**
* Trace network message
* @param handle pointer to an object containing information about one special logging context
* @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)
* @param header_len length of network message header
* @param header pointer to network message header
* @param payload_len length of network message payload
* @param payload pointer to network message payload
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_trace_network(DltContext *handle,
DltNetworkTraceType nw_trace_type,
uint16_t header_len,
void *header,
uint16_t payload_len,
void *payload);
/**
* Trace network message, truncated if necessary.
* @param handle pointer to an object containing information about logging context
* @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)
* @param header_len length of network message header
* @param header pointer to network message header
* @param payload_len length of network message payload
* @param payload pointer to network message payload
* @param allow_truncate Set to > 0 to allow truncating of the message if it is too large.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_trace_network_truncated(DltContext *handle,
DltNetworkTraceType nw_trace_type,
uint16_t header_len,
void *header,
uint16_t payload_len,
void *payload,
int allow_truncate);
/**
* Trace network message in segmented asynchronous mode.
* The sending of the data is done in a separate thread.
* Please note that handle must exist for the lifetime of the application, because
* data chunks are sent asynchronously in undetermined future time.
* @param handle pointer to an object containing information about logging context
* @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)
* @param header_len length of network message header
* @param header pointer to network message header
* @param payload_len length of network message payload
* @param payload pointer to network message payload
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_trace_network_segmented(DltContext *handle,
DltNetworkTraceType nw_trace_type,
uint16_t header_len,
void *header,
uint16_t payload_len,
void *payload);
/**************************************************************************************************
* The following API functions define a high level function interface for DLT
**************************************************************************************************/
/**
* Initialize the user lib communication with daemon.
* This function has to be called first, before using any DLT user lib functions.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_init(void);
/**
* Initialize the user lib writing only to file.
* This function has to be called first, before using any DLT user lib functions.
* @param name name of an optional log file
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_init_file(const char *name);
/**
* Set maximum file size if lib is configured to write only to file.
* This function has to be called after dlt_init_file().
* @param filesize maximum file size
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_set_filesize_max(unsigned int filesize);
/**
* Terminate the user lib.
* This function has to be called when finishing using the DLT user lib.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_free(void);
/**
* Check the library version of DLT library.
* @param user_major_version the major version to be compared
* @param user_minor_version the minor version to be compared
* @return Value from DltReturnValue enum, DLT_RETURN_ERROR if there is a mismatch
*/
DltReturnValue dlt_check_library_version(const char *user_major_version, const char *user_minor_version);
/**
* Register an application in the daemon.
* @param apid four byte long character array with the application id
* @param description long name of the application
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_app(const char *apid, const char *description);
/**
* DLTv2 Register an application in the daemon.
* @param apid character pointer with the application id
* @param description long name of the application
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_app_v2(const char *apid, const char *description);
/**
* Unregister an application in the daemon.
* This function has to be called when finishing using an application.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_unregister_app(void);
/**
* DLTv2 Unregister an application in the daemon.
* This function has to be called when finishing using an application.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_unregister_app_v2(void);
/**
* Unregister an application in the daemon and also flushes the buffered logs.
* This function has to be called when finishing using an application.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_unregister_app_flush_buffered_logs(void);
/**
* DLTv2 Unregister an application in the daemon and also flushes the buffered logs.
* This function has to be called when finishing using an application.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_unregister_app_flush_buffered_logs_v2(void);
/**
* Get the application id
* @param appid four byte long character array to store the application id
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_get_appid(char *appid);
/**
* DLTv2 Get the application id
* @param appid pointer to character pointer to store the application id
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_get_appid_v2(char **appid);
/**
* Register a context in the daemon.
* This function has to be called before first usage of the context.
* @param handle pointer to an object containing information about one special logging context
* @param contextid four byte long character array with the context id
* @param description long name of the context
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, const char *description);
/**
* DLTv2 Register a context in the daemon.
* This function has to be called before first usage of the context.
* @param handle pointer to an object containing information about one special logging context
* @param contextid character pointer with the context id
* @param description long name of the context
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_context_v2(DltContext *handle, const char *contextid, const char *description);
/**
* Register a context in the daemon with pre-defined log level and pre-defined trace status.
* This function has to be called before first usage of the context.
* @param handle pointer to an object containing information about one special logging context
* @param contextid four byte long character array with the context id
* @param description long name of the context
* @param loglevel This is the log level to be pre-set for this context
* (DLT_LOG_DEFAULT is not allowed here)
* @param tracestatus This is the trace status to be pre-set for this context
* (DLT_TRACE_STATUS_DEFAULT is not allowed here)
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_context_ll_ts(DltContext *handle,
const char *contextid,
const char *description,
int loglevel,
int tracestatus);
/**
* DLTv2 Register a context in the daemon with pre-defined log level and pre-defined trace status.
* This function has to be called before first usage of the context.
* @param handle pointer to an object containing information about one special logging context
* @param contextid character pointer with the context id
* @param description long name of the context
* @param loglevel This is the log level to be pre-set for this context
* (DLT_LOG_DEFAULT is not allowed here)
* @param tracestatus This is the trace status to be pre-set for this context
* (DLT_TRACE_STATUS_DEFAULT is not allowed here)
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_context_ll_ts_v2(DltContext *handle,
const char *contextid,
const char *description,
int loglevel,
int tracestatus);
/**
* Register a context in the daemon with log level changed callback fn.
* This function is introduced to avoid missing of LL change callback during registration
* @param handle pointer to an object containing information about one special logging context
* @param contextid four byte long character array with the context id
* @param description long name of the context
* @param *dlt_log_level_changed_callback This is the fn which will be called when log level is changed
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_context_llccb(DltContext *handle,
const char *contextid,
const char *description,
void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],
uint8_t log_level,
uint8_t trace_status));
/**
* DLTv2 Register a context in the daemon with log level changed callback fn.
* This function is introduced to avoid missing of LL change callback during registration
* @param handle pointer to an object containing information about one special logging context
* @param contextid character pointer with the context id
* @param description long name of the context
* @param *dlt_log_level_changed_callback This is the fn which will be called when log level is changed
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_context_llccb_v2(DltContext *handle,
const char *contextid,
const char *description,
void (*dlt_log_level_changed_callback_v2)(char *context_id,
uint8_t log_level,
uint8_t trace_status));
/**
* Unregister a context in the DLT daemon.
* This function has to be called when finishing using a context.
* @param handle pointer to an object containing information about one special logging context
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_unregister_context(DltContext *handle);
/**
* DLTv2 Unregister a context of in the DLT daemon.
* This function has to be called when finishing using a context.
* @param handle pointer to an object containing information about one special logging context
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_unregister_context_v2(DltContext *handle);
/**
* Set maximum timeout for re-sending at exit
* @param timeout_in_milliseconds maximum time to wait until giving up re-sending, default 10000 (equals to 10 seconds)
*/
int dlt_set_resend_timeout_atexit(uint32_t timeout_in_milliseconds);
/**
* Set the logging mode used by the daemon.
* The logging mode is stored persistantly by the daemon.
* @see DltUserLogMode
* @param mode the new logging mode used by the daemon: off, extern, internal, both.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_set_log_mode(DltUserLogMode mode);
/**
* DLTv2 Set the logging mode used by the daemon.
* The logging mode is stored persistantly by the daemon.
* @see DltUserLogMode
* @param mode the new logging mode used by the daemon: off, extern, internal, both.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_set_log_mode_v2(DltUserLogMode mode);
/**
* Get the state of the connected client to the daemon.
* The user application gets a message, when client is connected or disconnected.
* This value contains the last state.
* It needs some time until the application gets state from the daemon.
* Until then the state is "unknown state".
* @return -1 = unknown state, 0 = client not connected, 1 = client connected
*/
int dlt_get_log_state(void);
/**
* Register callback function called when injection message was received
* @param handle pointer to an object containing information about one special logging context
* @param service_id the service id to be waited for
* @param (*dlt_injection_callback) function pointer to callback function
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t service_id,
int (*dlt_injection_callback)(uint32_t service_id,
void *data,
uint32_t length));
/**
* Register callback function with private data called when injection message was received
* @param handle pointer to an object containing information about one special logging context
* @param service_id the service id to be waited for
* @param (*dlt_injection_callback) function pointer to callback function
* @param priv private data
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint32_t service_id,
int (*dlt_injection_callback)(uint32_t service_id,
void *data,
uint32_t length,
void *priv_data), void *priv);
/**
* Register callback function called when log level of context was changed
* @param handle pointer to an object containing information about one special logging context
* @param (*dlt_log_level_changed_callback) function pointer to callback function
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_log_level_changed_callback(DltContext *handle,
void (*dlt_log_level_changed_callback)(
char context_id[DLT_ID_SIZE],
uint8_t log_level,
uint8_t trace_status));
/**
* DLTv2 Register callback function called when log level of context was changed
* @param handle pointer to an object containing information about one special logging context
* @param (*dlt_log_level_changed_callback) function pointer to callback function
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_register_log_level_changed_callback_v2(DltContext *handle,
void (*dlt_log_level_changed_callback_v2)(
char *context_id,
uint8_t log_level,
uint8_t trace_status));
/**
* Switch to verbose mode
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_verbose_mode(void);
/**
* Check the version of dlt library with library version used of the application.
* @param user_major_version version number of application - see dlt_version.h
* @param user_minor_version version number of application - see dlt_version.h
* @return Value from DltReturnValue enum, DLT_RETURN_ERROR if there is a mismatch
*/
DltReturnValue dlt_user_check_library_version(const char *user_major_version, const char *user_minor_version);
/**
* Switch to non-verbose mode
*
* This does not force all messages to be sent as Non-Verbose ones, as that does not make much sense.
* Instead, it +allows+ the sending of both Verbose and Non-Verbose messages, depending on which APIs
* are being called.
*/
DltReturnValue dlt_nonverbose_mode(void);
/**
* Use extended header in non verbose mode.
* Enabled by default.
* @param use_extended_header_for_non_verbose Use extended header for non verbose mode if true
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_use_extended_header_for_non_verbose(int8_t use_extended_header_for_non_verbose);
/**
* Send session id configuration.
* Enabled by default.
* @param with_session_id Send session id in each message if enabled
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_with_session_id(int8_t with_session_id);
/**
* Send timestamp configuration.
* Enabled by default.
* @param with_timestamp Send timestamp id in each message if enabled
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_with_timestamp(int8_t with_timestamp);
/**
* Send ecu id configuration.
* Enabled by default.
* @param with_ecu_id Send ecu id in each message if enabled
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_with_ecu_id(int8_t with_ecu_id);
/**
* Send Filename and Line number configuration.
* disabled by default.
* @param fina Send filename
* @param linr Send linenumber
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_with_filename_and_line_number(const char *fina, const int linr);
/**
* Send Filename and Line number configuration.
* disabled by default.
* @param prlv Send privacy level
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_with_prlv(uint8_t prlv);
/**
* Send Filename and Line number configuration.
* disabled by default.
* @param firstTag list of tags
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_with_tags(const char *firstTag, ...);
/**
* Set maximum logged log level and trace status of application
*
* @param loglevel This is the log level to be set for the whole application
* @param tracestatus This is the trace status to be set for the whole application
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_set_application_ll_ts_limit(DltLogLevelType loglevel, DltTraceStatusType tracestatus);
/**
* @brief adjust log-level based on values given through environment
*
* Iterate over the set of items, and find the best match.
* For any item that matches, the one with the highest priority is selected and that
* log-level is returned.
*
* Priorities are determined as follows:
* - no apid, no ctid only ll given in item: use ll with prio 1
* - no apid, ctid matches: use ll with prio 2
* - no ctid, apid matches: use ll with prio 3
* - apid, ctid matches: use ll with prio 4
*
* @param ll_set
* @param apid
* @param ctid
* @param ll
* If no item matches or in case of error, the original log-level (\param ll) is returned
*/
int dlt_env_adjust_ll_from_env(dlt_env_ll_set const *const ll_set,
char const *const apid,
char const *const ctid,
int const ll);
/**
* @brief adjust log-level based on values given through environment
* DLTv2
* Iterate over the set of items, and find the best match.
* For any item that matches, the one with the highest priority is selected and that
* log-level is returned.
*
* Priorities are determined as follows:
* - no apid, no ctid only ll given in item: use ll with prio 1
* - no apid, ctid matches: use ll with prio 2
* - no ctid, apid matches: use ll with prio 3
* - apid, ctid matches: use ll with prio 4
*
* @param ll_set
* @param apid
* @param ctid
* @param ll
* If no item matches or in case of error, the original log-level (\param ll) is returned
*/
int dlt_env_adjust_ll_from_env_v2(dlt_env_ll_set const *const ll_set,
char const *const apid,
uint8_t apidlen,
char const *const ctid,
uint8_t ctidlen,
int const ll);
/**
* @brief extract log-level settings from given string
*
* Scan \param env for setttings like apid:ctid:log-level and store them
* in given \param ll_set
*
* @param env reference to a string to be parsed, after parsing env will point after the last parse character
* @param ll_set set of log-level extracted from given string
*
* @return 0 on success
* @return -1 on failure
*/
int dlt_env_extract_ll_set(char **const env, dlt_env_ll_set *const ll_set);
void dlt_env_free_ll_set(dlt_env_ll_set *const ll_set);
/**
* Enable local printing of messages
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_enable_local_print(void);
/**
* Disable local printing of messages
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_disable_local_print(void);
/**
* Write a null terminated ASCII string into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param text pointer to the ASCII string written into log message containing null termination.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_string(DltContext *handle, DltLogLevelType loglevel, const char *text);
/**
* DLTv2 Write a null terminated ASCII string into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param text pointer to the ASCII string written into log message containing null termination.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_string_v2(DltContext *handle, DltLogLevelType loglevel, const char *text);
/**
* Write a null terminated ASCII string and an integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param text pointer to the ASCII string written into log message containing null termination.
* @param data integer value written into the log message
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_string_int(DltContext *handle, DltLogLevelType loglevel, const char *text, int data);
/**
* DLTv2 Write a null terminated ASCII string and an integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param text pointer to the ASCII string written into log message containing null termination.
* @param data integer value written into the log message
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_string_int_v2(DltContext *handle, DltLogLevelType loglevel, const char *text, int data);
/**
* Write a null terminated ASCII string and an unsigned integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param text pointer to the ASCII string written into log message containing null termination.
* @param data unsigned integer value written into the log message
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_string_uint(DltContext *handle, DltLogLevelType loglevel, const char *text, unsigned int data);
/**
* DLTv2 Write a null terminated ASCII string and an unsigned integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param text pointer to the ASCII string written into log message containing null termination.
* @param data unsigned integer value written into the log message
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_string_uint_v2(DltContext *handle, DltLogLevelType loglevel, const char *text, unsigned int data);
/**
* Write an integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param data integer value written into the log message
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_int(DltContext *handle, DltLogLevelType loglevel, int data);
/**
* DLTv2 Write an integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param data integer value written into the log message
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_int_v2(DltContext *handle, DltLogLevelType loglevel, int data);
/**
* Write an unsigned integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param data unsigned integer value written into the log message
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_uint(DltContext *handle, DltLogLevelType loglevel, unsigned int data);
/**
* DLTv2 Write an unsigned integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param data unsigned integer value written into the log message
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_uint_v2(DltContext *handle, DltLogLevelType loglevel, unsigned int data);
/**
* Write an unsigned integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param data pointer to the parameter written into log message.
* @param length length in bytes of the parameter written into log message.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_raw(DltContext *handle, DltLogLevelType loglevel, void *data, uint16_t length);
/**
* DLTv2 Write an unsigned integer value into a DLT log message.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @param data pointer to the parameter written into log message.
* @param length length in bytes of the parameter written into log message.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_raw_v2(DltContext *handle, DltLogLevelType loglevel, void *data, uint16_t length);
/**
* Write marker message to DLT.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_log_marker(void);
/**
* Get the total size and available size of the shared memory buffer between daemon and applications.
* This information is useful to control the flow control between applications and daemon.
* For example only 50% of the buffer should be used for file transfer.
* @param total_size total size of buffer in bytes
* @param used_size used size of buffer in bytes
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_check_buffer(int *total_size, int *used_size);
/**
* Try to resend log message in the user buffer. Stops if the dlt_uptime is bigger than
* dlt_uptime() + DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT. A pause between the resending
* attempts can be defined with DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP
* @return number of messages in the user buffer
*/
int dlt_user_atexit_blow_out_user_buffer(void);
/**
* Try to resend log message in the user buffer.
* @return Value from DltReturnValue enum
*/
DltReturnValue dlt_user_log_resend_buffer(void);
/**
* Checks the log level passed by the log function if enabled for that context or not.
* This function can be called by applications before generating their logs.
* Also called before writing new log messages.
* @param handle pointer to an object containing information about one special logging context
* @param loglevel this is the current log level of the log message to be sent
* @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is enabled
*/
DltReturnValue dlt_user_is_logLevel_enabled(DltContext *handle, DltLogLevelType loglevel);
# ifdef DLT_TEST_ENABLE
void dlt_user_test_corrupt_user_header(int enable);
void dlt_user_test_corrupt_message_size(int enable, int16_t size);
# endif /* DLT_TEST_ENABLE */
# ifdef __cplusplus
}
# endif
/**
\}
*/
#endif /* DLT_USER_H */
|