@@ -250,11 +250,12 @@ def dump(in_db, f, **options):
250
250
if len (db .frames ) > 0 :
251
251
if max ([x .cycle_time for x in db .frames ]) > 0 :
252
252
db .add_frame_defines ("GenMsgCycleTime" , 'INT 0 65535' )
253
- if max ([x .cycle_time for y in db .frames for x in y .signals ]) > 0 :
254
- db .add_signal_defines ("GenSigCycleTime" , 'INT 0 65535' )
253
+ if len (db .signals ) > 0 :
254
+ if max ([x .cycle_time for y in db .frames for x in y .signals ]) > 0 :
255
+ db .add_signal_defines ("GenSigCycleTime" , 'INT 0 65535' )
255
256
256
- if max ([x .initial_value for y in db .frames for x in y .signals ]) > 0 or min ([x .initial_value for y in db .frames for x in y .signals ]) < 0 :
257
- db .add_signal_defines ("GenSigStartValue" , 'FLOAT 0 100000000000' )
257
+ if max ([x .initial_value for y in db .frames for x in y .signals ]) > 0 or min ([x .initial_value for y in db .frames for x in y .signals ]) < 0 :
258
+ db .add_signal_defines ("GenSigStartValue" , 'FLOAT 0 100000000000' )
258
259
259
260
260
261
@@ -786,7 +787,7 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
786
787
substring = decoded [7 :].strip ()
787
788
define_type = substring [:3 ]
788
789
substring = substring [3 :].strip ()
789
- pattern = r"^\"(.+?)\" +(.+);"
790
+ pattern = r"^\"(.+?)\" +(.+); * "
790
791
regexp = re .compile (pattern )
791
792
regexp_raw = re .compile (pattern .encode (dbc_import_encoding ))
792
793
temp = regexp .match (substring )
@@ -817,45 +818,45 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
817
818
tempba = regexp .match (decoded )
818
819
819
820
if tempba .group (1 ).strip ().startswith ("BO_ " ):
820
- regexp = re .compile (r"^BA_ +\"(.+?)\" +BO_ +(\d+) +(.+) *;" )
821
+ regexp = re .compile (r"^BA_ +\"(.+?)\" +BO_ +(\d+) +(.+) *; * " )
821
822
temp = regexp .match (decoded )
822
823
get_frame_by_id (canmatrix .ArbitrationId .from_compound_integer (int (temp .group (2 )))).add_attribute (
823
824
temp .group (1 ), temp .group (3 ))
824
825
elif tempba .group (1 ).strip ().startswith ("SG_ " ):
825
- regexp = re .compile (r"^BA_ +\"(.+?)\" +SG_ +(\d+) +(\w+) +(.+) *;" )
826
+ regexp = re .compile (r"^BA_ +\"(.+?)\" +SG_ +(\d+) +(\w+) +(.+) *; * " )
826
827
temp = regexp .match (decoded )
827
828
if temp is not None :
828
829
get_frame_by_id (canmatrix .ArbitrationId .from_compound_integer (int (temp .group (2 )))).signal_by_name (
829
830
temp .group (3 )).add_attribute (temp .group (1 ), temp .group (4 ))
830
831
elif tempba .group (1 ).strip ().startswith ("EV_ " ):
831
- regexp = re .compile (r"^BA_ +\"(.+?)\" +EV_ +(\w+) +(.*) *;" )
832
+ regexp = re .compile (r"^BA_ +\"(.+?)\" +EV_ +(\w+) +(.*) *; * " )
832
833
temp = regexp .match (decoded )
833
834
if temp is not None :
834
835
db .add_env_attribute (temp .group (2 ), temp .group (1 ), temp .group (3 ))
835
836
elif tempba .group (1 ).strip ().startswith ("BU_ " ):
836
- regexp = re .compile (r"^BA_ +\"(.*?)\" +BU_ +(\w+) +(.+) *;" )
837
+ regexp = re .compile (r"^BA_ +\"(.*?)\" +BU_ +(\w+) +(.+) *; * " )
837
838
temp = regexp .match (decoded )
838
839
db .ecu_by_name (
839
840
temp .group (2 )).add_attribute (
840
841
temp .group (1 ),
841
842
temp .group (3 ))
842
843
else :
843
844
regexp = re .compile (
844
- r"^BA_ +\"([A-Za-z0-9\-_]+)\" +([\"\w\-\.]+) *;" )
845
+ r"^BA_ +\"([A-Za-z0-9\-_]+)\" +([\"\w\-\.]+) *; * " )
845
846
temp = regexp .match (decoded )
846
847
if temp :
847
848
db .add_attribute (temp .group (1 ), temp .group (2 ))
848
849
849
850
elif decoded .startswith ("SIG_GROUP_ " ):
850
- regexp = re .compile (r"^SIG_GROUP_ +(\w+) +(\w+) +(\w+) +\:(.*) *;" )
851
+ regexp = re .compile (r"^SIG_GROUP_ +(\w+) +(\w+) +(\w+) +\:(.*) *; * " )
851
852
temp = regexp .match (decoded )
852
853
frame = get_frame_by_id (canmatrix .ArbitrationId .from_compound_integer (int (temp .group (1 ))))
853
854
if frame is not None :
854
855
signal_array = temp .group (4 ).split (' ' )
855
856
frame .add_signal_group (temp .group (2 ), temp .group (3 ), signal_array ) # todo wrong annotation in canmatrix? Id is a string?
856
857
857
858
elif decoded .startswith ("SIG_VALTYPE_ " ):
858
- regexp = re .compile (r"^SIG_VALTYPE_ +(\w+) +(\w+)\s*\:(.*) *;" )
859
+ regexp = re .compile (r"^SIG_VALTYPE_ +(\w+) +(\w+)\s*\:(.*) *; * " )
859
860
temp = regexp .match (decoded )
860
861
frame = get_frame_by_id (canmatrix .ArbitrationId .from_compound_integer (int (temp .group (1 ))))
861
862
if frame :
@@ -873,7 +874,7 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
873
874
db .add_define_default (temp .group (1 ),
874
875
temp_raw .group (2 ).decode (dbc_import_encoding ))
875
876
elif decoded .startswith ("SG_MUL_VAL_ " ):
876
- pattern = r"^SG_MUL_VAL_ +([0-9]+) +([\w\-]+) +([\w\-]+) +(.*) *;"
877
+ pattern = r"^SG_MUL_VAL_ +([0-9]+) +([\w\-]+) +([\w\-]+) +(.*) *; * "
877
878
regexp = re .compile (pattern )
878
879
temp = regexp .match (decoded )
879
880
if temp :
@@ -892,7 +893,7 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
892
893
mux_val_max_number = int (mux_val_max )
893
894
signal .mux_val_grp .append ([mux_val_min_number , mux_val_max_number ])
894
895
elif decoded .startswith ("EV_ " ):
895
- pattern = r"^EV_ +([\w\-\_]+?) *\: +([0-9]+) +\[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] +\"(.*?)\" +([0-9.+\-eE]+) +([0-9.+\-eE]+) +([\w\-]+?) +(.*);"
896
+ pattern = r"^EV_ +([\w\-\_]+?) *\: +([0-9]+) +\[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] +\"(.*?)\" +([0-9.+\-eE]+) +([0-9.+\-eE]+) +([\w\-]+?) +(.*); * "
896
897
regexp = re .compile (pattern )
897
898
temp = regexp .match (decoded )
898
899
0 commit comments