Conversation
kipp-ing
force-pushed
the
fix/vlsd-signal-data-index
branch
from
July 29, 2026 19:16
cd8c5c2 to
31fa41c
Compare
kipp-ing
marked this pull request as ready for review
July 29, 2026 19:24
kipp-ing
marked this pull request as draft
July 29, 2026 19:26
kipp-ing
force-pushed
the
fix/vlsd-signal-data-index
branch
from
July 29, 2026 19:31
31fa41c to
5c8cc75
Compare
kipp-ing
marked this pull request as ready for review
July 29, 2026 19:31
`MDF4._read_channels` appends an extra `grp.signal_data.append(None)` for
every channel that carries a `component_addr` (a structure or array
composition), while `dependencies` gets exactly one entry per channel.
`Group.signal_data` is indexed by channel index, so each composed channel
shifts the VLSD block info of every following channel by one and the payload
can no longer be located:
MdfException: Wrong signal data block refence (0x...) for VLSD channel "..."
This bites every CAN-FD bus-logging file recorded with variable-length
payloads: `CAN_DataFrame.DataBytes` is a VLSD channel inside the composed
`CAN_DataFrame` structure, so `MDF.extract_bus_logging` cannot read it at all.
Drop the stray append and cover it with a regression test that writes a VLSD
channel after a structure channel in the same group.
kipp-ing
force-pushed
the
fix/vlsd-signal-data-index
branch
from
August 15, 2026 15:17
5c8cc75 to
54016ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background — what VLSD is
Most MDF4 channels are fixed-width columns inside the record: the channel says
"my value lives at byte offset 12, 2 bytes wide", and every sample is the same
size. Some data cannot work that way — a text channel, or a CAN-FD payload whose
length changes from frame to frame. MDF4 stores those out of line: the record
holds only a 64-bit offset, and the actual bytes sit in separate signal-data
blocks elsewhere in the file. Such a channel is a VLSD channel — variable
length signal data.
To read one, asammdf has to know where that channel's signal-data blocks are.
It collects them per group in
Group.signal_data, a plain list indexed bychannel index, filled while the channel list is parsed. If that list ever falls
out of step with
Group.channels, a VLSD channel looks up somebody else's blocks— or none at all.
That is what happens here.
Problem
MDF4._read_channelsappends an extragrp.signal_data.append(None)forevery channel that has a
component_addr(a structure or array composition),while
dependenciesgets exactly one entry per channel.So every composed channel shifts the signal-data entry of all following channels
by one, and
_load_signal_datathen looks in the wrong slot. Reading such achannel raises:
Impact
This affects every CAN-FD bus-logging measurement recorded with variable-length
payloads — which is the normal case, since a CAN-FD frame carries anywhere from
0 to 64 bytes.
CAN_DataFrame.DataBytesis a VLSD channel, and it lives insidethe composed
CAN_DataFramestructure, so it is always one of the shifted ones.MDF.extract_bus_logging()cannot read the payload at all and the file iseffectively unusable.
Found on two real OEM CAN-FD bus logs (1.0 GB and 157 MB, 5.1 M and 2.3 M CAN
frames); with the fix both extract normally.
Fix
Drop the stray append.
grp.signal_datathen stays in step withgrp.channels.Test
test_vlsd_channel_after_structure_compositionintest/test_mdf4.py— writes aVLSD (string) channel after a structure channel in the same group, then reads it
back. Fully offline, no downloads.
Without the fix:
test_mdf,test_mdf4,test_CAN_bus_logging,test_endianess,test_cantpand
test_signalall pass.