Skip to content

Commit 29b5767

Browse files
committed
possible fix for #490
1 parent 4057540 commit 29b5767

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/canmatrix/formats/dbc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
545545
db.frames.append(frame)
546546
add_frame_by_id(frame)
547547
elif decoded.startswith("SG_ "):
548-
pattern = r"^SG_ +(\w+) *: *(\d+)\|(\d+)@(\d+)([\+|\-]) +\(([0-9.+\-eE]+), *([0-9.+\-eE]+)\) +\[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] +\"(.*)\" +(.*)"
548+
pattern = r"^SG_ +(\w+) *: *(\d+)\|(\d+)@(\d+)([\+|\-]) *\(([0-9.+\-eE]+), *([0-9.+\-eE]+)\) *\[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] +\"(.*)\" +(.*)"
549549
regexp = re.compile(pattern)
550550
temp = regexp.match(decoded)
551551
regexp_raw = re.compile(pattern.encode(dbc_import_encoding))
@@ -577,7 +577,7 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
577577
frame.add_signal(temp_signal)
578578
# db.frames.addSignalToLastFrame(tempSig)
579579
else:
580-
pattern = r"^SG_ +(.+?) +(.+?) *: *(\d+)\|(\d+)@(\d+)([\+|\-]) +\(([0-9.+\-eE]+),([0-9.+\-eE]+)\) +\[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] +\"(.*)\" +(.*)"
580+
pattern = r"^SG_ +(.+?) +(.+?) *: *(\d+)\|(\d+)@(\d+)([\+|\-]) *\(([0-9.+\-eE]+),([0-9.+\-eE]+)\) *\[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] +\"(.*)\" +(.*)"
581581
regexp = re.compile(pattern)
582582
regexp_raw = re.compile(pattern.encode(dbc_import_encoding))
583583
temp = regexp.match(decoded)

src/canmatrix/tests/test_dbc.py

+9
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,12 @@ def test_signal_inital_value():
429429
outdbc = io.BytesIO()
430430
canmatrix.formats.dump(matrix, outdbc, "dbc")
431431
assert 'BA_ "GenSigStartValue" SG_ 17 sig1 2.7;' in outdbc.getvalue().decode('utf8')
432+
433+
def test_missing_space():
434+
dbc = io.BytesIO(textwrap.dedent(u'''\
435+
BO_ 17 Frame_1: 8 Vector__XXX
436+
SG_ sig1 : 0|8@1-(1,0)[0|0] "" Vector__XXX
437+
''').encode('utf-8'))
438+
matrix = canmatrix.formats.dbc.load(dbc, dbcImportEncoding="utf8")
439+
assert matrix.frames[0].signals[0].name == "sig1"
440+

0 commit comments

Comments
 (0)