Open SengerM opened 2 years ago
I changed the oscilloscope to a different computer running Ubuntu 20.04 too, same configuration as the original. When I try to connect with the oscilloscope, the same error occurs. Now, with more time, I installed the NI-VISA library following the instructions for Ubuntu. So now in this computer pyvisa-info
gives this:
/home/myself/local/lib/python3.8/site-packages/gpib_ctypes/gpib/gpib.py:54: UserWarning: GPIB library not found. Please manually load it using _load_lib(filename). All GPIB functions will raise OSError until the library is manually loaded.
warnings.warn(message)
Machine Details:
Platform ID: Linux-5.4.0-91-generic-x86_64-with-glibc2.29
Processor: x86_64
Python:
Implementation: CPython
Executable: /usr/bin/python3
Version: 3.8.10
Compiler: GCC 9.3.0
Bits: 64bit
Build: Nov 26 2021 20:14:08 (#default)
Unicode: UCS4
PyVISA Version: 1.11.3
Backends:
ivi:
Version: 1.11.3 (bundled with PyVISA)
#1: /usr/lib/x86_64-linux-gnu/libvisa.so.21.0.0:
found by: auto
bitness: 64
Vendor: National Instruments
Impl. Version: National Instruments
Spec. Version: National Instruments
py:
Version: 0.5.2
ASRL INSTR: Available via PySerial (3.5)
USB INSTR: Available via PyUSB (1.2.1). Backend: libusb1
USB RAW: Available via PyUSB (1.2.1). Backend: libusb1
TCPIP INSTR: Available
TCPIP SOCKET: Available
After this, the following strange sequence of events happened:
rm = pyvisa.ResourceManager('@ivi')
. Then I run this script and obtained
Traceback (most recent call last):
File "test_lecroy_the_new_one.py", line 10, in <module>
osc = rm.open_resource('USB0::1535::4131::4751N40408::0::INSTR')
File "/home/sengerm/.local/lib/python3.8/site-packages/pyvisa/highlevel.py", line 3304, in open_resource
res.open(access_mode, open_timeout)
File "/home/sengerm/.local/lib/python3.8/site-packages/pyvisa/resources/resource.py", line 297, in open
self.session, status = self._resource_manager.open_bare_resource(
File "/home/sengerm/.local/lib/python3.8/site-packages/pyvisa/highlevel.py", line 3232, in open_bare_resource
return self.visalib.open(self.session, resource_name, access_mode, open_timeout)
File "/home/sengerm/.local/lib/python3.8/site-packages/pyvisa/ctwrapper/functions.py", line 1851, in open
ret = library.viOpen(
File "/home/sengerm/.local/lib/python3.8/site-packages/pyvisa/ctwrapper/highlevel.py", line 222, in _return_handler
return self.handle_return_value(session, ret_value) # type: ignore
File "/home/sengerm/.local/lib/python3.8/site-packages/pyvisa/highlevel.py", line 251, in handle_return_value
raise errors.VisaIOError(rv)
pyvisa.errors.VisaIOError: VI_ERROR_RSRC_BUSY (-1073807246): The resource is valid, but VISA cannot currently access it.
Also noted that rm.list_resources()
is now returning an empty tuple, i.e. is not seeing the oscilloscope.
rm = pyvisa.ResourceManager('@py')
. As expected, the original error occurs. rm = pyvisa.ResourceManager('@ivi')
and now it is working without problems.All this happened without restarting the computer or the oscilloscope in the middle. It just happened within 30 seconds or so I was doing this random tests.
I am just reporting this here in case it is of use to somebody, be it the developers (thank you BTW) or someone running into a similar issue (me in the future?).
Just want to add a comment on this issue now that I have been dealing with it for a while. The problem persists, but there is a workaround. First of all, the switch between @py
and @ivi
that I described before still has to be done every now and then (not sure what triggers this). To forget about it now I am connecting to the oscilloscope in this way:
try:
oscilloscope = pyvisa.ResourceManager('@ivi').open_resource(args.oscilloscope_visa_name)
except pyvisa.errors.VisaIOError:
try:
pyvisa.ResourceManager('@py').open_resource(args.oscilloscope_visa_name) # This I already know it won't work, but it triggers something that makes the `@ivi` to work.
except:
pass
oscilloscope = pyvisa.ResourceManager('@ivi').open_resource(args.oscilloscope_visa_name) # Now this works. Don't ask me.
With this weird connection mechanism, it works most of the times. There is one more thing, and it is that sometimes the connection still fails due to a busy resource error or so (sorry I don't have it right now) and the solution to this is to go to the oscilloscope and navigate to Utilities
→ Utilities setup
→ Remote
and here just click in Off
and then back again to USBTMC
. I have no idea if this fixes something within the oscilloscope or restarts some connection within Linux, but after this it works.
Just to chime in, we are seeing this error with 2 of our Lecroy scopes as well. It won't even open resource at all and faces the same pipe error.
Models are: Lecroy HDO6104 and Lecroy WaveRunning 8000HD
Can you have a look at the discussion in https://github.com/pyvisa/pyvisa-py/issues/256 and see if any of the investigated solution works in your case ? The more feedback we get the better.
Instrument details
Output of
pyvisa-info
Description
I am getting
usb.core.USBError: [Errno 32] Pipe error
when I try to open the connection. This is my code:and the output
As seen, the communication with the Keithley works fine but fails with the oscilloscope.
Let me add that I have communicated with this very same oscilloscope in the past from Windows using PyVISA (probably using the NI backend).