Skip to content

Commit

Permalink
Merge pull request #344 from nada-ben-ali/NaBe/truncate_the_mask_when…
Browse files Browse the repository at this point in the history
…_its_length_bigger_then_len(internal_value)

Truncate the mask when its length is greater than the length of the internal value
  • Loading branch information
andlaus authored Sep 19, 2024
2 parents 92bceae + a368630 commit ba81e22
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 ba81e22

Please sign in to comment.