使用Python捕获敏捷范围的屏幕截图

发布于 2025-02-06 08:09:24 字数 589 浏览 2 评论 0原文

我正在尝试捕获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 `

I'm trying to to capture a screenshot of an Agilent scope in python but using read_raw give me an issue “print cancel” can you please help

`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 `

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不乱于心 2025-02-13 08:09:24
import sys
import time
import pyvisa as visa  # PyVISA library

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()

scope = SCOPE_MSO_S_104A('USB0::0x2A8D::0x9050::MY55160105::0::INSTR')
scope.getPng('newPng.png')
from IPython.display import Image
Image('newPng.png')
import sys
import time
import pyvisa as visa  # PyVISA library

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()

scope = SCOPE_MSO_S_104A('USB0::0x2A8D::0x9050::MY55160105::0::INSTR')
scope.getPng('newPng.png')
from IPython.display import Image
Image('newPng.png')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文