Hi,
Is there a way to retrieve scope screen shot without saving the image file on the scope local drive, specify the location, read it back to the host PC, and then delete it from the scope local drive (this is because I'm doing this a lot and without deleting it will overflow the drive space)? Please see below code.
Is there a way to simply retrieve the scope screen shot as a file object without going thru the above steps? If not, please help with the below issue.
An issue with the below scripts is that I randomly get stuck with erros (at random lines of codes, more likely for line "read_raw(1920 * 1080)") "pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed."
what I have noticed is that by plugging in/out USB, or power cycling the scope/PC sometimes resolve these timeout errors. Any insights?
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