From c88c92a415bac3c0db7b367cf83909321b2f5d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Br=C3=B6cker?= Date: Thu, 27 Jun 2024 14:54:51 +0200 Subject: [PATCH 1/2] possible quick fix for issue #781 --- src/canmatrix/formats/dbc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/canmatrix/formats/dbc.py b/src/canmatrix/formats/dbc.py index ffe3ffa9..6c4e3c5e 100644 --- a/src/canmatrix/formats/dbc.py +++ b/src/canmatrix/formats/dbc.py @@ -237,6 +237,9 @@ def dump(in_db, f, **options): for signal in frame.signals: if signal.cycle_time != 0: signal.add_attribute("GenSigCycleTime", signal.cycle_time) + if signal.initial_value != 0 and "GenSigStartValue" not in db.signal_defines: + db.add_signal_defines("GenSigStartValue", 'FLOAT 0 100000000000') + if "GenSigStartValue" in db.signal_defines: signal.add_attribute("GenSigStartValue", signal.phys2raw(None)) From d41de4fa0802cdd02626b012770dd9d6bd02283e Mon Sep 17 00:00:00 2001 From: Eduard Date: Mon, 15 Jul 2024 11:28:37 +0200 Subject: [PATCH 2/2] fix tests --- tests/test_cli_convert.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cli_convert.py b/tests/test_cli_convert.py index e594c89d..32a9581c 100644 --- a/tests/test_cli_convert.py +++ b/tests/test_cli_convert.py @@ -92,11 +92,11 @@ def test_delete_obsolete_defines(tmpdir, run): deleted_result = run("--deleteObsoleteDefines", inputFile, "tmp2.dbc") with open("tmp2.dbc", "rb") as fd: content = fd.read() - assert b"BA_DEF_" not in content + assert b"SomeUnneededDefine" not in content normal_result = run(inputFile, "tmp2.dbc") with open("tmp2.dbc", "rb") as fd: content = fd.read() - assert b"BA_DEF_" in content + assert b"SomeUnneededDefine" in content def test_delete_ecu(tmpdir, run): inputFile = create_dbc_with_special_char()