Skip to content

Commit

Permalink
Reorganize error handling for cxfer
Browse files Browse the repository at this point in the history
  • Loading branch information
hkzlab committed Sep 2, 2024
1 parent 1f7f955 commit 53f4672
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/dpdumper/hl_board_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ def read_ic(cls, ser: serial.Serial, cmd_class: type[HardwareBoardCommands], ic:

data_normal = cmd_class.cxfer_read(ic.address, ic.data, hi_pins, upd_callback, ser)

if not data_normal:
raise IOError('Unable to read data from IC')

# If we need to check for Hi-Z, we need to forcefully set data pins to high and then redo the dump
if check_hiz:
print('Performing a second pass to detect Hi-Z pins!')
hi_pins = list(set(hi_pins + ic.data))
data_invert = cmd_class.cxfer_read(ic.address, ic.data, hi_pins, upd_callback, ser)
except Exception as exc:
_LOGGER.critical(exc)
finally:
ser.reset_input_buffer()
ser.reset_output_buffer()
Expand All @@ -108,12 +109,10 @@ def read_ic(cls, ser: serial.Serial, cmd_class: type[HardwareBoardCommands], ic:
dni = int.from_bytes(bytes(dn))
dii = int.from_bytes(bytes(di))
read_data.append(DataElement(data=dni, z_mask=dni^dii))
elif data_normal:
else:
for dn in DPLibUtils.iter_grouper(data_normal, data_width, 0):
dni = int.from_bytes(bytes(dn))
read_data.append(DataElement(data=dni))
else:
raise IOError('Data array is not available!')

return read_data[:addr_combs]

Expand Down

0 comments on commit 53f4672

Please sign in to comment.