Using tcpclient to Write and Read VXI-11 data from an instrument
Show older comments
I have been trying to use MATLAB to write and read values from a signal generator.
This signal generator uses the VXI-11 protocol to send commands, which I have been sending using tcpclient.
Using Wireshark, I can see the write and read commands going to the signal generator as expected. The signal generator also responds correctly, showing that it has accepted commands.
The TCP packets are structured with a Remote Procedure Call portion, followed by the VXI-11 portion.
However, when I try to use tcpclient.read, MATLAB only seems to see the Remote Procedure Call portion. The number of bytes read and the contents contain only this RPC info, omitting the VXI-11 bytes at the end.
Here's the "read" portion of code. The first "write" is writing a read command to the device. After waiting for some bytes to be available on server_name, it reads them out.
write(server_name,commstring_values);
%After writing, wait a short time for byte to be available before reading
waitin = true;
anybytes = 0;
cyclestowait = 50;
while waitin
anybytes = server_name.NumBytesAvailable;
if anybytes > 0
waitin = false;
['There were ' num2str(anybytes) ' bytes.']
end
cyclestowait = cyclestowait - 1;
if cyclestowait == 0
waitin = false;
'I gave up while waiting for bytes'
end
'I had to wait at least once for bytes'
pause(.0005);
end
visa_tcpip_return = read(server_name);
1 Comment
Blake Ipson
on 25 Mar 2022
Answers (0)
Categories
Find more on Instrument Control Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!