source: ResearchApps/PHY/WARPLAB/WARPLab_v06_1/M_Code_Reference/warplab_writeSMWO.m

Last change on this file was 1846, checked in by chunter, 12 years ago


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