1 /******************************************************************************
\r
3 * Copyright (c) 2019 Intel.
\r
5 * Licensed under the Apache License, Version 2.0 (the "License");
\r
6 * you may not use this file except in compliance with the License.
\r
7 * You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
17 *******************************************************************************/
\r
21 #include <arpa/inet.h>
\r
22 #include <sys/time.h>
\r
26 #include "xran_fh_o_du.h"
\r
27 #include "xran_pkt.h"
\r
28 #include "xran_pkt_up.h"
\r
29 #include "xran_cp_api.h"
\r
30 #include "xran_up_api.h"
\r
32 #include "xran_mlog_lnx.h"
\r
34 extern enum app_state state;
\r
36 int iq_playback_buffer_size_dl = IQ_PLAYBACK_BUFFER_BYTES;
\r
37 int iq_playback_buffer_size_ul = IQ_PLAYBACK_BUFFER_BYTES;
\r
39 int iq_bfw_buffer_size_dl = IQ_PLAYBACK_BUFFER_BYTES;
\r
40 int iq_bfw_buffer_size_ul = IQ_PLAYBACK_BUFFER_BYTES;
\r
42 int iq_srs_buffer_size_ul = IQ_PLAYBACK_BUFFER_BYTES;
\r
44 uint8_t numCCPorts = 1;
\r
45 /* Number of antennas supported by front-end */
\r
47 uint8_t num_eAxc = 4;
\r
48 /* Number of CPRI ports supported by front-end */
\r
50 int16_t *p_tx_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
51 int32_t tx_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
52 int32_t tx_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
\r
54 int16_t *p_tx_prach_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
55 int32_t tx_prach_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
56 int32_t tx_prach_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
\r
58 int16_t *p_tx_srs_play_buffer[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
\r
59 int32_t tx_srs_play_buffer_size[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
\r
60 int32_t tx_srs_play_buffer_position[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
\r
62 int16_t *p_rx_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
63 int32_t rx_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
64 int32_t rx_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
\r
66 int16_t *p_prach_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
67 int32_t prach_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
68 int32_t prach_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
\r
70 int16_t *p_srs_log_buffer[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
\r
71 int32_t srs_log_buffer_size[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
\r
72 int32_t srs_log_buffer_position[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
\r
74 int16_t *p_tx_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
75 int32_t tx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
77 int16_t *p_rx_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
78 int32_t rx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
80 /* beamforming weights for UL (O-DU) */
\r
81 int16_t *p_tx_dl_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
82 int32_t tx_dl_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
83 int32_t tx_dl_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
\r
85 /* beamforming weights for UL (O-DU) */
\r
86 int16_t *p_tx_ul_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
87 int32_t tx_ul_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
88 int32_t tx_ul_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
\r
90 /* beamforming weights for UL (O-RU) */
\r
91 int16_t *p_rx_dl_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
92 int32_t rx_dl_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
93 int32_t rx_dl_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
\r
95 /* beamforming weights for UL (O-RU) */
\r
96 int16_t *p_rx_ul_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
\r
97 int32_t rx_ul_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
\r
98 int32_t rx_ul_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
\r
100 // F1 Tables 38.101-1 Table 5.3.2-1. Maximum transmission bandwidth configuration NRB
\r
101 uint16_t nNumRbsPerSymF1[3][13] =
\r
103 // 5MHz 10MHz 15MHz 20 MHz 25 MHz 30 MHz 40 MHz 50MHz 60 MHz 70 MHz 80 MHz 90 MHz 100 MHz
\r
104 {25, 52, 79, 106, 133, 160, 216, 270, 0, 0, 0, 0, 0}, // Numerology 0 (15KHz)
\r
105 {11, 24, 38, 51, 65, 78, 106, 133, 162, 0, 217, 245, 273}, // Numerology 1 (30KHz)
\r
106 {0, 11, 18, 24, 31, 38, 51, 65, 79, 0, 107, 121, 135} // Numerology 2 (60KHz)
\r
109 // F2 Tables 38.101-2 Table 5.3.2-1. Maximum transmission bandwidth configuration NRB
\r
110 uint16_t nNumRbsPerSymF2[2][4] =
\r
112 // 50Mhz 100MHz 200MHz 400MHz
\r
113 {66, 132, 264, 0}, // Numerology 2 (60KHz)
\r
114 {32, 66, 132, 264} // Numerology 3 (120KHz)
\r
117 // 38.211 - Table 4.2.1
\r
118 uint16_t nSubCarrierSpacing[5] =
\r
127 // TTI interval in us (slot duration)
\r
128 uint16_t nTtiInterval[4] =
\r
137 // F1 Tables 38.101-1 Table F.5.3. Window length for normal CP
\r
138 uint16_t nCpSizeF1[3][13][2] =
\r
140 // 5MHz 10MHz 15MHz 20 MHz 25 MHz 30 MHz 40 MHz 50MHz 60 MHz 70 MHz 80 MHz 90 MHz 100 MHz
\r
141 {{40, 36}, {80, 72}, {120, 108}, {160, 144}, {160, 144}, {240, 216}, {320, 288}, {320, 288}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, // Numerology 0 (15KHz)
\r
142 {{22, 18}, {44, 36}, {66, 54}, {88, 72}, {88, 72}, {132, 108}, {176, 144}, {176, 144}, {264, 216}, {264, 216}, {352, 288}, {352, 288}, {352, 288}}, // Numerology 1 (30KHz)
\r
143 { {0, 0}, {26, 18}, {39, 27}, {52, 36}, {52, 36}, {78, 54}, {104, 72}, {104, 72}, {156, 108}, {156, 108}, {208, 144}, {208, 144}, {208, 144}}, // Numerology 2 (60KHz)
\r
146 // F2 Tables 38.101-2 Table F.5.3. Window length for normal CP
\r
147 int16_t nCpSizeF2[2][4][2] =
\r
149 // 50Mhz 100MHz 200MHz 400MHz
\r
150 { {0, 0}, {104, 72}, {208, 144}, {416, 288}}, // Numerology 2 (60KHz)
\r
151 {{68, 36}, {136, 72}, {272, 144}, {544, 288}}, // Numerology 3 (120KHz)
\r
154 uint32_t gMaxSlotNum;
\r
155 uint32_t gNumDLCtx;
\r
156 uint32_t gNumULCtx;
\r
157 uint32_t gDLResetAdvance;
\r
158 uint32_t gDLProcAdvance;
\r
159 uint32_t gULProcAdvance;
\r
161 static uint16_t g_NumSlotTDDLoop[XRAN_MAX_SECTOR_NR] = { XRAN_NUM_OF_SLOT_IN_TDD_LOOP };
\r
162 static uint16_t g_NumDLSymSp[XRAN_MAX_SECTOR_NR][XRAN_NUM_OF_SLOT_IN_TDD_LOOP] = {0};
\r
163 static uint16_t g_NumULSymSp[XRAN_MAX_SECTOR_NR][XRAN_NUM_OF_SLOT_IN_TDD_LOOP] = {0};
\r
164 static uint8_t g_SlotType[XRAN_MAX_SECTOR_NR][XRAN_NUM_OF_SLOT_IN_TDD_LOOP] = {{XRAN_SLOT_TYPE_INVALID}};
\r
165 float g_UlRate[XRAN_MAX_SECTOR_NR] = {0.0};
\r
166 float g_DlRate[XRAN_MAX_SECTOR_NR] = {0.0};
\r
168 uint32_t app_xran_get_tti_interval(uint8_t nMu)
\r
172 return nTtiInterval[nMu];
\r
176 printf("ERROR: %s Mu[%d] is not valid\n",__FUNCTION__, nMu);
\r
182 uint32_t app_xran_get_scs(uint8_t nMu)
\r
186 return nSubCarrierSpacing[nMu];
\r
190 printf("ERROR: %s Mu[%d] is not valid\n",__FUNCTION__, nMu);
\r
199 //-------------------------------------------------------------------------------------------
\r
200 /** @ingroup group_nr5g_source_phy_common
\r
202 * @param[in] nNumerology - Numerology determine sub carrier spacing, Value: 0->4 0: 15khz, 1: 30khz, 2: 60khz 3: 120khz, 4: 240khz
\r
203 * @param[in] nBandwidth - Carrier bandwidth for in MHz. Value: 5->400
\r
204 * @param[in] nAbsFrePointA - Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000
\r
206 * @return Number of RBs in cell
\r
209 * Returns number of RBs based on 38.101-1 and 38.101-2 for the cell
\r
212 //-------------------------------------------------------------------------------------------
\r
213 uint16_t app_xran_get_num_rbs(uint32_t nNumerology, uint32_t nBandwidth, uint32_t nAbsFrePointA)
\r
215 uint32_t error = 1;
\r
216 uint16_t numRBs = 0;
\r
218 if (nAbsFrePointA <= 6000000)
\r
220 // F1 Tables 38.101-1 Table 5.3.2-1. Maximum transmission bandwidth configuration NRB
\r
221 if (nNumerology < 3)
\r
225 case PHY_BW_5_0_MHZ:
\r
226 numRBs = nNumRbsPerSymF1[nNumerology][0];
\r
229 case PHY_BW_10_0_MHZ:
\r
230 numRBs = nNumRbsPerSymF1[nNumerology][1];
\r
233 case PHY_BW_15_0_MHZ:
\r
234 numRBs = nNumRbsPerSymF1[nNumerology][2];
\r
237 case PHY_BW_20_0_MHZ:
\r
238 numRBs = nNumRbsPerSymF1[nNumerology][3];
\r
241 case PHY_BW_25_0_MHZ:
\r
242 numRBs = nNumRbsPerSymF1[nNumerology][4];
\r
245 case PHY_BW_30_0_MHZ:
\r
246 numRBs = nNumRbsPerSymF1[nNumerology][5];
\r
249 case PHY_BW_40_0_MHZ:
\r
250 numRBs = nNumRbsPerSymF1[nNumerology][6];
\r
253 case PHY_BW_50_0_MHZ:
\r
254 numRBs = nNumRbsPerSymF1[nNumerology][7];
\r
257 case PHY_BW_60_0_MHZ:
\r
258 numRBs = nNumRbsPerSymF1[nNumerology][8];
\r
261 case PHY_BW_70_0_MHZ:
\r
262 numRBs = nNumRbsPerSymF1[nNumerology][9];
\r
265 case PHY_BW_80_0_MHZ:
\r
266 numRBs = nNumRbsPerSymF1[nNumerology][10];
\r
269 case PHY_BW_90_0_MHZ:
\r
270 numRBs = nNumRbsPerSymF1[nNumerology][11];
\r
273 case PHY_BW_100_0_MHZ:
\r
274 numRBs = nNumRbsPerSymF1[nNumerology][12];
\r
285 if ((nNumerology >= 2) && (nNumerology <= 3))
\r
287 // F2 Tables 38.101-2 Table 5.3.2-1. Maximum transmission bandwidth configuration NRB
\r
290 case PHY_BW_50_0_MHZ:
\r
291 numRBs = nNumRbsPerSymF2[nNumerology-2][0];
\r
294 case PHY_BW_100_0_MHZ:
\r
295 numRBs = nNumRbsPerSymF2[nNumerology-2][1];
\r
298 case PHY_BW_200_0_MHZ:
\r
299 numRBs = nNumRbsPerSymF2[nNumerology-2][2];
\r
302 case PHY_BW_400_0_MHZ:
\r
303 numRBs = nNumRbsPerSymF2[nNumerology-2][3];
\r
316 printf("ERROR: %s: nNumerology[%d] nBandwidth[%d] nAbsFrePointA[%d]\n",__FUNCTION__, nNumerology, nBandwidth, nAbsFrePointA);
\r
320 printf("%s: nNumerology[%d] nBandwidth[%d] nAbsFrePointA[%d] numRBs[%d]\n",__FUNCTION__, nNumerology, nBandwidth, nAbsFrePointA, numRBs);
\r
326 //-------------------------------------------------------------------------------------------
\r
327 /** @ingroup phy_cal_nrarfcn
\r
329 * @param[in] center frequency
\r
334 * This calculates NR-ARFCN value according to center frequency
\r
337 //-------------------------------------------------------------------------------------------
\r
338 uint32_t app_xran_cal_nrarfcn(uint32_t nCenterFreq)
\r
340 uint32_t nDeltaFglobal,nFoffs,nNoffs;
\r
341 uint32_t nNRARFCN = 0;
\r
343 if(nCenterFreq > 0 && nCenterFreq < 3000*1000)
\r
349 else if(nCenterFreq >= 3000*1000 && nCenterFreq < 24250*1000)
\r
351 nDeltaFglobal = 15;
\r
352 nFoffs = 3000*1000;
\r
355 else if(nCenterFreq >= 24250*1000 && nCenterFreq <= 100000*1000)
\r
357 nDeltaFglobal = 60;
\r
363 printf("@@@@ incorrect center frerquency %d\n",nCenterFreq);
\r
367 nNRARFCN = ((nCenterFreq - nFoffs)/nDeltaFglobal) + nNoffs;
\r
369 printf("%s: nCenterFreq[%d] nDeltaFglobal[%d] nFoffs[%d] nNoffs[%d] nNRARFCN[%d]\n", __FUNCTION__, nCenterFreq, nDeltaFglobal, nFoffs, nNoffs, nNRARFCN);
\r
373 int32_t app_xran_slot_limit(int32_t nSfIdx)
\r
375 while (nSfIdx < 0) {
\r
376 nSfIdx += gMaxSlotNum;
\r
379 while (nSfIdx >= gMaxSlotNum) {
\r
380 nSfIdx -= gMaxSlotNum;
\r
386 void app_xran_clear_slot_type(uint32_t nPhyInstanceId)
\r
388 g_UlRate[nPhyInstanceId] = 0.0;
\r
389 g_DlRate[nPhyInstanceId] = 0.0;
\r
390 g_NumSlotTDDLoop[nPhyInstanceId] = 1;
\r
393 int32_t app_xran_set_slot_type(uint32_t nPhyInstanceId, uint32_t nFrameDuplexType, uint32_t nTddPeriod, struct xran_slot_config *psSlotConfig)
\r
395 uint32_t nSlotNum, nSymNum, nVal, i;
\r
396 uint32_t numDlSym, numUlSym, numGuardSym;
\r
397 uint32_t numDlSlots = 0, numUlSlots = 0, numSpDlSlots = 0, numSpUlSlots = 0, numSpSlots = 0;
\r
398 char sSlotPattern[XRAN_SLOT_TYPE_LAST][10] = {"IN\0", "DL\0", "UL\0", "SP\0", "FD\0"};
\r
400 // nPhyInstanceId Carrier ID
\r
401 // nFrameDuplexType 0 = FDD 1 = TDD
\r
402 // nTddPeriod Tdd Periodicity
\r
403 // psSlotConfig[80] Slot Config Structure for nTddPeriod Slots
\r
405 g_UlRate[nPhyInstanceId] = 0.0;
\r
406 g_DlRate[nPhyInstanceId] = 0.0;
\r
407 g_NumSlotTDDLoop[nPhyInstanceId] = nTddPeriod;
\r
409 for (i = 0; i < XRAN_NUM_OF_SLOT_IN_TDD_LOOP; i++)
\r
411 g_SlotType[nPhyInstanceId][i] = XRAN_SLOT_TYPE_INVALID;
\r
412 g_NumDLSymSp[nPhyInstanceId][i] = 0;
\r
413 g_NumULSymSp[nPhyInstanceId][i] = 0;
\r
416 if (nFrameDuplexType == XRAN_FDD)
\r
418 for (i = 0; i < XRAN_NUM_OF_SLOT_IN_TDD_LOOP; i++)
\r
420 g_SlotType[nPhyInstanceId][i] = XRAN_SLOT_TYPE_FDD;
\r
422 g_NumSlotTDDLoop[nPhyInstanceId] = 1;
\r
423 g_DlRate[nPhyInstanceId] = 1.0;
\r
424 g_UlRate[nPhyInstanceId] = 1.0;
\r
428 for (nSlotNum = 0; nSlotNum < nTddPeriod; nSlotNum++)
\r
433 for (nSymNum = 0; nSymNum < XRAN_NUM_OF_SYMBOL_PER_SLOT; nSymNum++)
\r
435 switch(psSlotConfig[nSlotNum].nSymbolType[nSymNum])
\r
437 case XRAN_SYMBOL_TYPE_DL:
\r
440 case XRAN_SYMBOL_TYPE_GUARD:
\r
449 // printf("nSlotNum[%d] : numDlSym[%d] numGuardSym[%d] numUlSym[%d]\n", nSlotNum, numDlSym, numGuardSym, numUlSym);
\r
451 if ((numUlSym == 0) && (numGuardSym == 0))
\r
453 g_SlotType[nPhyInstanceId][nSlotNum] = XRAN_SLOT_TYPE_DL;
\r
456 else if ((numDlSym == 0) && (numGuardSym == 0))
\r
458 g_SlotType[nPhyInstanceId][nSlotNum] = XRAN_SLOT_TYPE_UL;
\r
463 g_SlotType[nPhyInstanceId][nSlotNum] = XRAN_SLOT_TYPE_SP;
\r
469 g_NumDLSymSp[nPhyInstanceId][nSlotNum] = numDlSym;
\r
474 g_NumULSymSp[nPhyInstanceId][nSlotNum] = numUlSym;
\r
478 // printf(" numDlSlots[%d] numUlSlots[%d] numSpSlots[%d] numSpDlSlots[%d] numSpUlSlots[%d]\n", numDlSlots, numUlSlots, numSpSlots, numSpDlSlots, numSpUlSlots);
\r
481 g_DlRate[nPhyInstanceId] = (float)(numDlSlots + numSpDlSlots) / (float)nTddPeriod;
\r
482 g_UlRate[nPhyInstanceId] = (float)(numUlSlots + numSpUlSlots) / (float)nTddPeriod;
\r
485 printf("set_slot_type: nPhyInstanceId[%d] nFrameDuplexType[%d], nTddPeriod[%d]\n",
\r
486 nPhyInstanceId, nFrameDuplexType, nTddPeriod);
\r
488 printf("DLRate[%f] ULRate[%f]\n", g_DlRate[nPhyInstanceId], g_UlRate[nPhyInstanceId]);
\r
490 nVal = (g_NumSlotTDDLoop[nPhyInstanceId] < 10) ? g_NumSlotTDDLoop[nPhyInstanceId] : 10;
\r
492 printf("SlotPattern:\n");
\r
494 for (nSlotNum = 0; nSlotNum < nVal; nSlotNum++)
\r
496 printf("%d ", nSlotNum);
\r
500 printf(" %3d ", 0);
\r
501 for (nSlotNum = 0, i = 0; nSlotNum < g_NumSlotTDDLoop[nPhyInstanceId]; nSlotNum++)
\r
503 printf("%s ", sSlotPattern[g_SlotType[nPhyInstanceId][nSlotNum]]);
\r
505 if ((i == 10) && ((nSlotNum+1) < g_NumSlotTDDLoop[nPhyInstanceId]))
\r
508 printf(" %3d ", nSlotNum);
\r
517 int32_t app_xran_get_slot_type(int32_t nCellIdx, int32_t nSlotdx, int32_t nType)
\r
519 int32_t nSfIdxMod, nSfType, ret = 0;
\r
521 nSfIdxMod = app_xran_slot_limit(nSlotdx) % ((g_NumSlotTDDLoop[nCellIdx] > 0) ? g_NumSlotTDDLoop[nCellIdx]: 1);
\r
522 nSfType = g_SlotType[nCellIdx][nSfIdxMod];
\r
524 if (nSfType == nType)
\r
528 else if (nSfType == XRAN_SLOT_TYPE_SP)
\r
530 if ((nType == XRAN_SLOT_TYPE_DL) && g_NumDLSymSp[nCellIdx][nSfIdxMod])
\r
535 if ((nType == XRAN_SLOT_TYPE_UL) && g_NumULSymSp[nCellIdx][nSfIdxMod])
\r
540 else if (nSfType == XRAN_SLOT_TYPE_FDD)
\r
550 void sys_save_buf_to_file(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num)
\r
554 if (filename && bufname)
\r
557 printf("Storing %s to file %s: ", bufname, filename);
\r
558 file = fopen(filename, "wb");
\r
561 printf("can't open file %s!!!", filename);
\r
566 num = fwrite(pBuffer, buffers_num, size, file);
\r
569 printf("from addr (0x%lx) size (%d) bytes num (%d)", (uint64_t)pBuffer, size, num);
\r
575 printf(" the file name, buffer name are not set!!!");
\r
580 printf(" the %s is free: size = %d bytes!!!", bufname, size);
\r
584 int sys_load_file_to_buff(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num)
\r
586 unsigned int file_size = 0;
\r
591 if (filename && bufname)
\r
594 printf("Loading file %s to %s: ", filename, bufname);
\r
595 file = fopen(filename, "rb");
\r
600 printf("can't open file %s!!!", filename);
\r
605 fseek(file, 0, SEEK_END);
\r
606 file_size = ftell(file);
\r
607 fseek(file, 0, SEEK_SET);
\r
609 if ((file_size > size) || (file_size == 0))
\r
612 printf("Reading IQ samples from file: File Size: %d [Buffer Size: %d]\n", file_size, size);
\r
614 num = fread(pBuffer, buffers_num, size, file);
\r
617 printf("from addr (0x%lx) size (%d) bytes num (%d)", (uint64_t)pBuffer, file_size, num);
\r
624 printf(" the file name, buffer name are not set!!!");
\r
629 printf(" the %s is free: size = %d bytes!!!", bufname, size);
\r
635 void sys_save_buf_to_file_txt(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num)
\r
639 if (pBuffer == NULL)
\r
644 if (filename && bufname)
\r
647 printf("Storing %s to file %s: ", bufname, filename);
\r
648 file = fopen(filename, "w");
\r
651 printf("can't open file %s!!!", filename);
\r
658 signed short *ptr = (signed short*)pBuffer;
\r
659 for (i = 0; i < (size/((unsigned int)sizeof(signed short) /** 2 * 2 * 2*/)); i = i + 2)
\r
661 #ifndef CSCOPE_DEBUG
\r
662 ret = fprintf(file,"%d %d\n", ptr[i], ptr[i + 1]);
\r
664 ret = fprintf(file,"%d %d ", ptr[i], ptr[i + 1]);
\r
665 /* I data => Ramp data, from 1 to 792.
\r
666 Q data => Contains time information of the current symbol:
\r
667 Bits [15:14] = Antenna-ID
\r
668 Bits [13:12] =
\9300
\94\r
669 Bits [11:8] = Subframe-ID
\r
670 Bits [7:4] = Slot-ID
\r
671 Bits [3:0] = Symbol-ID */
\r
672 fprintf(file, "0x%04x: ant %d Subframe-ID %d Slot-ID %d Symbol-ID %d\n",
\r
673 ptr[i + 1], (ptr[i + 1]>>14) & 0x3, (ptr[i + 1]>>8) & 0xF, (ptr[i + 1]>>4) & 0xF, (ptr[i + 1]>>0) & 0xF);
\r
677 printf("fprintf %d\n", ret);
\r
685 printf("from addr (0x%lx) size (%d) IQ num (%d)", (uint64_t)pBuffer, size, num);
\r
691 printf(" the file name, buffer name are not set!!!");
\r
696 printf(" the %s is free: size = %d bytes!!!", bufname, size);
\r