Rust DLT (Diagnostic Log and Trace) packet parser

Overview

Crates.io docs.rs Build Status Coverage Status

dlt_parse

A zero allocation rust library for basic parsing & writing DLT (Diagnostic Log and Trace) packets. Currently only the parsing and writing of the header is supported (excluding the verbose packet definitions).

Usage:

First, add the following to your Cargo.toml:

[dependencies]
dlt_parse = "0.2.1"

Next, add this to your crate:

use dlt_parse;

What is dlt_parse?

dlt_parse is a library that aims to provide serialisation & deserialisation funtions for DLT (Diagnostic Log and Trace) packets. It should make it possible to anlyse recordings of DLT packets as fast as possible, as well as writing servers that send DLT packets to the network.

Some key points are:

  • It is completly written in Rust and thoroughly tested.
  • Special attention has been paid to not use allocations or syscalls.
  • The package is still in development and can & will still change.
  • Methods for parsing verbose DLT packets are still missing (but maybe will be implemented in future versions).

Example: Serializing & Slicing/Deserializing DLT Packets

In this example a non verbose DLT packet is serialized and deserialized again. Specificly the serialized packet is converted into a DltPacketSlice. This has the advantage, that not all fields have to be deserialied to access the payload or specific fields in the header. Note that it is also possible to completely deserialize DLT headers with the DltHeader::read function. This can make sense, if most fields of the header are used anyways.

use self::dlt_parse::{DltHeader, DltLogLevel, DltExtendedHeader, SliceIterator};

let header = {
    let mut header = DltHeader {
        is_big_endian: true, //payload & message id are encoded with big endian
        version: 0,
        message_counter: 0,
        length: 0,
        ecu_id: None,
        session_id: None,
        timestamp: None,
        extended_header: Some(DltExtendedHeader::new_non_verbose_log(
            DltLogLevel::Debug,
            123,//application id
            1,//context id
        ))
    };
    header.length = header.header_len() + 4 + 4; //header + message id + payload

    header
};

//buffer to store serialized header & payload
let mut buffer = Vec::<u8>::with_capacity(usize::from(header.length));
header.write(&mut buffer).unwrap();

//write payload (message id 1234 & non verbose payload)
{
    //for write_all
    use std::io::Write;
    //byteorder crate is used for writing the message id with  the correct endianess
    use byteorder::{BigEndian, WriteBytesExt};

    //write the message id & payload
    buffer.write_u32::<BigEndian>(1234).unwrap(); //message id
    buffer.write_all(&[1,2,3,4]); //payload
}

//packets can contain multiple dlt messages, iterate through them
for dlt_message in SliceIterator::new(&buffer) {
    match dlt_message {
        Ok(dlt_slice) => {
            //check if the message is verbose or non verbose (non verbose messages have message ids)
            if let Some(message_id) = dlt_slice.message_id() {
                println!("non verbose message {:x}", message_id);
                println!("  with payload {:?}", dlt_slice.non_verbose_payload());
            } else {
                println!("verbose message (parsing not yet supported)");
            }
        },
        Err(err) => {
            //error parsing the dlt packet
            println!("ERROR: {:?}", err);
        }
    }
}

An complete example which includes the parsing of the ethernet & udp headers can be found in examples/print_messages_ids.rs

References

License

Licensed under the BSD 3-Clause license. Please see the LICENSE file for more information.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed as above, without any additional terms or conditions.

You might also like...
Fox Ear is a Linux process behavior trace tool powered by eBPF
Fox Ear is a Linux process behavior trace tool powered by eBPF

Fox Ear Fox Ear is a Linux process behavior trace tool powered by eBPF. Banner image by Birger Strahl on Unsplash. Features Log process and its subpro

A better visualization of clang's -ftime-trace output

crofiler: Easier C++ build profiling Understanding why C++ builds get slow has become a lot easier since clang introduced their -ftime-trace build tra

Opensource diagnostic software for Daimler vehicles, inspired by Xentry and DAS, written in Rust

OPENSTAR An opensource diagnostic application for Daimler vehicles inspired by DAS and Xentry. Some of the work here is based on OpenVehicleDiag If yo

miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!
miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

Rust crate providing a variety of automotive related libraries, such as communicating with CAN interfaces and diagnostic APIs

The Automotive Crate Welcome to the automotive crate documentation. The purpose of this crate is to help you with all things automotive related. Most

🕑 A personal git log and MacJournal output parser, written in rust.
🕑 A personal git log and MacJournal output parser, written in rust.

🕑 git log and MacJournal export parser A personal project, written in rust. WORK IN PROGRESS; NOT READY This repo consolidates daily activity from tw

tracing - a framework for instrumenting Rust programs to collect structured, event-based diagnostic information

tracing-appender Writers for logging events and spans Documentation | Chat Overview tracing is a framework for instrumenting Rust programs to collect

Diagnostic tools for timely dataflow computations
Diagnostic tools for timely dataflow computations

Timely Diagnostics Diagnostic tools for timely dataflow computations. Timely dataflows are data-parallel and scale from single threaded execution on y

Yet Another Parser library for Rust. A lightweight, dependency free, parser combinator inspired set of utility methods to help with parsing strings and slices.

Yap: Yet another (rust) parsing library A lightweight, dependency free, parser combinator inspired set of utility methods to help with parsing input.

Website for Microformats Rust parser (using 'microformats-parser'/'mf2')

Website for Microformats Rust parser (using 'microformats-parser'/'mf2')

Log your spending in seconds with short text snippets. Powered by Rust, Cloudflare Workers and Svelte.

FastSpend Log your daily spending lightning fast with short text snippets! FastSpend is a tool to log your spending in seconds, powered by a lightning

A language parser tool to build recursive descent top down parser.

lang-pt A language parser tool to generate recursive descent top down parser. Overview Parsers written for the languages like Javascript are often cus

Compute and derive metrics by watching a log file
Compute and derive metrics by watching a log file

Export Prometheus metrics from your web server's access log Web servers only offer limited metrics. For example, nginx only offers stub_status unless

Log for concurrent workloads, with support for atomic batches and in-order recovery

sharded-log A batch-oriented multi-threaded sharded log for workloads that occasionally flush logs into some other system. All batches have a 32-bit C

Cloud native log storage and management for Kubernetes, containerised workloads
Cloud native log storage and management for Kubernetes, containerised workloads

Live Demo | Website | API Workspace on Postman Parseable is an open source, cloud native, log storage and management platform. Parseable helps you ing

A scalable message queue powered by a segmented, partitioned, replicated and immutable log.
A scalable message queue powered by a segmented, partitioned, replicated and immutable log.

A scalable message queue powered by a segmented, partitioned, replicated and immutable log. This is currently a work in progress. laminarmq is intende

Log structured append-only key-value store from Rust In Action with some enhancements.

riakv Log structured, append only, key value store implementation from Rust In Action with some enhancements. Features Persistent key value store with

A cool log library built using rust-lang

RustLog A cool log library built using rust-lang Installation: Cargo.toml rustlog = { git = "https://github.com/krishpranav/rustlog" } log = "0.4.17"

A Write Ahead Log (WAL) implementation in Rust

Okay WAL A write-ahead log (WAL) implementation for Rust. There's The Great Wall, and then there's this: an okay WAL. This crate exposes a WAL that su

Releases(v0.4.0)
  • 0.3.0(Aug 22, 2021)

    • Marked slice methods as inline
    • Changed the types of the application id & context id from u32 to [u8;4] so they can be easier interpreted as chars
    • Extended check for DltNetworkType::UserDefined(u8) to only allow values from 0x7..=0xf. Previously 0..=0xf was allowed.
    Source code(tar.gz)
    Source code(zip)
  • 0.2.1(Jul 14, 2019)

  • 0.2.0(Jul 12, 2019)

    This release adds support for parsing & setting the message type informations in the extended header. Thanks to @marcelbuesing for the PR adding this functionality.

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Feb 10, 2019)

    This is the initial release of this library and as such the library will probably change a lot over the next few versions.

    It contains:

    • DltHeader parsing & serialization (including extended header)
    • DltPacketSlice: Allows reading header fields without the need to completely deserialize the dlt headers.
    • SliceIterator: Allows iterating over multiple dlt packets in the same payload.

    Enjoy

    Source code(tar.gz)
    Source code(zip)
Owner
Julian Schmid
Julian Schmid
Linux SocketCAN access in Rust

Rust SocketCAN support Maintenance status: This crate is in the process of entering renewed joint maintainership with @fpagliughi. Please stay patient

Marc Brinkmann 61 Dec 30, 2022
An intel PT trace converter from `perf.data` to Fuchsia trace format.

Introduction Recent Intel processors feature the "Intel Processor Trace" feature, which can be used to capture the full execution trace of a program.

Michał Chojnowski 14 Nov 9, 2022
Implements the packet parser for Gran Turismo 7 telemetry data, allowing a developer to retrieve data from a running game.

gran-turismo-query Implements the packet parser for Gran Turismo 7 telemetry data, allowing a developer to retrieve data from a running game. Features

Carlos Menezes 3 Dec 11, 2023
Log agent to replay time-stamped log stream

replayman Log agent to replay time-stamped log stream. Getting started Installation cargo install replayman Prepare for your data TSV with a header li

SpringQL 3 Dec 23, 2022
Reference library that implements all the necessary functionality for developing a client that is compatible with TAPLE's DLT network.

⚠️ TAPLE is in early development and should not be used in production ⚠️ TAPLE Core TAPLE (pronounced T+ ?? ['tapəl]) stands for Tracking (Autonomous)

Open Canarias 6 Jan 25, 2023
Reference application for connecting to the TAPLE DLT network.

⚠️ TAPLE is in early development and should not be used in production ⚠️ TAPLE Client TAPLE (pronounced T+ ?? ['tapəl]) stands for Tracking (Autonomou

Open Canarias 8 Feb 15, 2023
A decentralized, censorship-resistant, and incentive-compatible packet-routing overlay network

About Earendil is a decentralized, censorship-resistant packet-routing overlay network designed for performance and censorship resistance. It enables

Eric Tung (Yuhao Dong) 8 Jun 24, 2023
A Rust ESP stack trace decoder that can also runs in your browser thanks to WebAssembly

ESP Stack Trace Decoder A Rust ESP stack trace decoder that can also runs in your browser thanks to WebAssembly. It is composed of a ⌨️ Rust library,

Maxime BORGES 20 Oct 5, 2022
Rust crate for interacting with the Windows Packet Filter driver.

NDISAPI-RS NDISAPI-RS is a Rust crate for interacting with the Windows Packet Filter driver. It provides an easy-to-use, safe, and efficient interface

Vadim Smirnov 6 Jun 15, 2023
Secure multithreaded packet sniffer

sniffglue sniffglue is a network sniffer written in rust. Network packets are parsed concurrently using a thread pool to utilize all cpu cores. Projec

null 914 Dec 30, 2022