diff options
Diffstat (limited to 'qolab/hardware/i_server')
-rw-r--r-- | qolab/hardware/i_server/i800.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/qolab/hardware/i_server/i800.py b/qolab/hardware/i_server/i800.py index 2b3f55f..b7b2fc9 100644 --- a/qolab/hardware/i_server/i800.py +++ b/qolab/hardware/i_server/i800.py @@ -38,13 +38,15 @@ class I800(BasicInstrument): s.send(qstr.encode('ascii')) reply = s.recv(100).decode('ascii') s.close() + rlist=reply.split(); # occasionally there is more than one reply, it also removes \r + reply=rlist[-1]; # we will use the last one if reply[0:5] != f'{modbus_cmnd}': # check the proper echo response print(f'Warning: expected {modbus_cmnd} but got {reply[0:5]}') if trials > 0: return self.query(cmnd, trials -1 ) return None - return reply[5:-1] # last symbol is '\r' + return reply[5:] @BasicInstrument.tsdb_append @cached(cache=TTLCache(maxsize=1, ttl=TTL_MEASURED)) @@ -72,11 +74,11 @@ class I800(BasicInstrument): elif raw & (0b100 << 20): scale = 100 else: - print('Error: unknown decimal point position') - return None + print(f'Error: unknown decimal point position in decoded {spStr}') + return float('nan') val = raw & 0xFFFFF - return(sign*val/scale) + return float(sign*val/scale) @BasicInstrument.tsdb_append @cached(cache=TTLCache(maxsize=1, ttl=TTL_SEATABLES)) |