numat / alicat

Python driver and command line tool for Alicat mass flow controllers.
GNU General Public License v2.0
22 stars 28 forks source link

Occasional bad reads with `=` are not handled well #22

Closed alexrudd2 closed 3 years ago

alexrudd2 commented 3 years ago
File "/Users/a.ruddick/Documents/github/alicat/alicat/tcp.py", line 310, in print_state
    state = await flow_controller.get()
  File "/Users/a.ruddick/Documents/github/alicat/alicat/tcp.py", line 213, in get
    state = await FlowMeter.get(self)
  File "/Users/a.ruddick/Documents/github/alicat/alicat/tcp.py", line 90, in get
    return {k: (v if k == self.keys[-1] else float(v))
  File "/Users/a.ruddick/Documents/github/alicat/alicat/tcp.py", line 90, in <dictcomp>
    return {k: (v if k == self.keys[-1] else float(v))
ValueError: could not convert string to float: '='

The above Exception is thrown about 10-20% of the time when using the command line to read a kilo lab flowmeter through the serial gateway. I suspect my command line driver is actually intercepting responses intended for the kilo lab controller when its asking for e.g. control point. I believe Alicats respond to such requests with R{register}=xyz or something similar. The protocol was never meant to handle multiple simultaneous connections, but it could at least catch and log the unexpected value.

alexrudd2 commented 3 years ago

Yep, the reply is ['122', '=', '34'] which is a reply to querying the value of register 122 (flow or pressure control).

here is the code that is constantly requesting the control point. If get() gets a reply intended for _set_control_point() or vice-versa they both are unhappy with their replies.