Skip to content

Commit

Permalink
truncate the mask when its length is greater than the length of the i…
Browse files Browse the repository at this point in the history
…nternal value
  • Loading branch information
nada-ben-ali committed Sep 18, 2024
1 parent e2c364f commit a368630
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion odxtools/standardlengthtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def __get_raw_mask(self, internal_value: AtomicOdxType) -> Optional[bytes]:
else:
sz = (odxrequire(self.get_static_bit_length()) + 7) // 8

return self.bit_mask.to_bytes(sz, endianness)
max_value = (1 << (sz * 8)) - 1
bit_mask = self.bit_mask & max_value

return bit_mask.to_bytes(sz, endianness)

def __apply_mask(self, internal_value: AtomicOdxType) -> AtomicOdxType:
if self.bit_mask is None:
Expand Down

0 comments on commit a368630

Please sign in to comment.