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
|
/*
* 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_macros.h
*/
/*******************************************************************************
** **
** SRC-MODULE: dlt_user_macros.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: 1515 $
* $LastChangedDate: 2010-12-13 09:18:54 +0100 (Mon, 13 Dec 2010) $
* $LastChangedBy$
* Initials Date Comment
* aw 13.01.2010 initial
*/
#ifndef DLT_USER_MACROS_H
#define DLT_USER_MACROS_H
#include "dlt_version.h"
#include "dlt_types.h"
#include <stdbool.h>
/**
* \defgroup userapi DLT User API
* \addtogroup userapi
\{
*/
/**************************************************************************************************
* The folowing macros define a macro interface for DLT
**************************************************************************************************/
/**
* Create an object for a new context.
* This macro has to be called first for every.
* @param CONTEXT object containing information about one special logging context
* @note To avoid the MISRA warning "Null statement is located close to other code or comments"
* remove the semicolon when using the macro.
* Example: DLT_DECLARE_CONTEXT(hContext)
*/
#define DLT_DECLARE_CONTEXT(CONTEXT) \
DltContext CONTEXT;
/**
* Use an object of a new context created in another module.
* This macro has to be called first for every.
* @param CONTEXT object containing information about one special logging context
* @note To avoid the MISRA warning "Null statement is located close to other code or comments"
* remove the semicolon when using the macro.
* Example: DLT_IMPORT_CONTEXT(hContext)
*/
#define DLT_IMPORT_CONTEXT(CONTEXT) \
extern DltContext CONTEXT;
/**
* Register application.
* @param APPID application id with maximal four characters
* @param DESCRIPTION ASCII string containing description
*/
#define DLT_REGISTER_APP(APPID, DESCRIPTION) do { \
(void)dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION); \
(void)dlt_register_app(APPID, DESCRIPTION); } while(false)
/**
* DLTv2 Register application.
* @param APPID application id
* @param DESCRIPTION ASCII string containing description
*/
#define DLT_REGISTER_APP_V2(APPID, DESCRIPTION) do { \
(void)dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION); \
(void)dlt_register_app_v2(APPID, DESCRIPTION); } while(false)
/**
* Unregister application.
*/
#define DLT_UNREGISTER_APP() do { \
(void)dlt_unregister_app(); } while(false)
/**
* DLTv2 Unregister application.
*/
#define DLT_UNREGISTER_APP_V2() do { \
(void)dlt_unregister_app_v2(); } while(false)
/**
* Unregister application and flush the logs buffered in startup buffer if any.
*/
#define DLT_UNREGISTER_APP_FLUSH_BUFFERED_LOGS() do { \
(void)dlt_unregister_app_flush_buffered_logs(); } while(false)
/**
* DLTv2 Unregister application and flush the logs buffered in startup buffer if any.
*/
#define DLT_UNREGISTER_APP_FLUSH_BUFFERED_LOGS_V2() do { \
(void)dlt_unregister_app_flush_buffered_logs_v2(); } while(false)
/**
* To Get application ID.
* @Param APPID character pointer of minimum 4 bytes
*/
#define DLT_GET_APPID(APPID) do{\
dlt_get_appid(APPID);} while(false)
/**
* DLTv2 To Get application ID.
* @Param APPID character pointer
*/
#define DLT_GET_APPID_V2(APPID) do{\
dlt_get_appid_v2(&APPID);} while(false)
/**
* Register context (with default log level and default trace status)
* @param CONTEXT object containing information about one special logging context
* @param CONTEXTID context id with maximal four characters
* @param DESCRIPTION ASCII string containing description
*/
#define DLT_REGISTER_CONTEXT(CONTEXT, CONTEXTID, DESCRIPTION) do { \
(void)dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION); } while (false)
/**
* DLTv2 Register context (with default log level and default trace status)
* @param CONTEXT object containing information about one special logging context
* @param CONTEXTID context id
* @param DESCRIPTION ASCII string containing description
*/
#define DLT_REGISTER_CONTEXT_V2(CONTEXT, CONTEXTID, DESCRIPTION) do { \
(void)dlt_register_context_v2(&(CONTEXT), CONTEXTID, DESCRIPTION); } while (false)
/**
* Register context with pre-defined log level and pre-defined trace status.
* @param CONTEXT object containing information about one special logging context
* @param CONTEXTID context id with maximal four characters
* @param DESCRIPTION ASCII string containing description
* @param LOGLEVEL log level to be pre-set for this context
* (DLT_LOG_DEFAULT is not allowed here)
* @param TRACESTATUS trace status to be pre-set for this context
* (DLT_TRACE_STATUS_DEFAULT is not allowed here)
*/
#define DLT_REGISTER_CONTEXT_LL_TS(CONTEXT, CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS) do { \
(void)dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS); } while (false)
/**
* DLTv2 Register context with pre-defined log level and pre-defined trace status.
* @param CONTEXT object containing information about one special logging context
* @param CONTEXTID context id
* @param DESCRIPTION ASCII string containing description
* @param LOGLEVEL log level to be pre-set for this context
* (DLT_LOG_DEFAULT is not allowed here)
* @param TRACESTATUS trace status to be pre-set for this context
* (DLT_TRACE_STATUS_DEFAULT is not allowed here)
*/
#define DLT_REGISTER_CONTEXT_LL_TS_V2(CONTEXT, CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS) do { \
(void)dlt_register_context_ll_ts_v2(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS); } while (false)
/**
* Register context (with default log level and default trace status and log level change callback)
* @param CONTEXT object containing information about one special logging context
* @param CONTEXTID context id with maximal four characters
* @param DESCRIPTION ASCII string containing description
* @param CBK log level change callback to be registered
*/
#define DLT_REGISTER_CONTEXT_LLCCB(CONTEXT, CONTEXTID, DESCRIPTION, CBK) do { \
(void)dlt_register_context_llccb(&(CONTEXT), CONTEXTID, DESCRIPTION, CBK); } while(false)
/**
* DLTv2 Register context (with default log level and default trace status and log level change callback)
* @param CONTEXT object containing information about one special logging context
* @param CONTEXTID context id
* @param DESCRIPTION ASCII string containing description
* @param CBK log level change callback to be registered
*/
#define DLT_REGISTER_CONTEXT_LLCCB_V2(CONTEXT, CONTEXTID, DESCRIPTION, CBK) do { \
(void)dlt_register_context_llccb_v2(&(CONTEXT), CONTEXTID, DESCRIPTION, CBK); } while(false)
/**
* Unregister context.
* @param CONTEXT object containing information about one special logging context
*/
#define DLT_UNREGISTER_CONTEXT(CONTEXT) do { \
(void)dlt_unregister_context(&(CONTEXT)); } while(false)
/**
* DLTv2 Unregister context.
* @param CONTEXT object containing information about one special logging context
*/
#define DLT_UNREGISTER_CONTEXT_V2(CONTEXT) do { \
(void)dlt_unregister_context_v2(&(CONTEXT)); } while(false)
/**
* Register callback function called when injection message was received
* @param CONTEXT object containing information about one special logging context
* @param SERVICEID service id of the injection message
* @param CALLBACK function pointer to callback function
*/
#define DLT_REGISTER_INJECTION_CALLBACK(CONTEXT, SERVICEID, CALLBACK) do { \
(void)dlt_register_injection_callback(&(CONTEXT), SERVICEID, CALLBACK); } while(false)
/**
* Register callback function called when injection message was received
* @param CONTEXT object containing information about one special logging context
* @param SERVICEID service id of the injection message
* @param CALLBACK function pointer to callback function
* @param PRIV_DATA data specific to context
*/
#define DLT_REGISTER_INJECTION_CALLBACK_WITH_ID(CONTEXT, SERVICEID, CALLBACK, PRIV_DATA) do { \
(void)dlt_register_injection_callback_with_id(&(CONTEXT), SERVICEID, CALLBACK, PRIV_DATA); } while(false)
/**
* Register callback function called when log level of context was changed
* @param CONTEXT object containing information about one special logging context
* @param CALLBACK function pointer to callback function
*/
#define DLT_REGISTER_LOG_LEVEL_CHANGED_CALLBACK(CONTEXT, CALLBACK) do { \
(void)dlt_register_log_level_changed_callback(&(CONTEXT), CALLBACK); } while(false)
/**
* DLTv2 Register callback function called when log level of context was changed
* @param CONTEXT object containing information about one special logging context
* @param CALLBACK function pointer to callback function
*/
#define DLT_REGISTER_LOG_LEVEL_CHANGED_CALLBACK_V2(CONTEXT, CALLBACK) do { \
(void)dlt_register_log_level_changed_callback_v2(&(CONTEXT), CALLBACK); } while(false)
/**
* Send log message with variable list of messages (intended for verbose mode)
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param ... variable list of arguments
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
* use a semicolon instead of a comma to separate the __VA_ARGS__.
* Example: DLT_LOG(hContext, DLT_LOG_INFO, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
/* DLT_LOG is not supported by MS Visual C++ */
/* use function interface instead */
#else
# define DLT_LOG(CONTEXT, LOGLEVEL, ...) \
do { \
DltContextData log_local; \
int dlt_local; \
dlt_local = dlt_user_log_write_start(&CONTEXT, &log_local, LOGLEVEL); \
if (dlt_local == DLT_RETURN_TRUE) \
{ \
__VA_ARGS__; \
(void)dlt_user_log_write_finish(&log_local); \
} \
} while (false)
#endif
/**
* DLTv2 Send log message with variable list of messages (intended for verbose mode)
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param ... variable list of arguments
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
* use a semicolon instead of a comma to separate the __VA_ARGS__.
* Example: DLT_LOG(hContext, DLT_LOG_INFO, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
/* DLT_LOG_V2 is not supported by MS Visual C++ */
/* use function interface instead */
#else
# define DLT_LOG_V2(CONTEXT, LOGLEVEL, ...) \
do { \
DltContextData log_local; \
int dlt_local; \
dlt_local = dlt_user_log_write_start(&CONTEXT, &log_local, LOGLEVEL); \
if (dlt_local == DLT_RETURN_TRUE) \
{ \
__VA_ARGS__; \
(void)dlt_user_log_write_finish_v2(&log_local); \
} \
} while (false)
#endif
/**
* Send log message with variable list of messages (intended for verbose mode)
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param TS timestamp to be used for log message
* @param ... variable list of arguments
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
* use a semicolon instead of a comma to separate the __VA_ARGS__.
* Example: DLT_LOG_TS(hContext, DLT_LOG_INFO, timestamp, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
/* DLT_LOG_TS is not supported by MS Visual C++ */
/* use function interface instead */
#else
# define DLT_LOG_TS(CONTEXT, LOGLEVEL, TS, ...) \
do { \
DltContextData log_local; \
int dlt_local; \
dlt_local = dlt_user_log_write_start(&CONTEXT, &log_local, LOGLEVEL); \
if (dlt_local == DLT_RETURN_TRUE) \
{ \
__VA_ARGS__; \
log_local.use_timestamp = DLT_USER_TIMESTAMP; \
log_local.user_timestamp = (uint32_t) TS; \
(void)dlt_user_log_write_finish(&log_local); \
} \
} while (false)
#endif
/**
* Send log message with variable list of messages (intended for non-verbose mode)
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param MSGID the message id of log message
* @param ... variable list of arguments
* calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
* DLT_INT(), DLT_UINT(), DLT_RAW()
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
* use a semicolon instead of a comma to separate the __VA_ARGS__.
* Example: DLT_LOG_ID(hContext, DLT_LOG_INFO, 0x1234, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
/* DLT_LOG_ID is not supported by MS Visual C++ */
/* use function interface instead */
#else
# define DLT_LOG_ID(CONTEXT, LOGLEVEL, MSGID, ...) \
do { \
DltContextData log_local; \
int dlt_local; \
dlt_local = dlt_user_log_write_start_id(&CONTEXT, &log_local, LOGLEVEL, MSGID); \
if (dlt_local == DLT_RETURN_TRUE) \
{ \
__VA_ARGS__; \
(void)dlt_user_log_write_finish(&log_local); \
} \
} while(false)
#endif
/**
* Send log message with variable list of messages (intended for non-verbose mode)
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param MSGID the message id of log message
* @param TS timestamp to be used for log message
* @param ... variable list of arguments
* calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
* DLT_INT(), DLT_UINT(), DLT_RAW()
* @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
* use a semicolon instead of a comma to separate the __VA_ARGS__.
* Example: DLT_LOG_ID_TS(hContext, DLT_LOG_INFO, 0x1234, timestamp, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
/* DLT_LOG_ID_TS is not supported by MS Visual C++ */
/* use function interface instead */
#else
# define DLT_LOG_ID_TS(CONTEXT, LOGLEVEL, MSGID, TS, ...) \
do { \
DltContextData log_local; \
int dlt_local; \
dlt_local = dlt_user_log_write_start_id(&CONTEXT, &log_local, LOGLEVEL, MSGID); \
if (dlt_local == DLT_RETURN_TRUE) \
{ \
__VA_ARGS__; \
log_local.use_timestamp = DLT_USER_TIMESTAMP; \
log_local.user_timestamp = (uint32_t) TS; \
(void)dlt_user_log_write_finish(&log_local); \
} \
} while(false)
#endif
/**
* Send log with filename and line number
* @param FILENAME filename string
* @param LINR int line number
*/
#define DLT_WITH_FILENAME_LINENUMBER(FILENAME, LINR) \
(void)dlt_with_filename_and_line_number(FILENAME, LINR)
/**
* Send log with tags
* @param Tag list of string tags, minimum 1 tag to be provided
*/
#define DLT_WITH_TAGS(TAG, ...) \
(void)dlt_with_tags(TAG, __VA_ARGS__, NULL)
/**
* Send privacy level in logs
* @param prlv uint privacy level
*/
#define DLT_WITH_PRIVACYLEVEL(PRLV) \
(void)dlt_with_prlv(PRLV)
/**
* Add string parameter to the log messsage.
* @param TEXT ASCII string
*/
#define DLT_STRING(TEXT) \
(void)dlt_user_log_write_string(&log_local, TEXT)
/**
* Add string parameter with given length to the log messsage.
* The string in @a TEXT does not need to be null-terminated, but
* the copied string will be null-terminated at its destination
* in the message buffer.
* @param TEXT ASCII string
* @param LEN length in bytes to take from @a TEXT
*/
#define DLT_SIZED_STRING(TEXT, LEN) \
(void)dlt_user_log_write_sized_string(&log_local, TEXT, LEN)
/**
* Add constant string parameter to the log messsage.
* @param TEXT Constant ASCII string
*/
#define DLT_CSTRING(TEXT) \
(void)dlt_user_log_write_constant_string(&log_local, TEXT)
/**
* Add constant string parameter with given length to the log messsage.
* The string in @a TEXT does not need to be null-terminated, but
* the copied string will be null-terminated at its destination
* in the message buffer.
* @param TEXT Constant ASCII string
* @param LEN length in bytes to take from @a TEXT
*/
#define DLT_SIZED_CSTRING(TEXT, LEN) \
(void)dlt_user_log_write_sized_constant_string(&log_local, TEXT, LEN)
/**
* Add utf8-encoded string parameter to the log messsage.
* @param TEXT UTF8-encoded string
*/
#define DLT_UTF8(TEXT) \
(void)dlt_user_log_write_utf8_string(&log_local, TEXT)
/**
* Add utf8-encoded string parameter with given length to the log messsage.
* The string in @a TEXT does not need to be null-terminated, but
* the copied string will be null-terminated at its destination
* in the message buffer.
* @param TEXT UTF8-encoded string
* @param LEN length in bytes to take from @a TEXT
*/
#define DLT_SIZED_UTF8(TEXT, LEN) \
(void)dlt_user_log_write_sized_utf8_string(&log_local, TEXT, LEN)
/**
* Add constant utf8-encoded string parameter to the log messsage.
* @param TEXT Constant UTF8-encoded string
*/
#define DLT_CUTF8(TEXT) \
(void)dlt_user_log_write_constant_utf8_string(&log_local, TEXT)
/**
* Add constant utf8-encoded string parameter with given length to the log messsage.
* The string in @a TEXT does not need to be null-terminated, but
* the copied string will be null-terminated at its destination
* in the message buffer.
* @param TEXT Constant UTF8-encoded string
* @param LEN length in bytes to take from @a TEXT
*/
#define DLT_SIZED_CUTF8(TEXT, LEN) \
(void)dlt_user_log_write_sized_constant_utf8_string(&log_local, TEXT, LEN)
/**
* Add string parameter with "name" attribute to the log messsage.
* @param TEXT ASCII string
* @param NAME "name" attribute
*/
#define DLT_STRING_ATTR(TEXT, NAME) \
(void)dlt_user_log_write_string_attr(&log_local, TEXT, NAME)
/**
* Add string parameter with given length and "name" attribute to the log messsage.
* The string in @a TEXT does not need to be null-terminated, but
* the copied string will be null-terminated at its destination
* in the message buffer.
* @param TEXT ASCII string
* @param LEN length in bytes to take from @a TEXT
* @param NAME "name" attribute
*/
#define DLT_SIZED_STRING_ATTR(TEXT, LEN, NAME) \
(void)dlt_user_log_write_sized_string_attr(&log_local, TEXT, LEN, NAME)
/**
* Add constant string parameter with "name" attribute to the log messsage.
* @param TEXT Constant ASCII string
* @param NAME "name" attribute
*/
#define DLT_CSTRING_ATTR(TEXT, NAME) \
(void)dlt_user_log_write_constant_string_attr(&log_local, TEXT, NAME)
/**
* Add constant string parameter with given length and "name" attribute to the log messsage.
* The string in @a TEXT does not need to be null-terminated, but
* the copied string will be null-terminated at its destination
* in the message buffer.
* @param TEXT Constant ASCII string
* @param LEN length in bytes to take from @a TEXT
* @param NAME "name" attribute
*/
#define DLT_SIZED_CSTRING_ATTR(TEXT, LEN, NAME) \
(void)dlt_user_log_write_sized_constant_string_attr(&log_local, TEXT, LEN, NAME)
/**
* Add utf8-encoded string parameter with "name" attribute to the log messsage.
* @param TEXT UTF8-encoded string
* @param NAME "name" attribute
*/
#define DLT_UTF8_ATTR(TEXT, NAME) \
(void)dlt_user_log_write_utf8_string_attr(&log_local, TEXT, NAME)
/**
* Add utf8-encoded string parameter with given length and "name" attribute to the log messsage.
* The string in @a TEXT does not need to be null-terminated, but
* the copied string will be null-terminated at its destination
* in the message buffer.
* @param TEXT UTF8-encoded string
* @param LEN length in bytes to take from @a TEXT
* @param NAME "name" attribute
*/
#define DLT_SIZED_UTF8_ATTR(TEXT, LEN, NAME) \
(void)dlt_user_log_write_sized_utf8_string_attr(&log_local, TEXT, LEN, ATTR)
/**
* Add constant utf8-encoded string parameter with "name" attribute to the log messsage.
* @param TEXT Constant UTF8-encoded string
* @param NAME "name" attribute
*/
#define DLT_CUTF8_ATTR(TEXT, NAME) \
(void)dlt_user_log_write_constant_utf8_string_attr(&log_local, TEXT, NAME)
/**
* Add constant utf8-encoded string parameter with given length and "name" attribute to the log messsage.
* The string in @a TEXT does not need to be null-terminated, but
* the copied string will be null-terminated at its destination
* in the message buffer.
* @param TEXT Constant UTF8-encoded string
* @param LEN length in bytes to take from @a TEXT
* @param NAME "name" attribute
*/
#define DLT_SIZED_CUTF8_ATTR(TEXT, LEN, NAME) \
(void)dlt_user_log_write_sized_constant_utf8_string_attr(&log_local, TEXT, LEN, NAME)
/**
* Add boolean parameter to the log messsage.
* @param BOOL_VAR Boolean value (mapped to uint8)
*/
#define DLT_BOOL(BOOL_VAR) \
(void)dlt_user_log_write_bool(&log_local, BOOL_VAR)
/**
* Add boolean parameter with "name" attribute to the log messsage.
* @param BOOL_VAR Boolean value (mapped to uint8)
* @param NAME "name" attribute
*/
#define DLT_BOOL_ATTR(BOOL_VAR, NAME) \
(void)dlt_user_log_write_bool_attr(&log_local, BOOL_VAR, NAME)
/**
* Add float32 parameter to the log messsage.
* @param FLOAT32_VAR Float32 value (mapped to float)
*/
#define DLT_FLOAT32(FLOAT32_VAR) \
(void)dlt_user_log_write_float32(&log_local, FLOAT32_VAR)
/**
* Add float64 parameter to the log messsage.
* @param FLOAT64_VAR Float64 value (mapped to double)
*/
#define DLT_FLOAT64(FLOAT64_VAR) \
(void)dlt_user_log_write_float64(&log_local, FLOAT64_VAR)
/**
* Add float32 parameter with attributes to the log messsage.
* @param FLOAT32_VAR Float32 value (mapped to float)
* @param NAME "name" attribute
* @param UNIT "unit" attribute
*/
#define DLT_FLOAT32_ATTR(FLOAT32_VAR, NAME, UNIT) \
(void)dlt_user_log_write_float32_attr(&log_local, FLOAT32_VAR, NAME, UNIT)
/**
* Add float64 parameter with attributes to the log messsage.
* @param FLOAT64_VAR Float64 value (mapped to double)
* @param NAME "name" attribute
* @param UNIT "unit" attribute
*/
#define DLT_FLOAT64_ATTR(FLOAT64_VAR, NAME, UNIT) \
(void)dlt_user_log_write_float64_attr(&log_local, FLOAT64_VAR, NAME, UNIT)
/**
* Add integer parameter to the log messsage.
* @param INT_VAR integer value
*/
#define DLT_INT(INT_VAR) \
(void)dlt_user_log_write_int(&log_local, INT_VAR)
#define DLT_INT8(INT_VAR) \
(void)dlt_user_log_write_int8(&log_local, INT_VAR)
#define DLT_INT16(INT_VAR) \
(void)dlt_user_log_write_int16(&log_local, INT_VAR)
#define DLT_INT32(INT_VAR) \
(void)dlt_user_log_write_int32(&log_local, INT_VAR)
#define DLT_INT64(INT_VAR) \
(void)dlt_user_log_write_int64(&log_local, INT_VAR)
/**
* Add integer parameter with attributes to the log messsage.
* @param INT_VAR integer value
* @param NAME "name" attribute
* @param UNIT "unit" attribute
*/
#define DLT_INT_ATTR(INT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_int_attr(&log_local, INT_VAR, NAME, UNIT)
#define DLT_INT8_ATTR(INT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_int8_attr(&log_local, INT_VAR, NAME, UNIT)
#define DLT_INT16_ATTR(INT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_int16_attr(&log_local, INT_VAR, NAME, UNIT)
#define DLT_INT32_ATTR(INT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_int32_attr(&log_local, INT_VAR, NAME, UNIT)
#define DLT_INT64_ATTR(INT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_int64_attr(&log_local, INT_VAR, NAME, UNIT)
/**
* Add unsigned integer parameter to the log messsage.
* @param UINT_VAR unsigned integer value
*/
#define DLT_UINT(UINT_VAR) \
(void)dlt_user_log_write_uint(&log_local, UINT_VAR)
#define DLT_UINT8(UINT_VAR) \
(void)dlt_user_log_write_uint8(&log_local, UINT_VAR)
#define DLT_UINT16(UINT_VAR) \
(void)dlt_user_log_write_uint16(&log_local, UINT_VAR)
#define DLT_UINT32(UINT_VAR) \
(void)dlt_user_log_write_uint32(&log_local, UINT_VAR)
#define DLT_UINT64(UINT_VAR) \
(void)dlt_user_log_write_uint64(&log_local, UINT_VAR)
/**
* Add unsigned integer parameter with attributes to the log messsage.
* @param UINT_VAR unsigned integer value
* @param NAME "name" attribute
* @param UNIT "unit" attribute
*/
#define DLT_UINT_ATTR(UINT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_uint_attr(&log_local, UINT_VAR, NAME, UNIT)
#define DLT_UINT8_ATTR(UINT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_uint8_attr(&log_local, UINT_VAR, NAME, UNIT)
#define DLT_UINT16_ATTR(UINT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_uint16_attr(&log_local, UINT_VAR, NAME, UNIT)
#define DLT_UINT32_ATTR(UINT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_uint32_attr(&log_local, UINT_VAR, NAME, UNIT)
#define DLT_UINT64_ATTR(UINT_VAR, NAME, UNIT) \
(void)dlt_user_log_write_uint64_attr(&log_local, UINT_VAR, NAME, UNIT)
/**
* Add binary memory block to the log messages.
* @param BUF pointer to memory block
* @param LEN length of memory block
*/
#define DLT_RAW(BUF, LEN) \
(void)dlt_user_log_write_raw(&log_local, BUF, LEN)
#define DLT_HEX8(UINT_VAR) \
(void)dlt_user_log_write_uint8_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX8)
#define DLT_HEX16(UINT_VAR) \
(void)dlt_user_log_write_uint16_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX16)
#define DLT_HEX32(UINT_VAR) \
(void)dlt_user_log_write_uint32_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX32)
#define DLT_HEX64(UINT_VAR) \
(void)dlt_user_log_write_uint64_formatted(&log_local, UINT_VAR, DLT_FORMAT_HEX64)
#define DLT_BIN8(UINT_VAR) \
(void)dlt_user_log_write_uint8_formatted(&log_local, UINT_VAR, DLT_FORMAT_BIN8)
#define DLT_BIN16(UINT_VAR) \
(void)dlt_user_log_write_uint16_formatted(&log_local, UINT_VAR, DLT_FORMAT_BIN16)
/**
* Add binary memory block with "name" attribute to the log messages.
* @param BUF pointer to memory block
* @param LEN length of memory block
* @param NAME "name" attribute
*/
#define DLT_RAW_ATTR(BUF, LEN, NAME) \
(void)dlt_user_log_write_raw_attr(&log_local, BUF, LEN, NAME)
/**
* Architecture independent macro to print pointers
*/
#define DLT_PTR(PTR_VAR) \
(void)dlt_user_log_write_ptr(&log_local, PTR_VAR)
/**
* Trace network message
* @param CONTEXT object containing information about one special logging context
* @param TYPE type of network trace message
* @param HEADERLEN length of network message header
* @param HEADER pointer to network message header
* @param PAYLOADLEN length of network message payload
* @param PAYLOAD pointer to network message payload
*/
#define DLT_TRACE_NETWORK(CONTEXT, TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD) \
do { \
if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr) == DLT_TRACE_STATUS_ON) \
{ \
(void)dlt_user_trace_network(&(CONTEXT), TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD); \
} \
} while(false)
/**
* Trace network message, allow truncation
* @param CONTEXT object containing information about one special logging context
* @param TYPE type of network trace message
* @param HEADERLEN length of network message header
* @param HEADER pointer to network message header
* @param PAYLOADLEN length of network message payload
* @param PAYLOAD pointer to network message payload
*/
#define DLT_TRACE_NETWORK_TRUNCATED(CONTEXT, TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD) \
do { \
if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr) == DLT_TRACE_STATUS_ON) \
{ \
(void)dlt_user_trace_network_truncated(&(CONTEXT), TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD, 1); \
} \
} while(false)
/**
* Trace network message, segment large messages
* @param CONTEXT object containing information about one special logging context
* @param TYPE type of network trace message
* @param HEADERLEN length of network message header
* @param HEADER pointer to network message header
* @param PAYLOADLEN length of network message payload
* @param PAYLOAD pointer to network message payload
*/
#define DLT_TRACE_NETWORK_SEGMENTED(CONTEXT, TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD) \
do { \
if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr) == DLT_TRACE_STATUS_ON) \
{ \
(void)dlt_user_trace_network_segmented(&(CONTEXT), TYPE, HEADERLEN, HEADER, PAYLOADLEN, PAYLOAD); \
} \
} while(false)
/**
* Send log message with string parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param TEXT ASCII string
*/
#define DLT_LOG_STRING(CONTEXT, LOGLEVEL, TEXT) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_string(&(CONTEXT), LOGLEVEL, TEXT); \
} \
} while(false)
/**
* DLTv2 Send log message with string parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param TEXT ASCII string
*/
#define DLT_LOG_STRING_V2(CONTEXT, LOGLEVEL, TEXT) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_string_v2(&(CONTEXT), LOGLEVEL, TEXT); \
} \
} while(false)
/**
* Send log message with string parameter and integer parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log messages
* @param TEXT ASCII string
* @param INT_VAR integer value
*/
#define DLT_LOG_STRING_INT(CONTEXT, LOGLEVEL, TEXT, INT_VAR) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_string_int(&(CONTEXT), LOGLEVEL, TEXT, INT_VAR); \
} \
} while(false)
/**
* DLTv2 Send log message with string parameter and integer parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log messages
* @param TEXT ASCII string
* @param INT_VAR integer value
*/
#define DLT_LOG_STRING_INT_V2(CONTEXT, LOGLEVEL, TEXT, INT_VAR) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_string_int_v2(&(CONTEXT), LOGLEVEL, TEXT, INT_VAR); \
} \
} while(false)
/**
* Send log message with string parameter and unsigned integer parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param TEXT ASCII string
* @param UINT_VAR unsigned integer value
*/
#define DLT_LOG_STRING_UINT(CONTEXT, LOGLEVEL, TEXT, UINT_VAR) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_string_uint(&(CONTEXT), LOGLEVEL, TEXT, UINT_VAR); \
} \
} while(false)
/**
* DLTv2 Send log message with string parameter and unsigned integer parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param TEXT ASCII string
* @param UINT_VAR unsigned integer value
*/
#define DLT_LOG_STRING_UINT_V2(CONTEXT, LOGLEVEL, TEXT, UINT_VAR) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_string_uint_v2(&(CONTEXT), LOGLEVEL, TEXT, UINT_VAR); \
} \
} while(false)
/**
* Send log message with unsigned integer parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param UINT_VAR unsigned integer value
*/
#define DLT_LOG_UINT(CONTEXT, LOGLEVEL, UINT_VAR) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_uint(&(CONTEXT), LOGLEVEL, UINT_VAR); \
} \
} while(false)
/**
* DLTv2 Send log message with unsigned integer parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param UINT_VAR unsigned integer value
*/
#define DLT_LOG_UINT_V2(CONTEXT, LOGLEVEL, UINT_VAR) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_uint_v2(&(CONTEXT), LOGLEVEL, UINT_VAR); \
} \
} while(false)
/**
* Send log message with integer parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param INT_VAR integer value
*/
#define DLT_LOG_INT(CONTEXT, LOGLEVEL, INT_VAR) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_int(&(CONTEXT), LOGLEVEL, INT_VAR); \
} \
} while(false)
/**
* DLTv2 Send log message with integer parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param INT_VAR integer value
*/
#define DLT_LOG_INT_V2(CONTEXT, LOGLEVEL, INT_VAR) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_int_v2(&(CONTEXT), LOGLEVEL, INT_VAR); \
} \
} while(false)
/**
* Send log message with binary memory block.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param BUF pointer to memory block
* @param LEN length of memory block
*/
#define DLT_LOG_RAW(CONTEXT, LOGLEVEL, BUF, LEN) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_raw(&(CONTEXT), LOGLEVEL, BUF, LEN); \
} \
} while(false)
/**
* DLTv2 Send log message with binary memory block.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param BUF pointer to memory block
* @param LEN length of memory block
*/
#define DLT_LOG_RAW_V2(CONTEXT, LOGLEVEL, BUF, LEN) \
do { \
if (dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE) \
{ \
(void)dlt_log_raw_v2(&(CONTEXT), LOGLEVEL, BUF, LEN); \
} \
} while(false)
/**
* Send log message with marker.
*/
#define DLT_LOG_MARKER() \
do { \
(void)dlt_log_marker(); \
} while(false)
/**
* Switch to verbose mode
*
*/
#define DLT_VERBOSE_MODE() do { \
(void)dlt_verbose_mode(); } while(false)
/**
* Switch to non-verbose mode
*
*/
#define DLT_NONVERBOSE_MODE() do { \
(void)dlt_nonverbose_mode(); } while(false)
/**
* 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
*/
#define DLT_SET_APPLICATION_LL_TS_LIMIT(LOGLEVEL, TRACESTATUS) do { \
(void)dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS); } while(false)
/**
* Enable local printing of messages
*
*/
#define DLT_ENABLE_LOCAL_PRINT() do { \
(void)dlt_enable_local_print(); } while(false)
/**
* Disable local printing of messages
*
*/
#define DLT_DISABLE_LOCAL_PRINT() do { \
(void)dlt_disable_local_print(); } while(false)
/**
* Check if log level is enabled
*
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
*/
#define DLT_IS_LOG_LEVEL_ENABLED(CONTEXT, LOGLEVEL) \
(dlt_user_is_logLevel_enabled(&CONTEXT, LOGLEVEL) == DLT_RETURN_TRUE)
/**
\}
*/
#endif /* DLT_USER_MACROS_H */
|