Scope Tektronix TDS 1012 gives an error with pyvisa

218 Views Asked by At

I'm trying to connect a Tektronix TDS 1012B oscilloscope to my PC using Pyvisa. I'm using Kubuntu 20.04, Python version 3.9.7 and Pyvisa version 1.11.3. I do the following :

>>> import pyvisa
>>> rm = pyvisa.ResourceManager()
>>> rm.list_resources()
('USB0::1689::870::C021027::0::INSTR')
>>> scope = rm.open_resource('USB0::1689::870::C021027::0::INSTR')  
>>> scope.query("*IDN?")

But I get this error message:

Traceback (most recent call last):
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/pyvisa_py/protocols/usbtmc.py", line 256, in write
    return self.usb_send_ep.write(data)
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/usb/core.py", line 408, in write
    return self.device.write(self, data, timeout)
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/usb/core.py", line 989, in write
    return fn(
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/usb/backend/libusb1.py", line 837, in bulk_write
    return self.__write(self.lib.libusb_bulk_transfer,
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/usb/backend/libusb1.py", line 938, in __write
    _check(retval)
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/pyvisa/resources/messagebased.py", line 638, in query
    self.write(message)
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/pyvisa/resources/messagebased.py", line 197, in write
    count = self.write_raw(message.encode(enco))
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/pyvisa/resources/messagebased.py", line 157, in write_raw
    return self.visalib.write(self.session, message)[0]
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/pyvisa_py/highlevel.py", line 543, in write
    written, status_code = self.sessions[session].write(data)
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/pyvisa_py/usb.py", line 179, in write
    count = self.interface.write(data)
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/pyvisa_py/protocols/usbtmc.py", line 436, in write
    bytes_sent += raw_write(data)
  File "/home/pierre/anaconda3/lib/python3.9/site-packages/pyvisa_py/protocols/usbtmc.py", line 258, in write
    raise ValueError(str(e))
ValueError: [Errno 110] Operation timed out

When I use another type of oscilloscope this very simple code works fine. And when I use Pyvisa under Windows instead of Kubuntu, it also works.

Can someone help me fix this annoying issue?

2

There are 2 best solutions below

0
On

Check out this link to a post from Tek in Tek's forums. They suggest using the pyvisa-py native Python VISA backend. This command instructs to use the pyvisa-py backend

rm = visa.ResourceManager('@py')

and you install by

pip install pyvisa-py

I don't have an Ubuntu machine at my fingertips so I don't know if there are packages available for installing from apt.

0
On

Connecting my TBS 1064 in SUSE has problems due to write permissions. This results in an time-out on requests like ask(). It is likely due to udev/rules, although I did not figure out what to put exactly to make it always work. For now one has to put the write permission (admin) for every USB reconnect, but then it is working. Other devices do not have this problem and it is only a linux issue.