【问题标题】:Capture screen shot of Agilent scope using python使用 python 捕获安捷伦示波器的屏幕​​截图
【发布时间】:2022-08-05 01:21:40
【问题描述】:

我试图在 python 中捕获安捷伦示波器的屏幕​​截图,但使用 read_raw 给我一个问题“打印取消”你能帮忙吗

`import pyvisa as visa
 import sys
 #
 # Example VISA address for a USB         connection:
 VISA_ADDRESS = \'USB0::0x2A8D::0x1797::CN57046145::0::INSTR\'
# Define VISA Resource Manager
scope = visa.ResourceManager(\'C:\\\\Windows\\\\System32\\\\visa32.dll\')
scope.read_termination = \'\\n\'
scope.write_termination = \'\\n\' #or = \'\\r\'

print (scope.query(\'*IDN?\\n\'))
scope.write(\'SAVE:IMAG:FILEF PNG\')
scope.write(\':HARDcopy: STARt\')
raw_data = scope.read_raw ()
f= open (\'Shot.png\' \'wb\')
f.write (raw_data)
f.close `

    标签: python scope pyvisa oscilloscope


    【解决方案1】:
    class SCOPE_MSO_S_104A:
        def __init__(self, address):
            self.rm = visa.ResourceManager(r'C:\WINDOWS\system32\visa64.dll')
            self.scope = self.rm.open_resource(address)
            self.scope.timeout = 10000 # 10s
            self.scope.write_termination = '\n'
            self.scope.read_termination = '\n'
            print('MSO S 104A ID string:\n  ', self.scope.query('*IDN?'), flush=True)
            self.scope.query('*RST;*OPC?')
        def getPng(self, file):
            time.sleep(1)
            data = self.scope.query_binary_values(':DISPlay:DATA? PNG,SCReen,1,NORMal', datatype='B', header_fmt='ieee', container=bytes)
            file_id = open(file, 'wb')
            file_id.write(data)
            file_id.close()
        def closeScope(self):
            self.scope.close()
    
    # test in jupyter notebook:
    scope = instruments.SCOPE_MSO_S_104A('USB0::0x2A8D::0x9050::MY55160105::0::INSTR')
    scope.getPng('newPng.png')
    from IPython.display import Image
    Image('newPng.png')
    

    【讨论】:

    • 这对我有用,应该适用于大多数安捷伦/是德科技示波器
    猜你喜欢
    • 2020-10-26
    • 1970-01-01
    • 2015-04-06
    • 2014-05-31
    • 2016-12-11
    • 2014-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多