From 878cbb744d29344511b1885e82a3673ab2ba52ab Mon Sep 17 00:00:00 2001 From: SabrineBH Date: Fri, 21 Jun 2024 11:42:29 +0100 Subject: [PATCH] Update fibex.py --- src/canmatrix/formats/fibex.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/canmatrix/formats/fibex.py b/src/canmatrix/formats/fibex.py index cd643426..fefef63a 100644 --- a/src/canmatrix/formats/fibex.py +++ b/src/canmatrix/formats/fibex.py @@ -788,8 +788,10 @@ def dump(db, f, **options): "Coding for " + signal_id) - coded = create_sub_element_ho(coding, "CODED-TYPE") - base_data_type = get_base_data_type(signal.size, signal.is_signed) + 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) if base_data_type is not None: coded.set(ns_ho + "BASE-DATA-TYPE", base_data_type) coded.set("CATEGORY", "STANDARD-LENGTH-TYPE")