@@ -471,8 +471,8 @@ def add_frame_by_id(frame): # type: (canmatrix.Frame) -> None
471
471
l = line .strip ()
472
472
if l .__len__ () == 0 :
473
473
continue
474
- # try:
475
- if 1 == 1 :
474
+ try :
475
+ # if 1==1:
476
476
if followUp == FollowUps .signalComment :
477
477
try :
478
478
comment += "\n " + \
@@ -761,7 +761,7 @@ def add_frame_by_id(frame): # type: (canmatrix.Frame) -> None
761
761
substring = decoded [7 :].strip ()
762
762
define_type = substring [:3 ]
763
763
substring = substring [3 :].strip ()
764
- pattern = r"^\"([A-Za-z0-9\-_]+ )\" +(.+);"
764
+ pattern = r"^\"(.+? )\" +(.+);"
765
765
regexp = re .compile (pattern )
766
766
regexp_raw = re .compile (pattern .encode (dbcImportEncoding ))
767
767
temp = regexp .match (substring )
@@ -778,7 +778,7 @@ def add_frame_by_id(frame): # type: (canmatrix.Frame) -> None
778
778
db .add_env_defines (temp .group (1 ), temp_raw .group (2 ).decode (dbcImportEncoding ))
779
779
780
780
elif decoded .startswith ("BA_DEF_ " ):
781
- pattern = r"^BA_DEF_ +\"([A-Za-z0-9\-_]+ )\" +(.+);"
781
+ pattern = r"^BA_DEF_ +\"(.+? )\" +(.+);"
782
782
regexp = re .compile (pattern )
783
783
regexp_raw = re .compile (pattern .encode (dbcImportEncoding ))
784
784
temp = regexp .match (decoded )
@@ -788,35 +788,35 @@ def add_frame_by_id(frame): # type: (canmatrix.Frame) -> None
788
788
temp_raw .group (2 ).decode (dbcImportEncoding ))
789
789
790
790
elif decoded .startswith ("BA_ " ):
791
- regexp = re .compile (r"^BA_ +\"[A-Za-z0-9[\-_ .]+ \" +(.+)" )
791
+ regexp = re .compile (r"^BA_ +\".+? \" +(.+)" )
792
792
tempba = regexp .match (decoded )
793
793
794
794
if tempba .group (1 ).strip ().startswith ("BO_ " ):
795
- regexp = re .compile (r"^BA_ +\"(.* )\" +BO_ +(\w +) +(.+);" )
795
+ regexp = re .compile (r"^BA_ +\"(.+? )\" +BO_ +(\d +) +(.+);" )
796
796
temp = regexp .match (decoded )
797
797
get_frame_by_id (canmatrix .ArbitrationId .from_compound_integer (int (temp .group (2 )))).add_attribute (
798
798
temp .group (1 ), temp .group (3 ))
799
799
elif tempba .group (1 ).strip ().startswith ("SG_ " ):
800
- regexp = re .compile (r"^BA_ +\"(.* )\" +SG_ +(\w +) +(\w+) +(.+);" )
800
+ regexp = re .compile (r"^BA_ +\"(.+? )\" +SG_ +(\d +) +(\w+) +(.+);" )
801
801
temp = regexp .match (decoded )
802
802
if temp != None :
803
803
get_frame_by_id (canmatrix .ArbitrationId .from_compound_integer (int (temp .group (2 )))).signal_by_name (
804
804
temp .group (3 )).add_attribute (temp .group (1 ), temp .group (4 ))
805
805
elif tempba .group (1 ).strip ().startswith ("EV_ " ):
806
- regexp = re .compile (r"^BA_ +\"(.* )\" +EV_ +(. +) +(.+ );" )
806
+ regexp = re .compile (r"^BA_ +\"(.+? )\" +EV_ +(\w +) +(.* );" )
807
807
temp = regexp .match (decoded )
808
808
if temp != None :
809
809
db .add_env_attribute (temp .group (2 ),temp .group (1 ),temp .group (3 ))
810
810
elif tempba .group (1 ).strip ().startswith ("BU_ " ):
811
- regexp = re .compile (r"^BA_ +\"(.*)\" +BU_ +(\w+) +(.+);" )
811
+ regexp = re .compile (r"^BA_ +\"(.*? )\" +BU_ +(\w+) +(.+);" )
812
812
temp = regexp .match (decoded )
813
813
db .ecu_by_name (
814
814
temp .group (2 )).add_attribute (
815
815
temp .group (1 ),
816
816
temp .group (3 ))
817
817
else :
818
818
regexp = re .compile (
819
- r"^BA_ +\"([A-Za-z0-9\-_]+)\" +([\"A-Za-z0-9\-_ \.]+);" )
819
+ r"^BA_ +\"([A-Za-z0-9\-_]+)\" +([\"\w\- \.]+);" )
820
820
temp = regexp .match (decoded )
821
821
if temp :
822
822
db .add_attribute (temp .group (1 ), temp .group (2 ))
@@ -839,7 +839,7 @@ def add_frame_by_id(frame): # type: (canmatrix.Frame) -> None
839
839
# SIG_VALTYPE_ 0 float : 1;
840
840
841
841
elif decoded .startswith ("BA_DEF_DEF_ " ):
842
- pattern = r"^BA_DEF_DEF_ +\"([A-Za-z0-9\-_\.]+ )\" +(.+)\;"
842
+ pattern = r"^BA_DEF_DEF_ +\"(.+? )\" +(.+? )\;"
843
843
regexp = re .compile (pattern )
844
844
regexp_raw = re .compile (pattern .encode (dbcImportEncoding ))
845
845
temp = regexp .match (decoded )
@@ -848,7 +848,7 @@ def add_frame_by_id(frame): # type: (canmatrix.Frame) -> None
848
848
db .add_define_default (temp .group (1 ),
849
849
temp_raw .group (2 ).decode (dbcImportEncoding ))
850
850
elif decoded .startswith ("SG_MUL_VAL_ " ):
851
- pattern = r"^SG_MUL_VAL_ +([0-9]+) +([A-Za-z0-9\-_ ]+) +([A-Za-z0-9\-_ ]+) +([0-9]+)\-([0-9]+) *;"
851
+ pattern = r"^SG_MUL_VAL_ +([0-9]+) +([\w\- ]+) +([\w\- ]+) +([0-9]+)\-([0-9]+) *;"
852
852
regexp = re .compile (pattern )
853
853
regexp_raw = re .compile (pattern .encode (dbcImportEncoding ))
854
854
temp = regexp .match (decoded )
@@ -867,7 +867,7 @@ def add_frame_by_id(frame): # type: (canmatrix.Frame) -> None
867
867
signal .mux_val_min = muxValMin
868
868
signal .mux_val_max = muxValMax
869
869
elif decoded .startswith ("EV_ " ):
870
- pattern = r"^EV_ +([A-Za-z0-9\- _]+) *\: +([0-9]+) +\[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] +\"(\w* )\" +([0-9.+\-eE]+) +([0-9.+\-eE]+) +([A-Za-z0-9\-_]+ ) +(.*);"
870
+ pattern = r"^EV_ +([\w\-\ _]+? ) *\: +([0-9]+) +\[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] +\"(.*? )\" +([0-9.+\-eE]+) +([0-9.+\-eE]+) +([\w\-]+? ) +(.*);"
871
871
regexp = re .compile (pattern )
872
872
temp = regexp .match (decoded )
873
873
@@ -885,8 +885,8 @@ def add_frame_by_id(frame): # type: (canmatrix.Frame) -> None
885
885
"accessType" : accessType , "accessNodes" : accessNodes })
886
886
887
887
888
- else :
889
- # except:
888
+ # else:
889
+ except :
890
890
print ("error with line no: %d" % i )
891
891
print (line )
892
892
# Backtracking
0 commit comments