Skip to content

Commit

Permalink
fix base type once Signal is float in Fibex (#818)
Browse files Browse the repository at this point in the history
Co-authored-by: malilaroussi <[email protected]>
  • Loading branch information
Dalilaroussi and malilaroussi authored Oct 14, 2024
1 parent f060203 commit d6bb599
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/canmatrix/formats/fibex.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,36 +129,36 @@ def get_multiplexing_parts_infos(signals, frame_name, start_pos=-1, end_pos=-1,

return start_pos, end_pos, seg_big_endian

def get_base_data_type(bit_length, is_signed=False):
def get_base_data_type(signal):
# type: (int, bool) -> str
if bit_length > 0 and bit_length <= 8:
if is_signed:
if signal.is_float:
if (signal.size<=32):
return "A_FLOAT32"
else:
return "A_FLOAT64"

if signal.size > 0 and signal.size <= 8:
if signal.is_signed:
return "A_INT8"
elif not is_signed:

elif not signal.is_signed:
return "A_UINT8"

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

elif not is_signed:
return "A_UINT16"

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

elif not is_signed:
return "A_UINT32"

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

elif not is_signed:
return "A_UINT64"

elif signal.size > 8 and signal.size <= 16:
if signal.is_signed:
return "A_INT16"
elif not signal.is_signed:
return "A_UINT16"
elif signal.size > 16 and signal.size <= 32:
if signal.is_signed:
return "A_INT32"
elif not signal.is_signed:
return "A_UINT32"
elif signal.size > 32 and signal.size <= 64:
if signal.is_signed:
return "A_INT64"
elif not signal.is_signed:
return "A_UINT64"
class Fe:
def __init__(self, filename):
self.tree = lxml.etree.parse(filename)
Expand Down Expand Up @@ -791,7 +791,7 @@ def dump(db, f, **options):
signal_id)

coded = create_sub_element_ho(coding, "CODED-TYPE")
base_data_type = get_base_data_type(signal.size, signal.is_signed)
base_data_type = get_base_data_type(signal)
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 d6bb599

Please sign in to comment.