Closed planewave closed 3 years ago
It appears that the timeout is set for 10 seconds in the command below. If you increase the timeout to 20, will this allow you to export a larger waveform?
vsg = pyarbtools.instruments.VSG('10.0.0.10', port=5025, timeout=10, reset=True)
Jeff
From: Xiao Liu @.> Sent: Tuesday, March 23, 2021 3:50 AM To: morgan-at-keysight/pyarbtools @.> Cc: Subscribed @.***> Subject: [morgan-at-keysight/pyarbtools] VSG download waveform timeout (#38)
CAUTION: This message originates from an external sender.
Hi there
I found this repo is really helpful. thanks for your work!
I am working on an E4438C-601 VSG with 8 MSa Memory. but if I download an IQ signal with a length greater than 11670, for example
import pyarbtools
import numpy as np
iq2 = np.random.rand(11671)-1+(1j*np.random.rand(11671)-1j)
vsg.download_wfm(iq2)
Information: Waveform repeated 2 times.
Information: Waveform repeated 2 times.
Traceback (most recent call last):
File "
File "/home/dell/vsg_venv/lib/python3.6/site-packages/pyarbtools/instruments.py", line 1556, in download_wfm
self.binblockwrite(f'mmemory:data "WFM1:{wfmID}", ', wfm)
File "/home/dell/vsg_venv/lib/python3.6/site-packages/socketscpi/socketscpi.py", line 270, in binblockwrite
r = self.query('*esr?')
File "/home/dell/vsg_venv/lib/python3.6/site-packages/socketscpi/socketscpi.py", line 104, in query
return self.read()
File "/home/dell/vsg_venv/lib/python3.6/site-packages/socketscpi/socketscpi.py", line 83, in read
response += self.socket.recv(1024)
socket.timeout: timed out
and if the length is <= 11670, it will download successfully. So why the number of samples is far less than 8 MSa? how can I play an IQ signal with a few million (or tens of millions) samples?
one more thing, what is the value of full-scaled IQ data? like (+/- 1) + (+/-1j) or something else?
Thank you
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/morgan-at-keysight/pyarbtools/issues/38__;!!I5pVk4LIGAfnvw!yHEVacjfb7NwiQ7pfEjCpL12g7XhYRG8IXrZ8czo6QsT86p9uNkBudPY2n_r$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/API7PZRJAK5GZRXGVY5WA2TTFBBZVANCNFSM4ZUUOZ7Q__;!!I5pVk4LIGAfnvw!yHEVacjfb7NwiQ7pfEjCpL12g7XhYRG8IXrZ8czo6QsT86p9uNkBue8yUVQV$.
no, I have tried 60 seconds, not working.
from https://www.mathworks.com/matlabcentral/fileexchange/29973-agilent-e4438c-dowload-wave-file, which can download a large waveform without timeout issue,
I found that to download a waveform, the binblockwrite
command is
status = binblockwrite_(io, wave_int16, 'int16', [':MEMory:DATA ' ArbFileName ', ']);
which is different from
self.binblockwrite(f'mmemory:data "WFM1:{wfmID}", ', wfm)
self.write(f'radio:arb:waveform "WFM1:{wfmID}"')
in line 1556, instruments.py is it the problem? the download command in ESG is different from EXG/MXG/PSG?
---------- update ------------- no, still didn't work. not sure why the above Matlab code works. could you please take a look at it?
I found this is probably a socket issue, and it may need to go to socketscpi repository.
in socketscpi.py
line 260
self.socket.send(data)
the problem with socket.send()
is that it can't guarantee to send all data. this is not an issue if the number of samples is less than 11k. However, to send a larger date, we need socket.sendall()
instead.
self.socket.sendall(data)
also, for 1M samples, it takes about 10 seconds to download to my E4438C. The timeout arg shall be set according to the number of samples too.
this basically solved my problem. I will do more tests to confirm it.
@planewave, first, an apology for the delay in responding to this question.
Second, thank you for the time and effort you have put into tracking down this issue. You clearly know what you're doing, both from programming/networking and test & measurement standpoints.
Technically, the ESG isn't supported by PyArbTools since it's been obselete and discontinued for almost 20 years. The SCPI commands should be the same, but obviously there's something else going on. It's odd that you are seeing this issue since I haven't run into it before in any of the instruments supported by PyArbTools.
The 11671-sample limit is an odd one as well. I noticed that the waveform was repeated twice when it encountered the .check_wfm()
method, which ensures that the minimum waveform length requirements are met. This shouldn't cause problems with binblockwrite()
because it occurs before any samples are passed to binblockwrite()
.
Do you have any other instruments you can test this on?
I vaguely remember having to choose between socket.sendall()
and socket.send()
and don't remember specifically why I went with socket.send()
. I will do some testing with socketscpi
and see if socket.sendall()
breaks anything in PyArbTools.
A second-hand ESG E4438C is still a $10k instrument that we can barely afford, so there are no other instruments I can test ☹️.
I agree that the SCPI commands should be the same. The problem is the socket command in socketscpi. Have you tried to download a 1 Msamp waveform into a VSG you have? I suspect the timeout issue will show up (set the timeout > 10 seconds).
socket.send
is a low-level method and basically just the C/syscall method send(3) / send(2). It can send less bytes than you requested, but returns the number of bytes sent.socket.sendall
is a high-level Python-only method that sends the entire buffer you pass or throws an exception. It does that by callingsocket.send
until everything has been sent or an error occurs.
https://stackoverflow.com/questions/34252273/what-is-the-difference-between-socket-send-and-socket-sendall
So I believe socket.sendall
is the right choice
Understood. I just have never seen this problem with any other instruments before, so I'm wondering if it's an issue with the ESG specifically.
I just ran a few quick tests on an N5182B MXG, and it took 5 seconds to download a 10 MSample waveform and 45 seconds for a 100 MSample waveform, both using socket.send()
. I did have to increase the timeout above 10 seconds for the 100 MSample test, but I didn't see any issues.
I tested socket.sendall()
on the MXG as well and saw no change in behavior. I will test it on other instruments to see if it breaks anything. If I'm satisfied that it won't have a detrimental effect on everything else in PyArbTools, I'll make the change from socket.send()
to socket.sendall()
.
Update, I found an ESG on the Keysight network and ran the same code on it using the original socket.send
version of socketscpi
and was able to transfer all the way up to a 10 MSample waveform with no problems. I didn't go beyond that due to time constraints. Load times were very long because the ESG I'm using is all the way across the country.
Try running any of the vsg_xxx_example()
functions (except vsg_dig_mod_example()
since the sample rate is too high) in examples.py. Just replace the default IP address with your ESG's IP address in main()
and uncomment the function you want to run.
Let me know what the results are. If you still see the timeout error, something is up with your ESG.
@planewave have you tried any of the other example functions?
@morgan-at-keysight sorry I didn’t reply earlier, because I was working on other stuff recently. The ESG I was using is on the other side of the earth and my boss is trying to get me a local one, hopefully a newer one.
I have tried the example, it works. As long as the number of samples is limited to a few thousands, no issue.
I don’t know why you can’t reproduce the error, maybe it is related to the python version (3.7), the OS (Ubuntu 1804) or even the Ethernet adapter.
Anyway, I will go back to it maybe next month and see how it goes.
Thank you
I have updated socketscpi to use sendall()
instead of send()
in the binblockread
function. This should fix the issue for you.
See this closed issue in socketscpi,
You may have to manually update socketscpi and/or PyArbTools for this change to take effect.
pip install --upgrade socketscpi
pip install --upgrade pyarbtools
Hi there
I found this repo is really helpful. thanks for your work!
I am working on an E4438C-601 ESG Vector Signal Generator with 8 MSa Memory. but if I download an IQ signal with a length greater than 11670, for example
and if the length is <= 11670, it will download successfully. Also, if I download another waveform with a different wfmID, it will also be successful. So why the number of samples of one waveform is far less than 8 MSa? how can I play an IQ signal with a few million (or tens of millions) samples?
one more thing, what is the value of full-scaled IQ data? like -1 ~ +1 or it is like int16 (-32768~+32767)?
Thank you