Pyvisa-Pyusb无法加载大于1MB的序列



我正在通过USB连接到安捷伦(33600(波形发生器。如果我发送的波形小于1MB(2^20字节(,它可以完美工作。如果它更大,它会挂起并在超时时失败。

使用:

  • Python3.7、Pyusb 1.1、Pyvisa 1.11和Pyvisa py 0.5.1后端。尝试了Linux Mint和Raspberry Pi 4

最小工作示例:

import pyvisa as visa
my_WFM = 262000*[1] # works fine 262000*4 = 1,048,000
#my_WFM = 263000*[1] # fails (it is just above 1MB) 263000*4 = 1,052,000
resources = visa.ResourceManager('@py')
devices = resources.list_resources()
my_device = resources.open_resource(devices[1])
print(my_device.query('*IDN?')) # works fine
## Prepare the device
my_device.timeout = 300000
my_device.write('*CLS;*RST')
tmp = my_device.query('*OPC?')
my_device.write('SOURce1:DATA:VOLatile:CLEar')
## Send the waveform
my_device.write('FORM:BORD NORM') # set the byte order
bytes_sent = my_device.write_binary_values('SOUR1:DATA:ARB myARB,', my_WFM,datatype='f', is_big_endian=True)
print(bytes_sent)
my_device.write('*WAI') # Wait for the waveform to load
print(my_device.query('SYSTEM:ERROR?')) # no errors for less than 1MB
my_device.close() # close connection to device

与其等待操作完成,不如轮询设备以查看操作是否已完成。尝试使用"*OPC"命令,就像下面的例子一样。

import pyvisa as visa
from time import sleep
my_WFM = 262000*[1] # works fine 262000*4 = 1,048,000
#my_WFM = 263000*[1] # fails (it is just above 1MB) 263000*4 = 1,052,000
resources = visa.ResourceManager('@py')
devices = resources.list_resources()
my_device = resources.open_resource(devices[1])
print(my_device.query('*IDN?')) # works fine
## Prepare the device
my_device.timeout = 300000
my_device.write('*CLS;*RST')
tmp = my_device.query('*OPC?')
my_device.write('SOURce1:DATA:VOLatile:CLEar')
## Send the waveform
my_device.write('FORM:BORD NORM') # set the byte order
bytes_sent = my_device.write_binary_values('SOUR1:DATA:ARB myARB,', my_WFM,datatype='f', is_big_endian=True)
print(bytes_sent)
device_operation_complete = 0
while not device_operation_complete:
device_operation_complete = my_device.query('*OPC?') #should return a 1 if complete
sleep(2)

print(my_device.query('SYSTEM:ERROR?')) # no errors for less than 1MB
my_device.close() # close connection to device

相关内容

  • 没有找到相关文章

最新更新