source: ResearchApps/PHY/WARPLAB/ResearchExamples/LTE_Setup/LTE_MATLAB_Reference_Files/1user_mimo/warplab_readSMRO_fast_2.m

Last change on this file was 1590, checked in by mduarte, 14 years ago
File size: 1.8 KB
Line 
1function [rawData] = warplab_readSMRO_fast_2(udpSock, SMRO_id, numSamples)
2
3pktNoTx = 1;
4
5% rxCmd = eval(sprintf('RADIO%d_RXDATA', radio));
6% rssiCmd = eval(sprintf('RADIO%d_RSSIDATA', radio));
7
8%Read the raw samples from the selected SMRO
9rawData = zeros(1,2^12); %2^14 / 4 return values
10
11%   pktDataTx = [pktNoTx SMRO_id n];
12%   datarec = warplab_pktSend(udpSock, pktDataTx);
13
14
15%Set the bulk transfer request
16%This will return an integral number of UDP packets, each containing 256 samples
17%Argument 3 defines the first "block" of 256 samples to return (indexed from 0)
18%Argument 4 defines the number of blocks to return
19%Argument 5 defines the inter-packet delay imposed by the FPGA
20pktDataTx = [pktNoTx SMRO_id 0 ceil(numSamples/256) 0];
21
22%Use the new pnet command to receive all the packets in one call, returning a single vector with all 2^14 samples
23rawData = pnet(udpSock, 'bulkRxBuff', int32(pktDataTx));
24
25%Each packet contains 256 samples, preceded by 4 control values:
26%[pktNum ACK command sampOffset]
27%sampOffset is the sample number (zero indexed) of the first sample in that packet
28pktStarts = 1:260:length(rawData);
29
30%Extract the sampOffset values from every received packet
31% receivedOffsets = rawData(pktStarts + 3);
32% if(sum(receivedOffsets) ~= sum(0:256:numSamples-1)) %does this handle all cases of numSamples?!
33% %if(~isempty(setdiff(receivedOffsets, [1:256:length(rawData)])))
34%   %Error! At least one sampOffset is missing
35%   %Start an old-fashioned 1-by-1 download and return that
36%   %Assumes non-bulk CMD ID is 100 less (in warplab_defines.m)
37%   rawData = warplab_readSMRO(udpSock, (SMRO_id-100), numSamples);
38%   return;
39% end
40
41valsToIngore = [pktStarts pktStarts+1 pktStarts+2 pktStarts+3];
42rawData = rawData(setdiff([1:length(rawData)], valsToIngore));
43
44if(numSamples < length(rawData))
45    rawData = rawData(1:numSamples);
46end
Note: See TracBrowser for help on using the repository browser.