Skip to content

Commit 8b751fa

Browse files
ebroeckerEduard Bröcker
and
Eduard Bröcker
authored
fix reading additionalFrameAttributes and additionalSignalAttributes (#800)
Co-authored-by: Eduard Bröcker <[email protected]>
1 parent db8298d commit 8b751fa

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/canmatrix/formats/xlsx.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def load(file, **options):
368368

369369
ecu_start = ecu_end = 0
370370

371-
column_heads = [sheet.cell(1,a).value for a in range(1, sheet.max_column)]
371+
column_heads = [sheet.cell(1,a).value for a in range(1, sheet.max_column+1)]
372372

373373
if 'Byteorder' in column_heads:
374374
ecu_start = column_heads.index('Byteorder') + 1
@@ -407,6 +407,7 @@ def get_if_possible(my_row, my_value, default=None):
407407
cycle_time = get_if_possible(row, 'Cycle Time [ms]', '0')
408408
launch_type = get_if_possible(row, 'Launch Type')
409409
dlc = 8
410+
410411
# launch_param = get_if_possible(row, 'Launch Parameter', '0')
411412
# launch_param = str(int(launch_param))
412413

@@ -415,6 +416,12 @@ def get_if_possible(my_row, my_value, default=None):
415416
else:
416417
new_frame = canmatrix.Frame(frame_name, arbitration_id=int(frame_id[:-1], 16), size=dlc)
417418

419+
for col_head in column_heads:
420+
if col_head.startswith("frame."):
421+
command_str = col_head.replace("frame", "new_frame")
422+
command_str += "=" + str(row[column_heads.index(col_head)].value)
423+
exec(command_str)
424+
418425
db.add_frame(new_frame)
419426

420427
# eval launch_type
@@ -482,6 +489,7 @@ def get_if_possible(my_row, my_value, default=None):
482489
bitNumbering=1,
483490
startLittle=True
484491
)
492+
485493
if signal_name is not None:
486494
new_frame.add_signal(new_signal)
487495
new_signal.add_comment(signal_comment)
@@ -534,6 +542,14 @@ def get_if_possible(my_row, my_value, default=None):
534542
new_signal.min = None
535543
new_signal.max = None
536544

545+
for col_head in column_heads: # todo explain this possibly dangerous code with eval
546+
if col_head.startswith("signal."):
547+
command_str = col_head.replace("signal", "new_signal")
548+
command_str += "=" + str(row[column_heads.index(col_head)].value)
549+
exec(command_str)
550+
551+
552+
537553
# dlc-estimation / dlc is not in xls, thus calculate a minimum-dlc:
538554
for frame in db.frames:
539555
frame.update_receiver()

0 commit comments

Comments
 (0)