Skip to content

Commit

Permalink
Update fibex.py (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrineBH committed Jun 24, 2024
1 parent e9b2972 commit 6f71686
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/canmatrix/formats/fibex.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,34 @@ def get_multiplexing_parts_infos(signals, frame_name, start_pos=-1, end_pos=-1,

def get_base_data_type(bit_length, is_signed=False):
# type: (int, bool) -> str
if bit_length == 8:
if bit_length > 0 and bit_length <= 8:
if is_signed:
return "A_INT8"

elif not is_signed:
return "A_UINT8"

elif bit_length == 16:
elif bit_length > 8 and bit_length <= 16:
if is_signed:
return "A_INT16"

elif not is_signed:
return "A_UINT16"

elif bit_length == 32:
elif bit_length > 16 and bit_length <= 32:
if is_signed:
return "A_INT32"

elif not is_signed:
return "A_UINT32"

elif bit_length == 64:
elif bit_length > 32 and bit_length <= 64:
if is_signed:
return "A_INT64"

elif not is_signed:
return "A_UINT64"


class Fe:
def __init__(self, filename):
self.tree = lxml.etree.parse(filename)
Expand Down Expand Up @@ -788,10 +787,8 @@ def dump(db, f, **options):
"Coding for " +
signal_id)

coded = create_sub_element_ho(coding, "CODED-TYPE")
# find smallest predefined type size able of holding signal size
byte_size = (signal.size + 8 - 1) / 8
base_data_type = get_base_data_type(byte_size * 8, signal.is_signed)
coded = create_sub_element_ho(coding, "CODED-TYPE")
base_data_type = get_base_data_type(signal.size, signal.is_signed)
if base_data_type is not None:
coded.set(ns_ho + "BASE-DATA-TYPE", base_data_type)
coded.set("CATEGORY", "STANDARD-LENGTH-TYPE")
Expand Down

0 comments on commit 6f71686

Please sign in to comment.