• dlt-daemon安装教程


    获取dlt-daemon源码

    1. git clone https://github.com/GENIVI/dlt-daemon.git
    2. cd dlt-daemon
    3. mkdir build
    4. cd build
    5. cmake ..
    6. make
    7. sudo make install
    8. sudo ldconfig

    dlt-daemon 编译安装就完成了。

    批注: linux下使用sudo apt install dlt-daemon是不是也可以??

    dlt-viewer

    现装依赖包 sudo apt-get install libqt5serialport5-dev libqt5serialport5
    批注:也可以使用 sudo apt install dlt-viewer 完成安装。

    1. git clone https://github.com/GENIVI/dlt-viewer.git
    2. mkdir build
    3. cd build
    4. cmake ..
    5. make

    这时,build/bin目录下就生成了可执行文件dlt-viewer

    生成测试程序

    1. cd dlt-daemon/examples/example1/
    2. mkdir build
    3. cd build
    4. cmake ..
    5. make

    dlt-example1的测试程序就生成好了。具体如何添加dlt_log就餐控example下的几个例子。

    启动dlt-daemon

    首先复制dlt.conf文件

    1. cd dlt-daemon/src/daemon/
    2. sudo cp dlt.conf /etc/
    3. sudo gedit /etc/dlt.conf

    修改dlt.conf:

    1. LoggingMode = 2
    2. OfflineTraceDirectory = /tmp
    3. OfflineTraceFileSize = 1000000
    4. OfflineTraceMaxSize = 4000000
    5. OfflineTraceFileNameTimestampBased = 1
    6. OfflineLogstorageDirPath = /opt

    链接配置文件:

    dlt-daemon -c /etc/dlt.conf

    启动log接收端:

    dlt-receive -o /tmp/log.dlt localhost

    启动example1:

    dlt-daemon/examples/example1/build$ sudo ./dlt-example1

    这时,/tmp/log.dlt 文件就可以用dlt-viewer查看啦。

    自定义样例

    在home建立test文件夹,然后写入
    example.c

    1. #include
    2. #include
    3. DLT_DECLARE_CONTEXT(myContext1);
    4. DLT_DECLARE_CONTEXT(myContext2);
    5. DLT_DECLARE_CONTEXT(myContext3);
    6. int main()
    7. {
    8. /* register application */
    9. DLT_REGISTER_APP("MAPP","Test Application for Logging");
    10. /* register all contexts */
    11. DLT_REGISTER_CONTEXT(myContext1,"TES1","Test Context 1 for Logging");
    12. DLT_REGISTER_CONTEXT(myContext2,"TES2","Test Context 2 for Logging");
    13. DLT_REGISTER_CONTEXT(myContext3,"TES3","Test Context 3 for Logging");
    14. /* Write your logs */
    15. DLT_LOG(myContext1,DLT_LOG_ERROR,DLT_INT(5),DLT_STRING("This is a error"));
    16. DLT_LOG(myContext2,DLT_LOG_INFO,DLT_INT(5),DLT_STRING("But this only information"));
    17. DLT_LOG(myContext3,DLT_LOG_DEBUG,DLT_INT(5),DLT_STRING("But this only information"));
    18. /* Sleep some time to avoid a flaw in dlt-daemon that would eat your messages
    19. if you deregister while it still processes your registration */
    20. sleep(3);
    21. /* unregister your contexts */
    22. DLT_UNREGISTER_CONTEXT(myContext1);
    23. DLT_UNREGISTER_CONTEXT(myContext2);
    24. DLT_UNREGISTER_CONTEXT(myContext3);
    25. /* unregister your application */
    26. DLT_UNREGISTER_APP();
    27. return 0;
    28. }

    CMakeLists.txt

    1. #######
    2. # SPDX license identifier: MPL-2.0
    3. #
    4. # Copyright (C) 2011-2015, BMW AG
    5. #
    6. # This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
    7. #
    8. # This Source Code Form is subject to the terms of the
    9. # Mozilla Public License (MPL), v. 2.0.
    10. # If a copy of the MPL was not distributed with this file,
    11. # You can obtain one at http://mozilla.org/MPL/2.0/.
    12. #
    13. # For further information see http://www.genivi.org/.
    14. #######
    15. #
    16. # DLT example implementation
    17. #
    18. cmake_minimum_required( VERSION 2.6 )
    19. project( automotive-dlt-example1 )
    20. #
    21. # find dependency packages
    22. #
    23. find_package(PkgConfig)
    24. pkg_check_modules(DLT REQUIRED automotive-dlt)
    25. #
    26. # include directories
    27. #
    28. include_directories(
    29. ${DLT_INCLUDE_DIRS}
    30. )
    31. #
    32. # build project,这里需要修改
    33. #
    34. set(dlt_example1_SRCS example.c)
    35. add_executable(dlt-example1 ${dlt_example1_SRCS})
    36. target_link_libraries(dlt-example1 ${DLT_LIBRARIES})
    37. set_target_properties(dlt-example1 PROPERTIES LINKER_LANGUAGE C)
    38. install(TARGETS dlt-example1
    39. RUNTIME DESTINATION bin
    40. COMPONENT base)

    构建工程

    1. cd test
    2. mkdir build
    3. cd build
    4. cmake ..
    5. make
    6. dlt-receive -o /tmp/log.dlt localhost
    7. sudo ./dlt-example1

    此时就可以使用dltViewer查看 /tmp/log.dlt

  • 相关阅读:
    《Java编程思想》读书笔记(三)
    坏块处理 ORA-01578: ORACLE data block corrupted (file # 3, block # 152588)
    韩语图片文字如何转为纯文本?
    Ubuntu安装qwt6.1.2
    【特纳斯电子】基于物联网的空气质量检测-实物设计
    HIVE SQL regexp_extract和regexp_replace配合使用正则提取多个符合条件的值
    Django 的 settings 全局配置文件
    maven工程结构搭建
    能助我拿 3 家大厂 offer 的神级 Java 面试宝典,你值得拥有
    windows解决本地端口占用问题
  • 原文地址:https://blog.csdn.net/weixin_39759247/article/details/107055139