-
-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[COM] Communication issue with [keysight 53230A ] using USB #443
Comments
It shows time out error : An unexpected error occurred with device USB0::2391::6407::MY59370120::0::INSTR: [Errno 110] Operation timed out |
Could you please check device permissions? See pyvisa/pyvisa#758 (comment), specifically “My solution” section. |
I run with pyvisa debug mode get the following : During handling of the above exception, another exception occurred: Traceback (most recent call last): Configure logginglogging.basicConfig(level=logging.DEBUG) Initialize the resource managerrm = pyvisa.ResourceManager("@py") List all connected resourcesdevices = rm.list_resources() Dictionary to store identified devicesidentified_devices = {} Loop through each device and try to identify itfor device in devices: Print the identified devicesfor device, idn in identified_devices.items(): |
Interesting — thank you for debug logging, it is clear you've spent time digging into this. It appears that both your USB devices encounter issues, but different ones.
Keysight device appears to be timeouting on write, which is also unusual. Could you please post the following:
Thanks! |
the first device is working and i cancommunicate , the problem is with the agilent one I am using the latest build from development but befor that i was using latest offical version from pyvisa they both produce same error Python: PyVISA Version: 1.14.2.dev64+g6fb569d Backends: |
the second point I cant understand well , I am out of the lap now and I will try it when somone go there , |
I reconnected the agilent device , after restarting laptop, power cycle the counter . I got the same ouput the error in the write command During handling of the above exception, another exception occurred: Traceback (most recent call last): |
I tried this code : import pyvisa
def initialize_resource_manager():
try:
rm = pyvisa.ResourceManager()
return rm
except Exception as e:
print(f"Failed to initialize resource manager: {e}")
exit(1)
def identify_device(rm, visa_resource):
try:
inst = rm.open_resource(visa_resource)
inst.timeout = 5000 # Set a longer timeout (in milliseconds) if needed
idn = inst.query("*IDN?")
inst.close()
return idn
except pyvisa.errors.VisaIOError as e:
print(f"VISA IO Error with device {visa_resource}: {e}")
return None
except Exception as e:
print(f"Unexpected error with device {visa_resource}: {e}")
return None
def measure_frequency(rm, visa_resource):
try:
inst = rm.open_resource(visa_resource)
inst.timeout = 5000 # Set a longer timeout (in milliseconds) if needed
# Setup the device for frequency measurement
inst.write("CONF:FREQ")
# Initiate measurement
frequency = inst.query("READ?")
inst.close()
return frequency
except pyvisa.errors.VisaIOError as e:
print(f"VISA IO Error with device {visa_resource}: {e}")
return None
except Exception as e:
print(f"Unexpected error with device {visa_resource}: {e}")
return None
def main():
rm = initialize_resource_manager()
# Define the specific VISA resource
visa_resource = "USB0::0x0957::0x1907::MY59370120::INSTR"
# Identify the device
idn = identify_device(rm, visa_resource)
if idn:
print(f"Identification response for {visa_resource}: {idn}")
# Measure frequency
frequency = measure_frequency(rm, visa_resource)
if frequency:
print(f"Measured frequency for {visa_resource}: {frequency} Hz")
if __name__ == "__main__":
main() ################################################################### |
@arr-ee did you get the chance to look at that ? |
So,
I was asking you to change your test code to only query device in question — you have done so in the last snippet you posted, thanks!
This is to be expected —
This does not make sense to me. Line 258 is not in pyvisa-py/pyvisa_py/protocols/usbtmc.py Line 258 in 32ca1d5
Another thing that does not make sense to me is that we're getting a timeout error from the usb library here, yet from your previous message showing
Given that same code works on windows but not on linux, and given the oddness I've outlined above, I suggest we try to reset (figuratively speaking) and try the following:
I understand that it might feel like we're walking in circles, but what I am seeing so far does not make sense. |
Instrument details
Output of
pyvisa-info
USB0::2391::6407::MY59370120::0::INSTR
Traceback (most recent call last):
File "/home/user/Desktop/Build_1_Test/counter3.py", line 38, in
instrument = connect_device(resource_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/Desktop/Build_1_Test/counter3.py", line 13, in connect_device
instrument = rm.open_resource(resource_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/pyvisa/highlevel.py", line 3292, in open_resource
res.open(access_mode, open_timeout)
File "/usr/local/lib/python3.12/dist-packages/pyvisa/resources/resource.py", line 281, in open
self.session, status = self._resource_manager.open_bare_resource(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/pyvisa/highlevel.py", line 3217, in open_bare_resource
return self.visalib.open(self.session, resource_name, access_mode, open_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pyvisa_py/highlevel.py", line 167, in open
sess = cls(session, resource_name, parsed, open_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pyvisa_py/sessions.py", line 323, in init
self.after_parsing()
File "/usr/lib/python3/dist-packages/pyvisa_py/usb.py", line 81, in after_parsing
self.interface = self._intf_cls(
^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pyvisa_py/protocols/usbtmc.py", line 287, in init
super(USBTMC, self).init(vendor, product, serial_number, **kwargs)
File "/usr/lib/python3/dist-packages/pyvisa_py/protocols/usbtmc.py", line 199, in init
raise ValueError("No device found.")
ValueError: No device found.
[CODE]:
import pyvisa
def list_devices():
"""List all connected VISA devices."""
rm = pyvisa.ResourceManager('@py')
devices = rm.list_resources()
for device in devices:
print(device)
def connect_device(resource_name):
"""Connect to the USBTMC device."""
rm = pyvisa.ResourceManager('@py')
instrument = rm.open_resource(resource_name)
return instrument
def query_device(instrument, command):
"""Send a query to the device and get the response."""
response = instrument.query(command)
return response
def write_device(instrument, command):
"""Send a command to the device."""
instrument.write(command)
def read_device(instrument):
"""Read the response from the device."""
response = instrument.read()
return response
if name == "main":
# List all connected VISA devices
list_devices()
The text was updated successfully, but these errors were encountered: