Skip to content

Commit

Permalink
fix reading additionalFrameAttributes and additionalSignalAttributes (#…
Browse files Browse the repository at this point in the history
…800)

Co-authored-by: Eduard Bröcker <conuslt@eduard-broecker.de>
  • Loading branch information
ebroecker and Eduard Bröcker authored Jun 20, 2024
1 parent db8298d commit 8b751fa
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/canmatrix/formats/xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def load(file, **options):

ecu_start = ecu_end = 0

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

if 'Byteorder' in column_heads:
ecu_start = column_heads.index('Byteorder') + 1
Expand Down Expand Up @@ -407,6 +407,7 @@ def get_if_possible(my_row, my_value, default=None):
cycle_time = get_if_possible(row, 'Cycle Time [ms]', '0')
launch_type = get_if_possible(row, 'Launch Type')
dlc = 8

# launch_param = get_if_possible(row, 'Launch Parameter', '0')
# launch_param = str(int(launch_param))

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

for col_head in column_heads:
if col_head.startswith("frame."):
command_str = col_head.replace("frame", "new_frame")
command_str += "=" + str(row[column_heads.index(col_head)].value)
exec(command_str)

db.add_frame(new_frame)

# eval launch_type
Expand Down Expand Up @@ -482,6 +489,7 @@ def get_if_possible(my_row, my_value, default=None):
bitNumbering=1,
startLittle=True
)

if signal_name is not None:
new_frame.add_signal(new_signal)
new_signal.add_comment(signal_comment)
Expand Down Expand Up @@ -534,6 +542,14 @@ def get_if_possible(my_row, my_value, default=None):
new_signal.min = None
new_signal.max = None

for col_head in column_heads: # todo explain this possibly dangerous code with eval
if col_head.startswith("signal."):
command_str = col_head.replace("signal", "new_signal")
command_str += "=" + str(row[column_heads.index(col_head)].value)
exec(command_str)



# dlc-estimation / dlc is not in xls, thus calculate a minimum-dlc:
for frame in db.frames:
frame.update_receiver()
Expand Down

0 comments on commit 8b751fa

Please sign in to comment.