dlt-daemon安裝教程


獲取dlt-daemon源碼

git clone https://github.com/GENIVI/dlt-daemon.git
cd dlt-daemon
mkdir build
cd build
cmake ..
make
sudo make install
sudo ldconfig

dlt-daemon 編譯安裝就完成了。

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

dlt-viewer

現裝依賴包 sudo apt-get install libqt5serialport5-dev libqt5serialport5
批注:也可以使用 sudo apt install dlt-viewer 完成安裝。

git clone https://github.com/GENIVI/dlt-viewer.git
mkdir build
cd build
cmake ..
make

這時,build/bin目錄下就生成了可執行文件dlt-viewer

生成測試程序

cd dlt-daemon/examples/example1/
mkdir build
cd build
cmake ..
make

dlt-example1的測試程序就生成好了。具體如何添加dlt_log就餐控example下的幾個例子。

啟動dlt-daemon

首先復制dlt.conf文件

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

修改dlt.conf:

LoggingMode = 2
OfflineTraceDirectory = /tmp
OfflineTraceFileSize = 1000000
OfflineTraceMaxSize = 4000000

OfflineTraceFileNameTimestampBased = 1
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

#include <stdio.h>
#include <dlt.h>

DLT_DECLARE_CONTEXT(myContext1);
DLT_DECLARE_CONTEXT(myContext2);
DLT_DECLARE_CONTEXT(myContext3);

int main()
{
/* register application */
DLT_REGISTER_APP("MAPP","Test Application for Logging");

/* register all contexts */
DLT_REGISTER_CONTEXT(myContext1,"TES1","Test Context 1 for Logging");
DLT_REGISTER_CONTEXT(myContext2,"TES2","Test Context 2 for Logging");
DLT_REGISTER_CONTEXT(myContext3,"TES3","Test Context 3 for Logging");

/* Write your logs */
DLT_LOG(myContext1,DLT_LOG_ERROR,DLT_INT(5),DLT_STRING("This is a error"));
DLT_LOG(myContext2,DLT_LOG_INFO,DLT_INT(5),DLT_STRING("But this only information"));
DLT_LOG(myContext3,DLT_LOG_DEBUG,DLT_INT(5),DLT_STRING("But this only information"));

/* Sleep some time to avoid a flaw in dlt-daemon that would eat your messages
 if you deregister while it still processes your registration */
sleep(3);

/* unregister your contexts */
DLT_UNREGISTER_CONTEXT(myContext1);
DLT_UNREGISTER_CONTEXT(myContext2);
DLT_UNREGISTER_CONTEXT(myContext3);

/* unregister your application */
DLT_UNREGISTER_APP();

return 0;

}

CMakeLists.txt

#######
# SPDX license identifier: MPL-2.0
#
# Copyright (C) 2011-2015, BMW AG
#
# This file is part of GENIVI 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.genivi.org/.
#######

#
# DLT example implementation
#

cmake_minimum_required( VERSION 2.6 )
project( automotive-dlt-example1 )

#
# find dependency packages
#

find_package(PkgConfig)
pkg_check_modules(DLT REQUIRED automotive-dlt)

#
# include directories
#

include_directories(
    ${DLT_INCLUDE_DIRS}
)

#
# build project,這里需要修改
#

set(dlt_example1_SRCS example.c)
add_executable(dlt-example1 ${dlt_example1_SRCS})
target_link_libraries(dlt-example1 ${DLT_LIBRARIES})
set_target_properties(dlt-example1 PROPERTIES LINKER_LANGUAGE C)

install(TARGETS dlt-example1
	RUNTIME DESTINATION bin
	COMPONENT base)

構建工程

cd test
mkdir build
cd build
cmake ..
make
dlt-receive -o /tmp/log.dlt localhost
sudo ./dlt-example1

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM