Skip to content

Commit

Permalink
reading byte offset instead of bit count
Browse files Browse the repository at this point in the history
  • Loading branch information
victorjoh committed Oct 2, 2023
1 parent 5075692 commit 8e153b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/asammdf/blocks/mdf_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -6777,9 +6777,7 @@ def _get_array(
dim = 1
for d in shape:
dim *= d

item_size = channel.bit_count // 8
size = item_size * dim
size = ca_block.byte_offset_base * dim

if group.uses_ld:
record_size = group.channel_group.samples_byte_nr
Expand Down
20 changes: 20 additions & 0 deletions test/test_mdf4.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ def test_attachment_blocks_w_filename(self):

mdf.close()

def test_channel_with_boolean_array(self):
timestamps = np.array([0.1, 0.2, 0.3, 0.4, 0.5], dtype=np.float32)

samples = [np.ones((5, 2), dtype=np.uint8)]
types = [("boolean_array_channel", "(2, )<u1")]
record = np.core.records.fromarrays(samples, dtype=np.dtype(types))
boolean_array_channel = Signal(
record,
timestamps=timestamps,
name="boolean_array_channel",
)

mdf4 = MDF(version="4.10")
mdf4.append(signals=[boolean_array_channel])
# set bit count to 1 to indicate that each uint8 value is a boolean flag in boolean_array_channel
mdf4.groups[0].channels[1].bit_count = 1
signal = mdf4.select([("boolean_array_channel", 0, 1)])[0]

self.assertTrue((record == signal.samples).all())


if __name__ == "__main__":
unittest.main()

0 comments on commit 8e153b2

Please sign in to comment.