Skip to content

Commit

Permalink
possible fix for #242
Browse files Browse the repository at this point in the history
  • Loading branch information
ebroecker committed Aug 14, 2019
1 parent 182f78a commit 921e4ec
Show file tree
Hide file tree
Showing 2 changed files with 622 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/canmatrix/formats/dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,21 @@ def dump(in_db, f, **options):
if whitespace_replacement in ['', None] or {' ', '\t'}.intersection(whitespace_replacement):
logger.warning("Settings may result in whitespace in DBC variable names. This is not supported by the DBC format.")

if db.contains_fd and db.contains_j1939:
db.add_frame_defines("VFrameFormat",
'ENUM "StandardCAN","ExtendedCAN","StandardCAN_FD","ExtendedCAN_FD","J1939PG"')
logger.warning("dbc export not fully compatible to candb, because both J1939 and CAN_FD frames are defined")

elif db.contains_fd:
db.add_global_defines("BusType", "STRING")
db.add_attribute("BusType", "CAN FD")
db.add_frame_defines("VFrameFormat", 'ENUM "StandardCAN","ExtendedCAN","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","StandardCAN_FD","ExtendedCAN_FD"')
elif db.contains_j1939:
db.add_global_defines("ProtocolType", "STRING")
db.add_attribute("ProtocolType", "J1939")
db.add_frame_defines("VFrameFormat", 'ENUM "StandardCAN","ExtendedCAN","reserved","J1939PG"')

if db.contains_fd or db.contains_j1939:
if db.contains_fd:
db.add_global_defines("BusType", "STRING")
db.add_attribute("BusType", "CAN FD")
db.add_frame_defines("VFrameFormat", 'ENUM "StandardCAN","ExtendedCAN","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","StandardCAN_FD","ExtendedCAN_FD"')
elif db.contains_j1939:
db.add_global_defines("ProtocolType", "STRING")
db.add_attribute("ProtocolType", "J1939")
db.add_frame_defines("VFrameFormat", 'ENUM "StandardCAN","ExtendedCAN","StandardCAN_FD","ExtendedCAN_FD","J1939PG"')
for frame in db.frames:
if frame.is_fd:
if frame.arbitration_id.extended:
Expand Down
Loading

0 comments on commit 921e4ec

Please sign in to comment.