Skip to content

Commit

Permalink
allow bytearrays for A_BYTEFIELD
Browse files Browse the repository at this point in the history
Signed-off-by: Katja Köhler <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
  • Loading branch information
kakoeh committed Dec 19, 2023
1 parent 1b707e3 commit a691e64
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions odxtools/diagcodedtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def _encode_internal_value(
"""Convert the internal_value to bytes."""
# Check that bytes and strings actually fit into the bit length
if base_data_type == DataType.A_BYTEFIELD:
if isinstance(internal_value, bytearray):
internal_value = bytes(internal_value)
if not isinstance(internal_value, bytes):
odxraise()
if 8 * len(internal_value) > bit_length:
Expand Down

0 comments on commit a691e64

Please sign in to comment.