root/ResearchApps/PHY/WARPLAB/WARPLAB_SISO/M_code/warplab_writeSMWO.m

Revision 750, 1.0 kB (checked in by MelissaDuarte, 10 months ago)

minor changes

Line 
1function pktNoTx = warplab_writeSMWO(udpSock, TxData, SMWO_id)
2
3warplab_siso_defines
4
5pktNoTx = 1;
6
7if(length(TxData) > 2^14)
8        disp('ERROR: TxData must contain 16384 (2^14) samples maximum!');
9        return;
10end
11
12maxPayloadBytesPerPkt = 1024;
13
14TxData_I_fi = int16(real(TxData)*2^15);
15TxData_Q_fi = int16(imag(TxData)*2^15);
16
17TxPktData = 2^16.*int32(TxData_I_fi) + int32(TxData_Q_fi);
18
19%length(TxPktData) is the number of samples, each of which is a 32-bit value
20%We'll send UDP packets with payloads of 1024 bytes, or 256 samples
21%This results in a maximum of 64 UDP packets to download a full TxData
22
23numPkts = ceil(length(TxPktData)*4/maxPayloadBytesPerPkt);
24
25for n = 0:numPkts-1
26        indexStart = ((n*maxPayloadBytesPerPkt/4)+1);
27        indexEnd = min(length(TxPktData),((n+1)*maxPayloadBytesPerPkt/4));
28        dataToSendTx = [pktNoTx SMWO_id indexStart-1 TxPktData(indexStart:indexEnd)];
29        datarec = warplab_pktSend(udpSock, dataToSendTx);
30
31        pktNoTx = pktNoTx+1;
32end
Note: See TracBrowser for help on using the browser.