I'm not very familiar with python. I'm compiling a python code to plot the output on the oscilloscope. But i got an error like this.
Error:
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
Oscilloscope Model: RIGOL TECHNOLOGIES - DS2302A
Here is the code I compiled:
import pyvisa
import numpy as np
import pylab
import time
from struct import unpack
rm = pyvisa.ResourceManager()
print(rm.list_resources())
scope = rm.open_resource('TCPIP::169.254.94.149::INSTR') # oscilloscope IP
scope.timeout = 10000 # ms
scope.encoding = 'latin_1'
scope.read_termination = '\n'
scope.write_termination = '\r'
print(scope.query('*IDN?'))
scope.write('DATA:SOU CH1')
scope.write('DATA:WIDTH 1')
scope.write('DATA:ENC RPB')
ymult = float(scope.query('WFMPRE:YMULT?')) # y-axis least count
yzero = float(scope.query('WFMPRE:YZERO?')) # y-axis zero error
yoff = float(scope.query('WFMPRE:YOFF?')) # y-axis offset
xincr = float(scope.query('WFMPRE:XINCR?')) # x-axis least count
scope.write('CURVE?')
data = scope.read_raw() # Reading binary data
headerlen = 2 + int(data[1]) # Finding header length
header = data[:headerlen] # Separating header
ADC_wave = data[headerlen:-1] # Separating data
ADC_wave = np.array(unpack('%sB' % len(ADC_wave),ADC_wave)) #binary to ASCII
Volts = (ADC_wave - yoff) * ymult + yzero
Time = np.arange(0, xincr * len(Volts), xincr)
# Plotting Volt Vs. Time
pylab.plot(Time, Volts)
pylab.show()
Other people encountering the error have fixed the issues by adding a long timeout. but adding timeout didn't solve my problem. Here is the output of the pyvisa-info command in terminal.