thinkSRS / srsinst.sr860

Python instrument driver for SRS SR860 series lock-in amplifiers
MIT License
3 stars 2 forks source link

capture.get_all_data() fails if data_size_in_kilobytes > 64 #9

Closed abergerSRS closed 2 months ago

abergerSRS commented 2 months ago

According to the SR860 Operating Manual

CAPTUREGET? [i], [j] ... The maximum length j is 64 (corresponding to 64 kbytes).

Steps to reproduce:

>>> from srsinst.sr860 import SR860
>>> import pyvisa as visa
>>> lockin = SR860('visa', 'GPIB0::4::INSTR')
>>> lockin.capture.data_size_in_kilobytes
128
>>> lockin.capture.start(0,0)
>>> lockin.capture.state
6
>>> lockin.capture.buffer_size_in_kilobytes
128
>>> lockin.capture.get_all_data()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\instrumentlibrary\Documents\Python Demos\sr860_demo\venv\Lib\site-packages\srsinst\sr860\instruments\components.py", line 587, in get_all_data
    buffer = self.comm._read_binary(2)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\instrumentlibrary\Documents\Python Demos\sr860_demo\venv\Lib\site-packages\srsinst\sr860\instruments\visainterface.py", line 83, in _read_binary
    reply = self._visa.read_bytes(length)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\instrumentlibrary\Documents\Python Demos\sr860_demo\venv\Lib\site-packages\pyvisa\resources\messagebased.py", line 370, in read_bytes
    chunk, status = self.visalib.read(self.session, size)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\instrumentlibrary\Documents\Python Demos\sr860_demo\venv\Lib\site-packages\pyvisa\ctwrapper\functions.py", line 2336, in read
    ret = library.viRead(session, buffer, count, byref(return_count))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\instrumentlibrary\Documents\Python Demos\sr860_demo\venv\Lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 226, in _return_handler
    return self.handle_return_value(session, ret_value)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\instrumentlibrary\Documents\Python Demos\sr860_demo\venv\Lib\site-packages\pyvisa\highlevel.py", line 251, in handle_return_value
    raise errors.VisaIOError(rv)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
srsrga commented 2 months ago

Fixed with pull request #10.