summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaptor Engineering Development Team <support@raptorengineering.com>2018-02-19 15:55:13 -0600
committerRaptor Engineering Development Team <support@raptorengineering.com>2018-02-19 15:55:13 -0600
commit6c1a9aa6250f871c7af0fbee2fbb9d45b4f461c7 (patch)
tree92ef824dae10fa055c047dd30acb80bf1407bf8a
parent499ce30d5a590eb2d1bfdaa468786294215d771f (diff)
downloadtalos-skeleton-6c1a9aa6250f871c7af0fbee2fbb9d45b4f461c7.tar.gz
talos-skeleton-6c1a9aa6250f871c7af0fbee2fbb9d45b4f461c7.zip
Work around unstable I2C bus
The I2C bus the FPGA is attached to is even less stable than originally thought Retry reads and use most commonly returned value as an interim workaround
-rw-r--r--pyiplledmonitor/ipl_status_led_monitor.py41
1 files changed, 23 insertions, 18 deletions
diff --git a/pyiplledmonitor/ipl_status_led_monitor.py b/pyiplledmonitor/ipl_status_led_monitor.py
index a67186a..6e36d00 100644
--- a/pyiplledmonitor/ipl_status_led_monitor.py
+++ b/pyiplledmonitor/ipl_status_led_monitor.py
@@ -69,24 +69,29 @@ class IPLStatusLEDMonitor(DbusProperties, DbusObjectManager):
def IPLLEDReadI2CByte(self, byte):
retry_number = 0
retval = 0
- comm_fail = True;
- while (comm_fail == True):
- comm_fail = False;
- try:
- proc = subprocess.Popen(["i2cget", "-y", "12", "0x31", str(byte)], stdout=subprocess.PIPE, stderr=open(os.devnull, 'wb'), shell=False)
- (out, err) = proc.communicate()
- if (proc.returncode != 0):
- comm_fail = True
- else:
- retval = int(out, 16)
- except:
- comm_fail = True;
- pass
- if (comm_fail == True):
- retry_number += 1
- if (retry_number > 16):
- break
- time.sleep(0.1)
+ candidate_values = []
+ for read_count in range(0, 64):
+ comm_fail = True;
+ while (comm_fail == True):
+ comm_fail = False;
+ try:
+ proc = subprocess.Popen(["i2cget", "-y", "12", "0x31", str(byte)], stdout=subprocess.PIPE, stderr=open(os.devnull, 'wb'), shell=False)
+ (out, err) = proc.communicate()
+ if (proc.returncode != 0):
+ comm_fail = True
+ else:
+ retval = int(out, 64)
+ except:
+ comm_fail = True;
+ pass
+ if (comm_fail == True):
+ retry_number += 1
+ if (retry_number > 64):
+ break
+ time.sleep(0.1)
+ if (comm_fail == False):
+ candidate_values.append(retval)
+ retval = max(set(candidate_values), key=candidate_values.count)
return retval
def IPLLEDCheckSystem(self):
OpenPOWER on IntegriCloud