pyvisa / pyvisa-py

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

pyvisa-py backend problem writing data files via tcp containing over 450 points (900 bytes) to a Siglent SDG2042x AWG. #311

Open dirtcooker opened 2 years ago

dirtcooker commented 2 years ago

when writing fewer than about 450 points via the following two lines of code, the data is received properly on the awg. More than that and the bytes written by the 2nd line end up in the data file on the awg, rather than being executed as a separate command. The full script is attached. Note that the first line of code below creates a file on the awg containing the waveform data. The 2nd line tells the awg to load it.

dev.write("C1:WVDT WVNM,wave2,FREQ,100.0,AMPL,15.0,OFST,0.0,PHASE,0.0,LENGTH,%d,WAVEDATA,%s"%(nbytes,data),encoding='latin1') dev.write("C1:ARWV NAME,wave2")

The script works properly on a win10 machine using the NI backend. Thus I suspect this is a bug in the pyvisa-py backend. On a linux mint machine (same behavior on v19.2 and 20.2) using pyvisa-py it exhibits the erroneous behavior. I have copied the file from the awg back to the pc and opened it in a hex editor. Attached is a pic of the end of the data file, showing what happened. a work-around is to insert the following line in between the above two statements, which adds an additional 2 bytes to the data file, but seems to then properly close the data file, so that the next write is interpreted properly by the awg. dev.write('\x00\x80',encoding='latin1')

Steps to reproduce the behavior: run the attached script.

Output of pyvisa-info

Python: Implementation: CPython Executable: /usr/bin/python3 Version: 3.6.9 Compiler: GCC 8.4.0 Bits: 64bit Build: Jan 26 2021 15:33:00 (#default) Unicode: UCS4 sdgarb.py.zip corrupted wave file

PyVISA Version: 1.11.3

Backends: ivi: Version: 1.11.3 (bundled with PyVISA) Binary library: Not found py: Version: 0.5.2