pyvisa / pyvisa-py

A pure python PyVISA backend
https://pyvisa-py.readthedocs.io
MIT License
282 stars 120 forks source link

[COM] Communication with Keysight waveform generator, using USB, hangs for waveforms larger than 1MB. #286

Open EleftheriosM opened 3 years ago

EleftheriosM commented 3 years ago

I am connecting via USB to an Agilent (33622) waveform generator. If the waveform I am sending with write_binary_values is less than 1MB (2^20 bytes) it works perfectly. If it is larger it hangs and fails at timeout. Tried with Raspberry Pi 4 and Linux Mint 19. I have tried different termination characters: \r,\n and tried chunk_size = 2097152.

Minimum working example

import pyvisa as visa
visa.log_to_screen()
my_WFM = 262000*[1] # works fine (it is just below 1MB)
#my_WFM = 263000*[1] # fails (it is just above 1MB)

resources = visa.ResourceManager('@py')
devices = resources.list_resources()
my_device = resources.open_resource(devices[1])

print( '###### Target Device ######')
print(my_device.query('*IDN?')) # works fine

my_device.timeout = 300000
my_device.write('*CLS;*RST')
tmp = my_device.query('*OPC?')
my_device.write('SOURce1:DATA:VOLatile:CLEar')
print(my_device.query('SOURce1:DATA:VOLatile:FREE?'))

my_device.write('FORM:BORD NORM') # set the byte order
print('Downloading Waveform...')
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('Download Complete')

print(my_device.query('SYSTEM:ERROR?')) # no errors for less than 1MB , hangs until timeout for more than 1MB

my_device.close() # close connection to device

Output of pyvisa-info

Machine Details:
   Platform ID:    Linux-5.4.72-v7l+-armv7l-with-debian-10.6
   Processor:      

Python:
   Implementation: CPython
   Executable:     /usr/bin/python3
   Version:        3.7.3
   Compiler:       GCC 8.3.0
   Bits:           32bit
   Build:          Jul 25 2020 13:03:44 (#default)
   Unicode:        UCS4

PyVISA Version: 1.11.1

Backends:
   ivi:
      Version: 1.11.1 (bundled with PyVISA)
      Binary library: Not found
   py:
      Version: 0.5.1
      ASRL INSTR: Available via PySerial (3.4)
      USB INSTR: Available via PyUSB (1.1.0). Backend: libusb1
      USB RAW: Available via PyUSB (1.1.0). Backend: libusb1
      TCPIP INSTR: Available 
      TCPIP SOCKET: Available