Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyVisa Query Command fails
#1
Hi
I am restoring an Electro-Metrics EMC-30 receiver. This is a Mil-Spec EMC test receiver that includes a GPIB bus. This is an old piece of kit.
I have built versions of the usbGpib adapter by Xyphro UsbGpib Adapter.
I have been writing and testing very simple test scripts in python with pyVisa.

Write commands sent over the GPIB interface work. When I send a command the receiver responds correctly.

Query commands (write/read) fail for reasons I don't understand.

The following is the code for my test program:
[inline]
# EMC30 simple test
# ver 0.2 date 29 Apr 25
# The purpose of this script is to test manually entered query commands

import pyvisa
import time

print("###### Simple GPIB test for emc30")
print("# Manually enter query commands")
print("# Show the list of Resources")
rm = pyvisa.ResourceManager()
print(rm.list_resources())
rs = rm.list_resources()

print("# Opening the usb:gpib adapter")
emc30 = rm.open_resource(rs[0], send_end=True,)
time.sleep(1)

# get the user input
qy = input("Enter the query command:")
print(emc30.query_ascii_values(qy) )

emc30.clear()
rm.close()
[/inline]

This is a generic test program. It accepts any query command and returns the response.
I always get an error response as follows:

Output:
###### Simple GPIB test for emc30 # Manually enter query commands # Show the list of Resources ('USB0::0x03EB::0x2065::GPIB_01_34230313836351610051::INSTR',) # Opening the usb:gpib adapter Enter the query command:FR Query the command: FR
Error:
Traceback (most recent call last): File "C:\Users\Darren\Documents\Electronics\emc30_cmd_qry.py", line 26, in <module> print(emc30.read()) ~~~~~~~~~~^^ File "C:\Users\Darren\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyvisa\resources\messagebased.py", line 485, in read message = self._read_raw().decode(enco) ~~~~~~~~~~~~~~^^ File "C:\Users\Darren\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyvisa\resources\messagebased.py", line 441, in _read_raw chunk, status = self.visalib.read(self.session, size) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Darren\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyvisa\ctwrapper\functions.py", line 2336, in read ret = library.viRead(session, buffer, count, byref(return_count)) File "C:\Users\Darren\AppData\Local\Programs\Python\Python313\Lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 226, in _return_handler return self.handle_return_value(session, ret_value) # type: ignore ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Darren\AppData\Local\Programs\Python\Python313\Lib\site-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.
I think this error is telling me the reply is not being received (timing out).
I have had these query commands working before, so I don't think this is a problem with the EMC-30.

How should I go about troubleshooting this issue? My Python knowledge is poor.
buran write Apr-30-2025, 10:24 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
What does the receiver use for read and write termination? You may need to set these for emc30. The pyvisa manual says this is a common cause for the timeout error you see.

https://pyvisa.readthedocs.io/en/latest/...ation.html
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Executing a command which fails ebolisa 0 1,981 May-01-2020, 01:51 PM
Last Post: ebolisa
  Issue to read commands with pyvisa losc 0 2,146 Nov-13-2019, 04:10 AM
Last Post: losc
  pyspark sql unable to recognize SQL query command cpatte7372 6 20,848 Jul-31-2018, 04:17 PM
Last Post: micseydel
  Setting Byte Count in pyVisa Read Function mike505 0 5,797 Nov-17-2016, 07:43 PM
Last Post: mike505

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020