Skip to content

Commit

Permalink
possible quick fix for issue #781 (#809)
Browse files Browse the repository at this point in the history
* possible quick fix for issue #781 (DBC <=> XLSX initial_value)
  • Loading branch information
ebroecker authored Jul 15, 2024
1 parent ef9f709 commit 261f8c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/canmatrix/formats/dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
if signal.phys2raw(None) != 0:
if db.signal_defines["GenSigStartValue"].defaultValue is None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 261f8c3

Please sign in to comment.