From 0bbc3958b02f1df4b4e8d4a476297d27bfe8f4ab Mon Sep 17 00:00:00 2001 From: dspitzba <daniel.spitzbart@cern.ch> Date: Fri, 23 Jun 2023 13:12:30 -0400 Subject: [PATCH 1/4] raise proper errors when I2C transactions fail, fix prototype VTRx reset routine for channel 0 --- tamalero/LPGBT.py | 14 ++++---------- tamalero/ReadoutBoard.py | 3 ++- tamalero/SCA.py | 3 +-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tamalero/LPGBT.py b/tamalero/LPGBT.py index a142c05..398f345 100644 --- a/tamalero/LPGBT.py +++ b/tamalero/LPGBT.py @@ -1112,7 +1112,7 @@ class LPGBT(RegParser): elif type(val == list): data_bytes = val else: - raise("data must be an int or list of ints") + raise RuntimeError("Data must be an int or list of ints") nbytes = len(adr_bytes+data_bytes) @@ -1152,9 +1152,7 @@ class LPGBT(RegParser): status = self.rd_adr(i2cm0status+OFFSET_RD) retries += 1 if retries > 50: - if verbose: - print ("Write not successfull!") - break + raise TimeoutError(f"I2C write failed after 50 retries, {status=}") def I2C_read(self, reg=0x0, master=2, slave_addr=0x70, nbytes=1, adr_nbytes=2, freq=2, verbose=False): #https://gitlab.cern.ch/lpgbt/pigbt/-/blob/master/backend/apiapp/lpgbtLib/lowLevelDrivers/MASTERI2C.py#L83 @@ -1234,9 +1232,7 @@ class LPGBT(RegParser): #print(f"Updating status: {status}, retries: {retries}") retries += 1 if retries > 50: - if verbose: - print ("Write not successfull!") - return None + raise TimeoutError(f"I2C transaction failed after 50 retries because of an issue in writing the register address, {status=}") ################################################################################ # Write the data @@ -1264,9 +1260,7 @@ class LPGBT(RegParser): status = self.rd_adr(i2cm0status+OFFSET_RD) retries += 1 if retries > 50: - if verbose: - print ("Read not successfull!") - return None + raise TimeoutError(f"I2C transaction failed after 50 retries because of an issue in reading back the data, {status=}") read_values = [] diff --git a/tamalero/ReadoutBoard.py b/tamalero/ReadoutBoard.py index e7ad6ad..af084cf 100644 --- a/tamalero/ReadoutBoard.py +++ b/tamalero/ReadoutBoard.py @@ -333,7 +333,8 @@ class ReadoutBoard: if self.VTRX.ver == 'production': self.VTRX.reset() elif self.VTRX.ver == 'prototype': - self.VTRX.reset(toggle_channels=[0]) + #self.VTRX.reset(toggle_channels=[0]) + self.VTRX.reset() else: print ("Don't know how to reset VTRX version", self.VTRX.ver) self.VTRX.configure(trigger=trigger) diff --git a/tamalero/SCA.py b/tamalero/SCA.py index 78d7033..4b1c241 100644 --- a/tamalero/SCA.py +++ b/tamalero/SCA.py @@ -601,8 +601,7 @@ class SCA: if success: return True else: - #print("write not successful: status = {}".format(status)) - return False + raise RuntimeError(f"I2C write not successful, {status=}") def I2C_write_ctrl(self, channel, data): #enable channel -- GitLab From 6d469187b804fbca1474d17fe4b79d0121bedc2d Mon Sep 17 00:00:00 2001 From: dspitzba <daniel.spitzbart@cern.ch> Date: Fri, 23 Jun 2023 13:14:25 -0400 Subject: [PATCH 2/4] bump FW version to 2.1.11 --- tamalero/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tamalero/__init__.py b/tamalero/__init__.py index d378a1a..3aaa979 100644 --- a/tamalero/__init__.py +++ b/tamalero/__init__.py @@ -1,2 +1,2 @@ __version__ = "0.1.0" -__fw_version__ = "2.1.10" +__fw_version__ = "2.1.11" -- GitLab From 20e61d3607519f1f6c425d7cfb7adb419bbe7f99 Mon Sep 17 00:00:00 2001 From: dspitzba <daniel.spitzbart@cern.ch> Date: Fri, 23 Jun 2023 14:05:46 -0400 Subject: [PATCH 3/4] using actual value --- tamalero/LPGBT.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tamalero/LPGBT.py b/tamalero/LPGBT.py index 398f345..0e81283 100644 --- a/tamalero/LPGBT.py +++ b/tamalero/LPGBT.py @@ -1149,7 +1149,7 @@ class LPGBT(RegParser): status = self.rd_adr(i2cm0status+OFFSET_RD) retries = 0 while (status != self.LPGBT_CONST.I2CM_SR_SUCC_bm): - status = self.rd_adr(i2cm0status+OFFSET_RD) + status = self.rd_adr(i2cm0status+OFFSET_RD).value() retries += 1 if retries > 50: raise TimeoutError(f"I2C write failed after 50 retries, {status=}") @@ -1227,7 +1227,7 @@ class LPGBT(RegParser): retries = 0 while (status != self.LPGBT_CONST.I2CM_SR_SUCC_bm): - status = self.rd_adr(i2cm0status+OFFSET_RD) + status = self.rd_adr(i2cm0status+OFFSET_RD).value() # debugging #print(f"Updating status: {status}, retries: {retries}") retries += 1 @@ -1257,7 +1257,7 @@ class LPGBT(RegParser): retries = 0 while (status != self.LPGBT_CONST.I2CM_SR_SUCC_bm): - status = self.rd_adr(i2cm0status+OFFSET_RD) + status = self.rd_adr(i2cm0status+OFFSET_RD).value() retries += 1 if retries > 50: raise TimeoutError(f"I2C transaction failed after 50 retries because of an issue in reading back the data, {status=}") -- GitLab From 81367a9a4c7904691949d25ef2f4b0a7d836793e Mon Sep 17 00:00:00 2001 From: dspitzba <daniel.spitzbart@cern.ch> Date: Fri, 23 Jun 2023 14:13:01 -0400 Subject: [PATCH 4/4] making ETROC is_connected compatible with failing I2C_reads --- tamalero/ETROC.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tamalero/ETROC.py b/tamalero/ETROC.py index 7a88e3b..b77a87d 100644 --- a/tamalero/ETROC.py +++ b/tamalero/ETROC.py @@ -255,7 +255,14 @@ class ETROC(): # ============================ def is_connected(self): - self.connected = self.I2C_read(0x0) # read from first register (default value 0x2C) + try: + self.connected = self.I2C_read(0x0) # read from first register (default value 0x2C) + except TimeoutError: + # this comes from lpGBT read fails + self.connected = False + except RuntimeError: + # this comes from SCA read fails + self.connected = False return self.connected def get_elink_status(self): -- GitLab