Rydberg
Rydberg

Reputation: 101

pyvisa succeeds with "*IDN?" but fails with VI_ERROR_TMO: Timeout expired before operation completed with all other commands

My instrument responds properly to "*IDN?" with Rigol Technologies,DG822,DG8A233304081,00.02.06.00.01.

When I try to issue any other commands, I get:

Traceback (most recent call last):
  File "/home/pi/918AutoRelock/rigol_f_gen.py", line 16, in <module>
    rigol.query(OUTPUT1_ON)
  File "/usr/local/lib/python3.9/dist-packages/pyvisa/resources/messagebased.py", line 648, in query
    return self.read()
  File "/usr/local/lib/python3.9/dist-packages/pyvisa/resources/messagebased.py", line 486, in read
    message = self._read_raw().decode(enco)
  File "/usr/local/lib/python3.9/dist-packages/pyvisa/resources/messagebased.py", line 442, in _read_raw
    chunk, status = self.visalib.read(self.session, size)
  File "/usr/local/lib/python3.9/dist-packages/pyvisa_py/highlevel.py", line 519, in read
    return data, self.handle_return_value(session, status_code)
  File "/usr/local/lib/python3.9/dist-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.

The instrument responds to the command. If I tell it to turn on the output, it will! The program just crashes likely because it doesn't receive the correct acknowledgement back from the device.

Additionally, once I issue a command, I cannot control the device physically with the buttons or knobs until I reboot it. Any fix for this?

import pyvisa

RIGOL_ID = 'USB0::6833::1603::DG8A233304081::0::INSTR'
ID_QUERY = "*IDN?"
OUTPUT1_ON = ":OUTP1 ON"
SINE = ":SOUR1:APPL:SIN 500,2.5,1,90"

rm = pyvisa.ResourceManager()
try:
    rigol = rm.open_resource(RIGOL_ID)
    response = rigol.query("*IDN?")
    print(response)
except (ValueError):
    print("The device was not found. Make sure you run the program with sudo privileges.")
# rigol.query(SINE)
rigol.query(OUTPUT1_ON)

exit()

How can I fix this problem? I tried looking in the programming guide, but I couldn't find any reference. I'm copy and pasting the example queries directly from the PDF.

Thanks for the help!

Upvotes: 0

Views: 564

Answers (1)

M. Deckers
M. Deckers

Reputation: 1293

Are you sure you expect an actual answer from the device, therefore want to query data from it, which is a combination of writing and reading?

Most likely the devices does not return any information back to you, therefore writing the commands to the device without waiting for an answer would be the correct way.

Example:

rigol.write(':OUTP1 ON')

Usually only data queries, indicated by a trailing ?, e.g. *IDN? in your example return a result.

Upvotes: 0

Related Questions