I tried adding CLS in the init but I'm still having issues.
def __init__(self, addr):
self.addr = addr
self.rm = pyvisa.ResourceManager() # rm.list_resources()
self.inst = self.rm.open_resource(self.addr)
self.write("*CLS")
print(self.query("*IDN?"))
self.write("*CLS")
Do you see anything wrong with the below function? (I keep getting timeout errors at random lines in the below funciton. )
If not, can you please share a scope shot retrieving routine that's robust?
def get_screenshot(self):
now = str(datetime.datetime.now()).replace(":", "-")
# print(now)
self.write(f'SAVE:IMAGe \"C:/{now}.png\"')
self.query("*OPC?")
self.write(f'FILESystem:READFile \"C:/{now}.png\"')
imgData = self.inst.read_raw(1920 * 1080)
cwd = os.getcwd()
full_path = cwd + "\\scope screenshots"
Path(full_path).mkdir(exist_ok=True)
filepath = full_path + "\\" + now + ".jpg"
file = open(filepath, "wb")
file.write(imgData)
file.close()
self.write(f'FILESystem:DELEte \"C:/{now}.png\"')
return filepath