from datetime import datetimeimport pyvisa as visaimport structfrom re import findallclass Infiniiumdef initselfUSB_COMrm = visaResourceManagerselfinfiniium = rmopen_resourceUSB_COM read_termination=
The issue might be with the read_raw() method in the png_save() function. It is possible that the timeout value is not sufficient to read all the image data.
You can try increasing the timeout value before calling read_raw() to ensure that enough time is given to read the complete image data. Here's an updated version of the png_save() function:
def png_save(self, fileSaveLocation):
self.infiniium.write("SAVe:IMAGe:FILEFormat PNG")
self.infiniium.write("SAVe:IMAGe:INKSaver OFF")
self.infiniium.write("HARDCopy STARt")
self.infiniium.timeout = 3000
imgData = b''
while True:
data = self.infiniium.read_raw()
if not data:
break
imgData += data
self.infiniium.timeout = 3000
print(imgData)
dt = datetime.now()
fileName = dt.strftime("%Y%m%d_%H%M%S.png")
imgFile = open(fileSaveLocation + fileName, "wb")
imgFile.write(imgData)
This updated code will keep reading data from the instrument until there is no more data to read. It then saves the complete image data to the file.
Make sure to also check if there are any other issues with the code or if there are any errors being raised that could be causing incomplete data to be read
原文地址: https://www.cveoy.top/t/topic/iGAQ 著作权归作者所有。请勿转载和采集!