Skip to content

Commit

Permalink
fix issue with overlapping Motorola channels with bit_count+bit_offse…
Browse files Browse the repository at this point in the history
…t <=8
  • Loading branch information
danielhrisca committed Mar 26, 2020
1 parent 80ce891 commit d6c3c80
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion asammdf/blocks/mdf_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2867,7 +2867,11 @@ def get(
dtype_fmt = get_fmt_v3(data_type, bits, self.identification.byte_order)
channel_dtype = dtype(dtype_fmt.split(")")[-1])

view = f'{channel_dtype.byteorder}u{vals.itemsize}'
if channel_dtype.byteorder == '|' and data_type in (v23c.DATA_TYPE_SIGNED_MOTOROLA, v23c.DATA_TYPE_UNSIGNED_MOTOROLA):
view = f'>u{vals.itemsize}'
else:
view = f'{channel_dtype.byteorder}u{vals.itemsize}'

vals = vals.view(view)

if bit_offset:
Expand Down
14 changes: 10 additions & 4 deletions asammdf/blocks/mdf_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -7179,7 +7179,11 @@ def _get_scalar(
else:
channel_dtype = channel.dtype_fmt

view = f'{channel_dtype.byteorder}u{vals.itemsize}'
if channel_dtype.byteorder == '|' and data_type in (v4c.DATA_TYPE_SIGNED_MOTOROLA, v4c.DATA_TYPE_UNSIGNED_MOTOROLA):
view = f'>u{vals.itemsize}'
else:
view = f'{channel_dtype.byteorder}u{vals.itemsize}'

vals = vals.view(view)

if bit_offset:
Expand Down Expand Up @@ -7296,7 +7300,10 @@ def _get_scalar(
else:
channel_dtype = channel.dtype_fmt

view = f'{channel_dtype.byteorder}u{vals.itemsize}'
if channel_dtype.byteorder == '|' and data_type in (v4c.DATA_TYPE_SIGNED_MOTOROLA, v4c.DATA_TYPE_UNSIGNED_MOTOROLA):
view = f'>u{vals.itemsize}'
else:
view = f'{channel_dtype.byteorder}u{vals.itemsize}'
vals = vals.view(view)

if bit_offset:
Expand Down Expand Up @@ -7338,8 +7345,7 @@ def _get_scalar(
channel_dtype = channel.dtype_fmt.subdtype[0]
else:
channel_dtype = channel.dtype_fmt
if vals.dtype != channel_dtype:
print('???????????', channel_dtype, vals.dtype, vals[0])
if vals.dtype != channel_dtype:p
vals = vals.astype(channel_dtype)

if master_is_required:
Expand Down
2 changes: 1 addition & 1 deletion asammdf/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
""" asammdf version module """

__version__ = "5.19.8"
__version__ = "5.19.9"

0 comments on commit d6c3c80

Please sign in to comment.