GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 3319fbb8 authored by bliss administrator's avatar bliss administrator

Version to hide protocol and timeout problems.

parent 84a3c1f8
......@@ -26,28 +26,40 @@ class ForceMeter(SamplingCounterController):
counter = self.create_counter(
SamplingCounter, cname, mode=SamplingMode.SINGLE
)
self.max_retries = 3
def read(self, counter):
self._cnx.flush()
retry = 0
while retry < self.max_retries:
try:
self._cnx.flush()
#clear = b"\001" * 63
#self._cnx.write(clear)
ret = self._cnx.readline()
#print (ret)
ret = self._cnx.readline()
#print (ret)
try:
value = float(ret[3:10])
# could not read counter value
except ValueError:
print (f"Prtocol error on forcemeter serial line! ret = {ret}")
ret = self._cnx.readline()
value = float(ret[3:10])
#print (f"force value = {value}")
return value
#clear = b"\001" * 63
#self._cnx.write(clear)
ret = self._cnx.readline()
#print (ret)
ret = self._cnx.readline()
#print (ret)
try:
value = float(ret[3:10])
# could not read counter value
except ValueError:
ret = self._cnx.readline()
value = float(ret[3:10])
#print (f"force value = {value}")
return value
except (SerialTimeout) as e:
retry = retry + 1
print (f"Timeout error on forcemeter serial line! Retry = {retry}")
sys.excepthook(*sys.exc_info())
if retry >= self.max_retries:
# re-throw the caught exception
raise e
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment