DLT(Diagnostic Log and Trace)嵌入式系统程序运行记录
http://blog.csdn.net/yanlinembed/article/details/49837975
?
- DLT的使用有屬于Application范疇與Context范疇。在使用DLT時(shí),需要包含以下頭文件:
- 1
- 1
同時(shí)需要link相應(yīng)的dlt庫文件。
- Context范疇需要使用以下statement去申明及注冊(cè):
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- Application范疇需要使用以下statement去注冊(cè):
- 1
- 2
- 1
- 2
- 1
- 2
- 3
- 1
- 2
- 3
- DLT log 有以下幾種格式
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 上位機(jī)可以使用DLT-viewer軟件通過網(wǎng)絡(luò)SSH協(xié)議連接到目標(biāo)板上去查看系統(tǒng)的運(yùn)行情況。
DLT library
To use DLT from an application, the application has to link again the DLT library. When the DLT daemon is installed on the system , there will a shared library with the name libdlt.so which provides the interface for applications to get a connection to the DLT daemon. The library path and include path must be set in the build environment prior to building a program using the shared dlt library. By default, the include file “dlt.h” is located in a directory called “dlt/” within the standard include directory.
- Using DLT with cmake
To use DLT with cmake, the following lines are the important ones:
- 1
- 2
- 1
- 2
to INCLUDE_DIRECTORIES, add
${DLT_INCLUDE_DIRS}- 1
- 1
and to TARGET_LINK_LIBRARIES:
${DLT_LIBRARIES}- 1
- 1
- Logging instruction
Include the dlt header file:
- 1
- 1
- Create logging context (place it beneath the define section):
- 1
- 1
- Register the application and the context in main:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
Important note: If your application uses fork(), you may not call DLT_REGISTER_APP before fork(). And fork() should never be called after DLT_REGISTER_APP. This is because of state information and inter process communication channel to daemon would be copied to new process, but threads would be not.
- Use one of the DLT macros or the DLT function interface:
Here we use the macro interface of DLT
- 1
- 2
- 1
- 2
- Unregister the application and the context which are registered
- 1
- 2
- 1
- 2
-
Logging example
gedit dltdemo.c &
Copy the example code below into dltdemo.c
gcc -o dltdemo -ldlt dltdemo.c
rolf.haimerl|./dltdemo -
DLT - Hello world
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
-
API
Two types of DLT user interfaces are provided to applications. The first interface is a macro based interface, which makes it very easy and very pretty coding to use DLT. The second interface is a functional interface, which provides an object oriented C interface for applications.
The doxygen documentation of the dlt-daemon contains more informations about functional/macro based interfaces.
See INSTALL.txt how to generate doxygen documentation. -
DLT macro interface
The DLT macro interface provides a very easy to use interface. It is very easy to log a flexible size of parameters into a single log in a single source code line. -
Command and Description
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
-
DLT functional interface and example
The DLT functional interface provides a very easy to use interface. The C interface has an object oriented style. -
Command Description
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 4
- 5
- 6
- 1
- 2
- 3
- 4
- 5
- 6
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 1
- 2
- 3
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 1
- 2
- 3
- Addendum
Implementation specifics
The implementation is multithread safe.
Initialize DLT application and contexts, then forking and using the forked process, will lead to unclear behavior (or in worst case to a crash), as the forked process uses another process id as the parent process. Instead, initialize the DLT application and contexts in the forked process.
Purpose
This document specifies the usage of the DLT daemon. The DLT daemon is the central place where logs and traces are gathered from different applications, stored temporarily or permanently and transferred to a DLT client application, which can run directly on the GENIVI system or more likely on a external tester device. The DLT daemon component is based on the AUTOSAR 4.0 standard DLT.
Overview
The DLT daemon is the central component in GENIVI, which gathers all logs and traces from the DLT user applications. The logs and traces are stored optionally directly in a file in the ECU. The DLT daemon forwards all logs and traces to a connected DLT client. The DLT client can send control messages to the daemon, e.g. to set individual log levels of applications and contexts or get the list of applications and contexts registered in the DLT daemon.
-
The SW components of DLT:
dlt-daemon
dlt-system
dlt-adaptor-stdin
dlt-adaptor-udp
dlt-convert
dlt-receive -
The SW components of DLT for testing:
dlt-example-user
dlt-example-user-func
dlt-example-filetransfer
dlt-test-filetransfer
dlt-test-stress-user
dlt-test-client
dlt-test-stress-client
dlt-test-multi-process-client
dlt-test-stress
dlt-test-multi-process
dlt-test-user -
DLT daemon
Features
-Message injection callback
-The Viewer can send a message to an application. The application has to register an injection callback.
-Support for multiple applications and multiple contexts organized in a hierarchy
-Support for different interfaces between daemon and viewer (
-Binary transport of messages (TCP/IP, Serial)
-Verbose and none-verbose mode support
-System log-level and individual log-levels for contexts
-Adapters to connect Linux log facilities, e.g. syslog (planned journal)
-User library and Daemon has a temporary internal buffer
-Trace message (network message) support
-The viewer writes messages from several sources into a single trace file
-File transfer + compression for small files, e.g., screenshots of HMI
-Many configuration options
-Viewer supports plug-ins* *(SDK + example code) e.g. MOST message formatting
-Daemon or application mode
The DLT daemon can be started in daemon mode, which is the normal use case. For testing purpose it can also be started in a standard application mode. In application mode all output is displayed in the console. In daemon mode output is done to the syslog daemon.The daemon mode is needed specially in System V init start-up system.
-Offline Trace
Optional an offline trace memory can be configured in the DLT daemon configuration. The offline trace is stored locally in the file system. The directory of the offline trace can be configured.
-Trace Mode
A API is provided in the DLT library to change the trace mode. If the trace mode is changed, the trace mode is stored persistently in the runtime configuration. The following modes are possible:
trace off
online trace only (Default)
offline trace only
online and offline trace
-Start-up Trace
During star-up the logging data is stored in a temporary buffer, until the first client is connected. This feature is only available, if no serial connection is configured and the trace mode is “online trace only”. - Command line interface
See Manpage dlt-daemon(1). - Configuration
See Manpage dlt.conf(5). - DLT system logger
Overview
The dlt-system application provides the following features:
DLT file-transfer manager
Syslog Adapter over UDP
Logging of file content from filesystem
Logging of files from proc filesystem of processes
All the configuration is done in the file /etc/dlt-system.conf. -
DLT Filetransfer
The DLT file-transfer manager can control up to two directories, if they contain any files. When a new file is detected in theses directories, the file transfer over DLT is started for this file. When the file transfer is finished, a configurable time is waited, until the file is deleted and the transfer of the next file is started. The first file transfer starts after a configurable time after dlt-system is started.
Flow control is used to control the amount of data which is sent at once over DLT. Currently the fill level of the shared memory is checked. When 50% of fill level is reached no new data is sent again, until the level falls under 50% again.
Typical Use cases are file transfer of screenshots or core dump files. -
Syslog adapter
The syslog adapter provides a UDP port, to which the syslog daemon can send each syslog message. The syslog configuration must be changed to do this. The used UDP port can be configured. -
Logging of files
Every file in the filesystem can be logged over DLT. The files can be logged only once during start-up or periodically after a defined time. Several files can be configured to be logged. -
Logging of files from proc filesystem
Every file in the proc filesystem of a process can be logged. Theses files can be logged only once during start-up or periodically after a defined time. A specific process can be selected or all processes at once. -
Command line interface
See Manpage dlt-system(1). -
Configuration
See Manpage dlt-system.conf(5). -
DLT command line tools
Three command line tools are provided together with DLT daemon implementation.
These tools are:
Data logger: dlt-receive
Converter: dlt-convert
Configuration: dlt-control (planned) - dlt-receive
-
Overview
dlt-receive is a command line tool to connect to the dlt-daemon and receive logs and display them in the console or store them in a file. -
Command line interface
See Manpage dlt-receive(1). -
dlt-convert
-
Overview
The dlt-convert console utility is used to read DLT files, print DLT messages in different formats (ASCII, hex, mixed, headers only) and store the messages again. Filters can be used to filter messages. Ranges and output file can be used to cut DLT files. Two files and output file can be used to join DLT files. -
Command line interface
See Manpage dlt-convert(1). -
DLT adaptors
The DLT adaptors are used to interface legacy linux applications with the DLT daemon. Therefore, there are two adaptors:
dlt-adaptor-stdin for input received from stdin
dlt-adaptor-udp for input received from a specific udp port
As command line parameters, the application id and context id can be specified individually for each instance of these programs. These id’s are a character string consisting of up to 4 characters. Empty ids are not allowed and will be replaced with a default id. If not specified, the default id’s will also be taken. -
dlt-adaptor-stdin
The dlt-adaptor-stdin is a small external program for forwarding input from stdin to DLT daemon, and can be used for e.g. sending DBUS messages to the dlt daemon using the program dbus-monitor:
$ dbus-monitor | dlt-adaptor-stdin -
dlt-adaptor-udp
The dlt-adaptor-udp is a small external program for forwarding received UDP messages to DLT daemon, and can be used for e.g. sending syslog messages to the DLT daemon. Therefore a syslog daemon called syslog-ng is necessary. This syslog daemon must be configured to send the syslog messages to a specific UDP port. For configuration of this syslog daemon, see the documentation for syslog-ng.
This tool is already integrated into dlt-system.
總結(jié)
以上是生活随笔為你收集整理的DLT(Diagnostic Log and Trace)嵌入式系统程序运行记录的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何修改Excel2007中回车键切换单
- 下一篇: 免费申请国外免费域名超详细教程[通俗易懂