Skip to content

Commit

Permalink
Read the status word using read_raw
Browse files Browse the repository at this point in the history
Changed the read to use `read_raw` to read the instrument. Thus,
no need to re-encode the status word using `bytes`.
  • Loading branch information
trappitsch committed Sep 14, 2020
1 parent 321b925 commit c0224ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions instruments/keithley/keithley195.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ def get_status_word(self):
:return: String containing setting information of the instrument
:rtype: `str`
"""
return self.query('U0DX')
self.sendcmd('U0DX')
return self._file.read_raw()

@staticmethod
def parse_status_word(statusword): # pylint: disable=too-many-locals
Expand All @@ -294,14 +295,13 @@ def parse_status_word(statusword): # pylint: disable=too-many-locals
:return: A parsed version of the status word as a Python dictionary
:rtype: `dict`
"""
if statusword[:3] != '195':
if statusword[:3] != b'195':
raise ValueError('Status word starts with wrong prefix, expected '
'195, got {}'.format(statusword))

(trigger, function, input_range, eoi, buf, rate, srqmode, relative,
delay, multiplex, selftest, data_fmt, data_ctrl, filter_mode,
terminator) = struct.unpack('@4c2s3c2s5c2s', bytes(statusword[4:],
"utf-8"))
terminator) = struct.unpack('@4c2s3c2s5c2s', statusword[4:])

return {'trigger': Keithley195.TriggerMode(int(trigger)),
'mode': Keithley195.Mode(int(function)),
Expand Down

0 comments on commit c0224ec

Please sign in to comment.