diff --git a/pumpAgilent.py b/pumpAgilent.py index 75c02b4a9f6eea74709077714ce5f7d441c467d5..aeac2f3942d6ada690954ac847a9dea0e39e44b9 100755 --- a/pumpAgilent.py +++ b/pumpAgilent.py @@ -79,8 +79,14 @@ class pumpAgilent: def getPressure(self): stat = self.serWriteAndRecieve(b"\002\200\062\062\064\060\003\070\067") if stat is not None: - stat = stat[4: 12] - return float(stat) + print(":".join("{:02x}".format(ord(c)) for c in stat)) + hdr = stat.find("2240") + stat = stat[hdr + 3: hdr + 11] + try: + pressure = float(stat) + except ValueError: + pressure = 1.20E+03 + return pressure return 1.20E+03 def getRpm(self):