Skip to content

VisaIOError(-1073807298) when performing a write after a previous VisaIOError #500

@sfentonn

Description

@sfentonn

When calling a write() after a previous read() results in a VisaIOError: VI_ERROR_IO (-1073807298): Could not perform operation because of I/O error., another VisaIOError with the same message is thrown. The command, however, is still successfully written to the device, as evidenced by a subsequent read to the device in a new session succeeding with the correct information. Using the Keysight VISA driver backend with the same script does not produce this issue.

Closing and reopening the instrument connection or the resource manager or, oddly, time.sleep-ing for 4 seconds (but not <= 3) after catching the first VisaIOError does successfully communicate with the device again. Is there a timeout I'm unaware of?

To Reproduce

Sample script which reproduces the error

INST_ADDR = "TCPIP::xxx.xxx.xxx.xxx::INSTR"

rm = pyvisa.ResourceManager("@py")
inst = cast(MessageBasedResource, rm.open_resource(INST_ADDR))

inst.open()
try:
    inst.query("SOURce:LIST")
except pyvisa.VisaIOError:
    print("Caught malformatted command")

# Device now has Missing parameter (bad write) and
# Query unterminated (nothing to read) errors in queue

# Write succeeds on device but throws another VisaIOError
inst.write("SYST:ERR?")
print(inst.read())

Output of pyvisa-info

Machine Details:
Platform ID: Windows-10-10.0.19045-SP0
Processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel

Python:
Implementation: CPython
Executable: C:\Users\fentsc\Projects\pyvisa_issue.venv\Scripts\python.exe
Version: 3.12.9
Compiler: MSC v.1943 64 bit (AMD64)
Architecture: AMD64
Build: Mar 17 2025 21:06:20 (#main)
Unicode: UCS4

PyVISA Version: 1.15.0

Backends:
ivi:
Version: 1.15.0 (bundled with PyVISA)
#1: C:\WINDOWS\system32\visa32.dll:
found by: auto
architecture:
('x86', 64)
Vendor: Keysight Technologies
Impl. Version: 1380422065
Spec. Version: 7340544
#2: C:\WINDOWS\system32\visa64.dll:
found by: auto
architecture:
('x86', 64)
Vendor: Keysight Technologies
Impl. Version: 1380422065
Spec. Version: 7340544
py:
Version: 0.8.0
TCPIP INSTR: Available
Resource discovery:
- VXI-11: partial (psutil not installed)
- hislip: disabled (zeroconf not installed)
TCPIP SOCKET: Available
PRLGX_TCPIP INTFC: Available
GPIB INSTR: Available
ASRL INSTR:
Please install PySerial (>=3.0) to use this resource type.
No module named 'serial'
USB INSTR:
Please install PyUSB to use this resource type.
No module named 'usb'
USB RAW:
Please install PyUSB to use this resource type.
No module named 'usb'
VICP INSTR:
Please install PyVICP to use this resource type.
PRLGX_ASRL INTFC:
Please install PySerial (>=3.0) to use this resource type.
No module named 'serial'
GPIB INTFC:
Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of functionalities.
No module named 'gpib'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions