diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2022-01-19 15:49:11 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2022-01-19 16:02:54 -0500 |
commit | bc5fe26a8d17a132d85c689aacb60688ea705132 (patch) | |
tree | 11e8ef4e01d48effb19c20b4c6ee123d363b7689 /qolab/hardware | |
parent | 995227e5d26baa45e9335e618a1e96ba9ac054f8 (diff) | |
download | qolab-bc5fe26a8d17a132d85c689aacb60688ea705132.tar.gz qolab-bc5fe26a8d17a132d85c689aacb60688ea705132.zip |
improved error messaging with logger in i800
Diffstat (limited to 'qolab/hardware')
-rw-r--r-- | qolab/hardware/i_server/i800.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/qolab/hardware/i_server/i800.py b/qolab/hardware/i_server/i800.py index b7b2fc9..264316a 100644 --- a/qolab/hardware/i_server/i800.py +++ b/qolab/hardware/i_server/i800.py @@ -10,6 +10,9 @@ from qolab.hardware.basic import BasicInstrument from cachetools import cached, TTLCache import socket +import logging +logger = logging.getLogger('qolab.hardware.i_server.i800') + class I800(BasicInstrument): """ Newport i800 series controller, should work with similar Omega controllers """ TTL_MEASURED = 30 # Time To Live for device measured things, i.e. Temperature @@ -39,14 +42,14 @@ class I800(BasicInstrument): 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}': + lreply=rlist[-1]; # we will use the last one + if lreply[0:5] != f'{modbus_cmnd}': # check the proper echo response - print(f'Warning: expected {modbus_cmnd} but got {reply[0:5]}') + logger.warning(f'Warning: expected {modbus_cmnd} but got {lreply[0:5]} in full set {reply}') if trials > 0: return self.query(cmnd, trials -1 ) return None - return reply[5:] + return lreply[5:] @BasicInstrument.tsdb_append @cached(cache=TTLCache(maxsize=1, ttl=TTL_MEASURED)) @@ -74,7 +77,7 @@ class I800(BasicInstrument): elif raw & (0b100 << 20): scale = 100 else: - print(f'Error: unknown decimal point position in decoded {spStr}') + logger.error(f'Error: unknown decimal point position in decoded {spStr} {bin(raw)}') return float('nan') val = raw & 0xFFFFF |