So i made a python script which can convert a DBC in an Excel and back using the library cantools. Turning the DBC-file into an Excel is no problem, but if i want to create a DBC out of the Excel-file and i assign the J1939 standard to a message, it won't show up in the DBC-file. Instead it only shows CAN extended.
I gave the message with the J1939 standard the attribute protocol="j1939"
and save the DBC-file with dumpfile(db, "__.dbc")
. Does anyone know if there is a special setting how i have to save the DBC-file, or if it is possible at all with cantools?
Here a short code example:
signal1 = cantools.db.can.Signal(name="signal1", start=1, length=8,
is_signed=True, scale=1, offset=0, unit=None, spn=1586)
frame1 = cantools.db.can.Message(name="Msg1", frame_id=0x16fd3b09, protocol="j1939",
is_extended_frame=True, length=8, signals=[signal1],
cycle_time=50, senders=["A"])
db_cantools = cantools.db.can.Database(messages=[frame1])
cantools.db.dump_file(db_cantools, "test_db.dbc")
Picture of the DBC file in Vector CANdb (ID-Format is CAN Extended and not J1939).
For a different DBC file (which contains J1939 messages) i found with
db.dbc.attributes
a dict of attributes in my database:
OrderedDict([('ProtocolType', attribute('ProtocolType', J1939)),...)
I don't know if that would be the key, to create this attribute, but I also don't know how i do that. Also in the attributes of the messages i find j1939
but same problem (don't know how to create them).
Edit: I tried to create a J1939 template DBC file and added the messages there. It works, but messages which use the ID-Format CAN Standard or CAN Extended also turn into the ID-Format J1939.