How to use the SPECTRAN V6 via Matlab

Quote from jhexa on 14/05/2021, 10:11I have your SPECTRAN V6 product and I have now problems of connecting
the device to Matlab. With your Aaronia-RTSA-Suite Pro program the
device is working with IQ 92 MS/s (I would like to have higher sampling
rate there also, but cannot get even when connected to 2 USB3 ports?),
and with Matlab example codes you have provided in the forum website, I am
not able to access the device by Matlab. I am using the localhost:port
shown by Aaronia-RTSA-Suite Pro ( localhost:55442), but for instance by
accessing via AaroniaHTTP.m file, I will get always an error:Error using matlab.net.http.RequestMessage/sendOneRequest (line 1335)
Error connecting to http://localhost:55442/sample: Failed to connect to
localhost
port 55442: Connection refusedwhen trying to read samples.
Can you advice me what am I missing now, and how to proceed ?
I have your SPECTRAN V6 product and I have now problems of connecting
the device to Matlab. With your Aaronia-RTSA-Suite Pro program the
device is working with IQ 92 MS/s (I would like to have higher sampling
rate there also, but cannot get even when connected to 2 USB3 ports?),
and with Matlab example codes you have provided in the forum website, I am
not able to access the device by Matlab. I am using the localhost:port
shown by Aaronia-RTSA-Suite Pro ( localhost:55442), but for instance by
accessing via AaroniaHTTP.m file, I will get always an error:
Error using matlab.net.http.RequestMessage/sendOneRequest (line 1335)
Error connecting to http://localhost:55442/sample: Failed to connect to
localhost
port 55442: Connection refused
when trying to read samples.
Can you advice me what am I missing now, and how to proceed ?

Quote from AdminTC on 17/05/2021, 09:12It looks like your missing a key for higher RTBWs.
Are you sure you have a 120MHz or 245MHz IQ key?
It looks like your missing a key for higher RTBWs.
Are you sure you have a 120MHz or 245MHz IQ key?

Quote from pmar on 17/05/2021, 11:21In addition to the missed RTBW key, it seems as if the FREE INCLUDED KEYs are not loaded.
Please check the RTSA-Suite PRO License Manager [ALT]+[L] and add it manually (from provided USB Stick):
In addition to the missed RTBW key, it seems as if the FREE INCLUDED KEYs are not loaded.
Please check the RTSA-Suite PRO License Manager [ALT]+[L] and add it manually (from provided USB Stick):

Quote from DevSF on 19/05/2021, 12:20Even if it was not a license key issue (as succested by AdminTC and pmar), before using the example code in Matlab make sure the HTTP Server block is providing the related data. To do so, you can easily enter the related HTTP endpoint into your webbrowser to check if you get a response by the RTSA Suite. It should look like following:
Even if it was not a license key issue (as succested by AdminTC and pmar), before using the example code in Matlab make sure the HTTP Server block is providing the related data. To do so, you can easily enter the related HTTP endpoint into your webbrowser to check if you get a response by the RTSA Suite. It should look like following:

Quote from jhexa on 06/08/2021, 08:49In the RTSA-http-Stream-Server-Endpoints-8.pdf document there is text about the Raw Data Format. Could you please advice me how to access this raw data by Matlab. I cannot figure out this from the text of the document.
In the RTSA-http-Stream-Server-Endpoints-8.pdf document there is text about the Raw Data Format. Could you please advice me how to access this raw data by Matlab. I cannot figure out this from the text of the document.

Quote from mm_dev on 06/08/2021, 10:33You can select the output format using the "format" query parameter. Supported values are "int16", "float16", "float32" or "json".
The "format" parameter is only available when using the /stream endpoint, which by default will continously send data at a potentially very high rate. You can use the "limit" parameter to only request a finite amount of samples.
You can select the output format using the "format" query parameter. Supported values are "int16", "float16", "float32" or "json".
The "format" parameter is only available when using the /stream endpoint, which by default will continously send data at a potentially very high rate. You can use the "limit" parameter to only request a finite amount of samples.

Quote from DevSF on 09/08/2021, 07:45jhexa, have a look at the "C++ Just IQ Data Streaming" example which is using the Stream endpoint of the HTTP Server block.
jhexa, have a look at the "C++ Just IQ Data Streaming" example which is using the Stream endpoint of the HTTP Server block.

Quote from jhexa on 12/08/2021, 17:06Thanks for the help! Now my streaming is working fine, but I have faced the next challenge related to the conversion the gathered raw16 IQ data stream to correct numerical form.
So what is wrong in the following Matlab code? The result (I and Q) obtained with the code below does not make any sense.
res=webread('http://localhost:54664/stream?format=raw16&limit=10');
j = strfind(char(res)','samples')+17;
I=[];Q=[];
for i=1:length(j)
x1=res(j:4:j+4*65536-5);
x2=res(j+1:4:j+4*65536-4);
I = [I ((256*x1 + x2))];
x1=res(j+2:4:j+4*65536-3);
x2=res(j+3:4:j+4*65536-2);
Q = [Q ((256*x1 + x2))];
end
Thanks for the help! Now my streaming is working fine, but I have faced the next challenge related to the conversion the gathered raw16 IQ data stream to correct numerical form.
So what is wrong in the following Matlab code? The result (I and Q) obtained with the code below does not make any sense.
res=webread('http://localhost:54664/stream?format=raw16&limit=10');
j = strfind(char(res)','samples')+17;
I=[];Q=[];
for i=1:length(j)
x1=res(j:4:j+4*65536-5);
x2=res(j+1:4:j+4*65536-4);
I = [I ((256*x1 + x2))];
x1=res(j+2:4:j+4*65536-3);
x2=res(j+3:4:j+4*65536-2);
Q = [Q ((256*x1 + x2))];
end

Quote from jhexa on 12/08/2021, 20:33Sorry, in the last code the loop (for i=1:length(j) ..) of course should have j(i) instead of j (I by accidently copied an old code version).
Sorry, in the last code the loop (for i=1:length(j) ..) of course should have j(i) instead of j (I by accidently copied an old code version).

Quote from DevSF on 17/08/2021, 15:44jhexa, you had multiple errors in your code. If the received packets have all the same amount of samples, following code should work:
res=webread('http://localhost:54664/stream?format=raw16&limit=10');
j = strfind(char(res)',char([125 10 30])) + 2;
header = jsondecode(char(res(1:(j(1)-2)))');
disp(header);
I=[]; Q=[];
size = header.samples*4;for i=1:length(j)
values = typecast(res(j(i):(j(i) + size -1)), 'int16');
I = [I (double( values(1:2:size/2) )/header.scale)];
Q = [Q (double( values(2:2:size/2) )/header.scale)];
endIQData = I(1:end,1)+1i*Q(1:end,1);
fftsize = 1024+4;if(fftsize > 1)
fftWindow = hann(fftsize)*2;
y = fftshift( fft( IQData(1:fftsize).*fftWindow, fftsize ) ) ;y = abs(y/fftsize).^2;
y = y/50;
y = 10*log10( y / 0.001 );x = linspace(header.startFrequency, header.endFrequency, fftsize);
%figure
plot(x,y);
xlabel('Frequency in Hz');
ylabel('Power in dBm');
title('Spectrum of RTSA IQ Data');
else
disp('No data to plot');
end
jhexa, you had multiple errors in your code. If the received packets have all the same amount of samples, following code should work:
res=webread('http://localhost:54664/stream?format=raw16&limit=10');
j = strfind(char(res)',char([125 10 30])) + 2;
header = jsondecode(char(res(1:(j(1)-2)))');
disp(header);
I=[]; Q=[];
size = header.samples*4;for i=1:length(j)
values = typecast(res(j(i):(j(i) + size -1)), 'int16');
I = [I (double( values(1:2:size/2) )/header.scale)];
Q = [Q (double( values(2:2:size/2) )/header.scale)];
endIQData = I(1:end,1)+1i*Q(1:end,1);
fftsize = 1024+4;if(fftsize > 1)
fftWindow = hann(fftsize)*2;
y = fftshift( fft( IQData(1:fftsize).*fftWindow, fftsize ) ) ;y = abs(y/fftsize).^2;
y = y/50;
y = 10*log10( y / 0.001 );x = linspace(header.startFrequency, header.endFrequency, fftsize);
%figure
plot(x,y);
xlabel('Frequency in Hz');
ylabel('Power in dBm');
title('Spectrum of RTSA IQ Data');
else
disp('No data to plot');
end