Search code examples
pythonusbvisa

Python: PyVisa with USB connection - > wait_for_srq() or wait_on_event?


I'm trying to controlling to a USB instrument (Keithley 2450) using pyVisa but I get an error. I'm following the simple example on the pyVisa website

I have a problem after I send a "service request"

keithley.wait_for_srq()

and it throws an error

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'USBInstrument' object has no attribute 'wait_for_srq'

It seems with that's command I can't communicate via USB. What can I to do to remote communicate with my instruments via USB interface ? Hopefully, you can me help. I'm new in Python and SCPI.


Solution

  • I tried with my Pyvisa just now, it has the same problem as well. I'm currently using Pyvisa version 1.8.

    I think it is due to that when you open the device, you used the usb interfaceinstead of thegpib` interface.

    If you go to the source of wait_for_srq in pyvisa, you can see that it is only belong to the GPIBInstrument.

    Unlike wait_on_event, it is directly wrapped around the NI-VISA C libraries, which means this method is available for all types of instruments (GPIBInstrument, USBInstrument).

    So probably you can use the function wait_for_srq with the event_type set to be Service Request (i didn't try from my side).

    And to be noted that SRQ(Service Request) is defined by IEEE 488 standard and it is one of the few number of lines that are dedicated to signalling and control on the GPIB. Which means SRQ is exclusively available in GPIB interace but not USB.