From 54016ac01f6834b2fbc5fc3723acaebb4e396db6 Mon Sep 17 00:00:00 2001 From: kipp-ing Date: Wed, 29 Jul 2026 21:00:01 +0200 Subject: [PATCH] fix: VLSD signal data is unreadable after a composed channel `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. --- src/asammdf/blocks/mdf_v4.py | 1 - test/test_mdf4.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/asammdf/blocks/mdf_v4.py b/src/asammdf/blocks/mdf_v4.py index df71d52b1..7124e2e6d 100644 --- a/src/asammdf/blocks/mdf_v4.py +++ b/src/asammdf/blocks/mdf_v4.py @@ -1065,7 +1065,6 @@ def _read_channels( index = ch_cntr - 1 dependencies.append(None) - grp.signal_data.append(None) # check if it is a CABLOCK or CNBLOCK stream.seek(component_addr) diff --git a/test/test_mdf4.py b/test/test_mdf4.py index c538dfeb4..025e40821 100644 --- a/test/test_mdf4.py +++ b/test/test_mdf4.py @@ -189,6 +189,35 @@ def test_channel_with_boolean_array(self) -> None: self.assertTrue((record == signal.samples).all()) + def test_vlsd_channel_after_structure_composition(self) -> None: + """A VLSD channel that sits after a structure (composed) channel in the + same group must still find its signal data. + + ``Group.signal_data`` is indexed by channel index, so an extra entry + pushed for a composed channel shifts every following channel's VLSD + block info and makes the payload unreadable. + """ + count = 20 + timestamps = np.arange(count, dtype="