How to read (and later write) Vector BLF and related CAN log formats (ASC, MF4, TRC, candump, PCAP) safely - structure, containers, object types, timestamps, pitfalls, fixtures and fuzzing. Use when implementing or reviewing log readers, replay, recording or import.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Blf And Log Formats?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/afri-bit-blf-and-log-formats)
---
name: blf-and-log-formats
description: How to read (and later write) Vector BLF and related CAN log formats (ASC, MF4, TRC, candump, PCAP) safely - structure, containers, object types, timestamps, pitfalls, fixtures and fuzzing. Use when implementing or reviewing log readers, replay, recording or import.
---
# Log formats for CAN data
> Layouts below come from public open-source readers (for example python-can) and experience, not the proprietary Vector specification. **Verify every field against real files and a reference tool** (Vector CANalyzer/CANoe, python-can) and keep golden fixtures. Mark anything unverified as such in docs.
## BLF (Binary Logging Format) - structure
1. **File header** `LOGG` (signature), header size (typically 144 bytes), application/API versions, file size, uncompressed size, object count, **measurement start** and **last object** times as SYSTEMTIME (8 x uint16: year, month, weekday, day, hour, minute, second, ms).
2. **Objects**, each starting with the base header: signature `LOBJ`, header size (u16), header version (u16), object size (u32, includes header), object type (u32). Version-1 header adds flags (u32), client index (u16), object version (u16), timestamp (u64). Objects are **padded to 4-byte alignment**; the next object starts at `offset + objectSize` rounded up.
3. **Containers** `LOG_CONTAINER` (type 10) wrap many objects, usually **zlib-compressed** (method 2; 0 = stored) with an uncompressed size. Inner objects may **straddle container boundaries** - keep a carry-over buffer.
4. **Timestamps**: flags select unit - 10 microseconds (`TIME_TEN_MICS` = 1) or nanoseconds (`TIME_ONE_NANS` = 2); relative to measurement start.
Common object types (verify): `CAN_MESSAGE` 1, `CAN_ERROR` 2, `LOG_CONTAINER` 10, `APP_TEXT` 65, `CAN_ERROR_EXT` 73, `CAN_MESSAGE2` 86, `CAN_FD_MESSAGE` 100, `CAN_FD_MESSAGE_64` 101, `CAN_FD_ERROR_64` 104. `CAN_MESSAGE`: channel (u16), flags (u8: direction, remote), DLC (u8), ID (u32, bit 31 = extended), 8 data bytes. FD messages add FD flags (EDL, BRS, ESI), valid data length and up to 64 data bytes. Other objects (LIN, FlexRay, Ethernet, env vars, statistics) must be **skipped by size**, counted and reported.
## Reader rules
- Stream container by container; bound inflate output; validate every size against remaining bytes; stop with an **offset-bearing error** on inconsistency.
- Never throw away unknown objects silently: count by type.
- Preserve ns precision as integers. Order = file order; do not sort silently (report out-of-order timestamps).
- Channel numbers in BLF are 1-based per application mapping; keep them as stored and map for display only.
- Writing (if ever): also write a correct header (counts, sizes) on close; flush periodically so crashes lose little.
## Other formats (orientation)
| Format | Notes |
|--------|-------|
| **ASC** (Vector ASCII) | Text lines `time channel id Rx/Tx d dlc bytes`; header sets base (hex/dec) and absolute/relative time; FD lines differ. Locale decimal separators and `//` comments. |
| **MF4** (ASAM MDF4) | Block-structured, channel groups, bus-logging conventions (CAN_DataFrame). Large; use a library or a careful subset. |
| **TRC** (PEAK) | Text, versions 1.x/2.x differ in columns. |
| **candump -L** | `(sec.usec) iface ID#DATA`; FD uses `##` with flags. |
| **PCAP/PCAPNG** | Link type 227 (SocketCAN); classic and FD frames are told apart by record length. |
## Testing
Build tiny fixtures in code with byte builders (header, object, container, zlib via `node:zlib`); cases: empty log, 1 frame, straddling containers, ns vs 10 us, unknown object, truncated header/object/container, oversize length, zlib bomb, extended ID bit 31, FD 64 bytes. Generate cross-check files with python-can in a dev-only script; never commit large or customer logs.