Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible quick fix for issue #781 #809

Merged
merged 4 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading