Skip to main content

cfastblf

Cython-accelerated BLF file reading/writing and signal query library.

Project Introduction

cfastblf is a high-performance BLF (Binary Logging Format) file reading/writing library written in Cython, specifically designed for processing automotive bus data. By compiling critical performance paths into native code using Cython, it provides faster file parsing and processing speed compared to python-can.

This library supports reading, filtering, signal decoding, and exporting of CAN/CAN FD messages, offering both low-level direct access and high-level query usage patterns, suitable for automotive data analysis and test validation scenarios.

Features

  • High-performance parsing: Core logic compiled with Cython, significantly improving BLF file parsing speed
  • NumPy integration: Uses NumPy structured arrays as memory data structures for high-speed data analysis and processing
  • Memory efficient: Optimized index-data block storage structure effectively reduces memory usage, supports loading hundreds of millions of frame data at once
  • Complete protocol support: Supports multiple message types including CAN, CAN FD, error frames, etc.
  • Flexible signal decoding: Supports high-speed signal extraction and conversion based on DBC files
  • Advanced query functionality: Provides expression-based message filtering and signal mapping
  • Platform compatibility: Free version supports Windows, contact author for other system versions

Installation

pip install cfastblf

Usage

from cfastblf import read, write, signal_decoder, Query

with open(r'myblf.blf', 'rb') as blf:  # Note: use binary read mode
    # Read all CAN/CANFD frames from BLF file, returns a tuple
    # The tuple contains: index array (numpy structured array) and compact data block (numpy byte array)
    # The dtype structure of index structured array: np.dtype([('timestamp', 'i8'), ('can_id', 'u4'), ('is64', 'u1'), ('channel', 'u1'), ('len', 'u1'), ('flags', 'u1'), ('loc', 'u8')])
    # Where:
    # * timestamp: timestamp in nanoseconds
    # * len: message payload length (bytes)
    # * flags: flag bits, from high to low: reserved, is_extended_id, is_remote_frame, is_error_frame, is_fd, is_rx, bitrate_switch, error_state_indicator
    # * loc: offset in data block (bytes)
    frames = read(blf)

# Low-level usage: directly read message frames
index, chunk = frames  # Destructure tuple, chunk can be reused by frame subsets
msg = index[5]  # The 5th CAN message (frame)
can_id = msg['can_id']  # Read CAN ID
payload = chunk[msg['loc']:msg['loc'] + msg['len']]  # Get message payload

# Low-level usage: filter frames with specific CAN_ID
sub = frames[0][frames[0]['can_id'] == 0x150]  # Pure numpy computation

# High-level usage: using query
from cantools import database as db
dbc = db.load_file(r'mybus.dbc', encoding='gbk')  # Load DBC file
qry = Query()  # Create query
qry.addDatabase(dbc)  # Add signal database
# Filter frames with CAN ID 0x150, note: must use 'frames' in query string to represent actual frame array
sub = qry.filter(frames, "frames['can_id'] == 0x150")  # Note: sub is still a tuple
# Decode ECU_150_CheckSum signal from all frames in subset sub
sig = qry.map(sub, 'signals.ECU_150_CheckSum(frames)')  # Returns float array

# Save frame subset as BLF file
with open('output.blf', 'wb') as f:  # Must use binary write mode
    write(f, sub)

Free Version Limitations

This module is freeware, not open source software. Free version has the following limitations:

  1. Only provides binary installation packages for Windows systems.
  2. Only supports processing up to 2M CAN/CANFD frames, data exceeding this limit will be truncated.

Contact Author

Email: rockswang@foxmail.com GitHub: https://github.com/rockswang/cfastblf

Metadata

Release files for cfastblf 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for cfastblf 0.1.2
File Interpreter ABI Platform Actions
cfastblf-0.1.2-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details for cfastblf-0.1.2-cp38-cp38-win_amd64.whl

Release files / cfastblf-0.1.2-cp38-cp38-win_amd64.whl

Download URL cfastblf-0.1.2-cp38-cp38-win_amd64.whl
Size 208.7 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
6864f802e5d72557f953b389798372700d03d1a4a07ca7fbe5ba0d02f710e432
BLAKE2b-256 checksum
How to use checksums
177a5f37843036e32f38d891ab649952d5976247e62a7cb7a808890bdbe2aa80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Security for cfastblf 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page