Commit 6e76ecdd authored by knopp's avatar knopp
Browse files

Applied S. Held's patches 16, additional modifications for UE frequency...

Applied S. Held's patches 16, additional modifications for UE frequency scanning and RSRP/RSSI calibration for ExpressMIMO2 and USRP B210

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7536 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent ea655773
......@@ -250,7 +250,7 @@ int openair0_stop_without_reset(int card)
int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
// Initialize card
exmimo_config_t *p_exmimo_config;
// exmimo_config_t *p_exmimo_config;
exmimo_id_t *p_exmimo_id;
int ret;
......@@ -276,7 +276,7 @@ int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cf
printf ("Detected %d number of cards, %d number of antennas.\n", openair0_num_detected_cards, openair0_num_antennas[0]);
}
p_exmimo_config = openair0_exmimo_pci[0].exmimo_config_ptr;
// p_exmimo_config = openair0_exmimo_pci[0].exmimo_config_ptr;
p_exmimo_id = openair0_exmimo_pci[0].exmimo_id_ptr;
printf("Card %d: ExpressMIMO %d, HW Rev %d, SW Rev 0x%d\n", 0, p_exmimo_id->board_exmimoversion, p_exmimo_id->board_hwrev, p_exmimo_id->board_swrev);
......@@ -356,14 +356,15 @@ int openair0_config(openair0_config_t *openair0_cfg, int UE_flag)
for (ant=0; ant<4; ant++) {
if (openair0_cfg[card].rx_freq[ant] || openair0_cfg[card].tx_freq[ant]) {
p_exmimo_config->rf.rf_mode[ant] = RF_MODE_BASE;
p_exmimo_config->rf.do_autocal[ant] = 1;
p_exmimo_config->rf.do_autocal[ant] = 1;//openair0_cfg[card].autocal[ant];
printf("card %d, antenna %d, autocal %d\n",card,ant,openair0_cfg[card].autocal[ant]);
}
if (openair0_cfg[card].tx_freq[ant]) {
p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX + TXLPFNORM + TXLPFEN + tx_filter);
p_exmimo_config->rf.rf_freq_tx[ant] = (unsigned int)openair0_cfg[card].tx_freq[ant];
p_exmimo_config->rf.tx_gain[ant][0] = (unsigned int)openair0_cfg[card].tx_gain[ant];
printf("openair0 : programming card %d TX antenna %d (freq %u, gain %d)\n",card,ant,p_exmimo_config->rf.rf_freq_tx[ant],p_exmimo_config->rf.tx_gain[ant][0]);
}
if (openair0_cfg[card].rx_freq[ant]) {
......@@ -419,11 +420,11 @@ int openair0_config(openair0_config_t *openair0_cfg, int UE_flag)
int openair0_reconfig(openair0_config_t *openair0_cfg)
{
int ret;
int ant, card;
exmimo_config_t *p_exmimo_config;
exmimo_id_t *p_exmimo_id;
// exmimo_id_t *p_exmimo_id;
if (!openair0_cfg) {
printf("Error, openair0_cfg is null!!\n");
......@@ -433,7 +434,7 @@ int openair0_reconfig(openair0_config_t *openair0_cfg)
for (card=0; card<openair0_num_detected_cards; card++) {
p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr;
p_exmimo_id = openair0_exmimo_pci[card].exmimo_id_ptr;
// p_exmimo_id = openair0_exmimo_pci[card].exmimo_id_ptr;
for (ant=0; ant<4; ant++) {
if (openair0_cfg[card].tx_freq[ant]) {
......@@ -468,6 +469,18 @@ int openair0_reconfig(openair0_config_t *openair0_cfg)
return(0);
}
int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config) {
if (exmimo_dump_config > 0) {
// do a full configuration
openair0_config(openair0_cfg,0);
}
else { // just change the frequencies in pci descriptor
openair0_reconfig(openair0_cfg);
}
return(0);
}
unsigned int *openair0_daq_cnt(void) {
......
......@@ -95,4 +95,7 @@ int openair0_stop_without_reset(int card);
// return the DAQ block counter
unsigned int *openair0_daq_cnt(void);
// set the TX and RX frequencies (card 0 only for now, to retain USRP compatibility)
int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config);
#endif
......@@ -195,7 +195,7 @@ static bool is_equal(double a, double b)
return std::fabs(a-b) < std::numeric_limits<double>::epsilon();
}
int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair0_cfg) {
int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair0_cfg,int dummy) {
usrp_state_t *s = (usrp_state_t*)device->priv;
......@@ -231,7 +231,13 @@ int openair0_set_gains(openair0_device* device, openair0_config_t *openair0_cfg)
s->usrp->set_rx_gain(openair0_cfg[0].rx_gain[0]);
return(0);
}
int openair0_stop(int card) {
return(0);
}
int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cfg)
{
uhd::set_thread_priority_safe(1.0);
......
......@@ -247,6 +247,7 @@ static char *itti_dump_file = NULL;
#endif
int UE_scan = 1;
int UE_scan_carrier = 0;
runmode_t mode = normal_txrx;
......@@ -430,7 +431,7 @@ void help (void) {
printf(" --no-L2-connect bypass L2 and upper layers\n");
printf(" --ue_rxgain set UE RX gain\n");
printf(" --ue_txgain set UE tx gain\n");
printf(" --ue_scan_carrier set UE to scan around carrier\n");
printf(" -C Set the downlink frequecny for all Component carrier\n");
printf(" -d Enable soft scope and L1 and L2 stats (Xforms)\n");
printf(" -F Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n");
......@@ -598,7 +599,7 @@ static void *scope_thread(void *arg)
sleep(1);
}
printf("%s",stats_buffer);
// printf("%s",stats_buffer);
# ifdef ENABLE_XFORMS_WRITE_STATS
......@@ -1934,6 +1935,7 @@ static void get_options (int argc, char **argv)
LONG_OPTION_NO_L2_CONNECT,
LONG_OPTION_RXGAIN,
LONG_OPTION_TXGAIN,
LONG_OPTION_SCANCARRIER
};
static const struct option long_options[] = {
......@@ -1945,6 +1947,7 @@ static void get_options (int argc, char **argv)
{"no-L2-connect", no_argument, NULL, LONG_OPTION_NO_L2_CONNECT},
{"ue_rxgain", required_argument, NULL, LONG_OPTION_RXGAIN},
{"ue_txgain", required_argument, NULL, LONG_OPTION_TXGAIN},
{"ue_scan_carrier", no_argument, NULL, LONG_OPTION_SCANCARRIER},
{NULL, 0, NULL, 0}
};
......@@ -1993,6 +1996,11 @@ static void get_options (int argc, char **argv)
break;
case LONG_OPTION_SCANCARRIER:
UE_scan_carrier=1;
break;
case 'M':
#ifdef ETHERNET
strcpy(rrh_eNB_ip,optarg);
......@@ -2009,6 +2017,7 @@ static void get_options (int argc, char **argv)
}
UE_scan=0;
break;
case 'd':
......@@ -2564,6 +2573,7 @@ int main( int argc, char **argv )
UE[CC_id]->UE_scan = UE_scan;
UE[CC_id]->UE_scan_carrier = UE_scan_carrier;
UE[CC_id]->mode = mode;
compute_prach_seq(&UE[CC_id]->lte_frame_parms.prach_config_common,
......@@ -2794,6 +2804,7 @@ int main( int argc, char **argv )
for (i=0; i<4; i++) {
openair0_cfg[card].autocal[i] = 1;
openair0_cfg[card].tx_gain[i] = tx_gain[0][i];
openair0_cfg[card].rx_gain[i] = ((UE_flag==0) ? PHY_vars_eNB_g[0][0]->rx_total_gain_eNB_dB :
PHY_vars_UE_g[0][0]->rx_total_gain_dB) - USRP_GAIN_OFFSET; // calibrated for USRP B210 @ 2.6 GHz, 30.72 MS/s
......@@ -2830,6 +2841,7 @@ int main( int argc, char **argv )
printf("Initializing openair0 ...");
openair0_cfg[0].log_level = glog_level;
if (openair0_device_init(&openair0, &openair0_cfg[0]) <0) {
printf("Exiting, cannot initialize device\n");
exit(-1);
......@@ -3387,15 +3399,15 @@ int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_c
for (i=0; i<frame_parms->nb_antennas_rx; i++) {
free(phy_vars_eNB[CC_id]->lte_eNB_common_vars.rxdata[0][i]);
rxdata[i] = (int32_t*)(16 + malloc16(16+samples_per_frame*sizeof(int32_t)));
phy_vars_eNB[CC_id]->lte_eNB_common_vars.rxdata[0][i] = rxdata[i]-N_TA_offset; // N_TA offset for TDD
rxdata[i] = (int32_t*)(16 + malloc16(16+samples_per_frame*sizeof(int32_t))); // FIXME broken memory allocation
phy_vars_eNB[CC_id]->lte_eNB_common_vars.rxdata[0][i] = rxdata[i]-N_TA_offset; // N_TA offset for TDD FIXME! N_TA_offset > 16 => access of unallocated memory
memset(rxdata[i], 0, samples_per_frame*sizeof(int32_t));
printf("rxdata[%d] @ %p (%p) (N_TA_OFFSET %d)\n", i, phy_vars_eNB[CC_id]->lte_eNB_common_vars.rxdata[0][i],rxdata[i],N_TA_offset);
}
for (i=0; i<frame_parms->nb_antennas_tx; i++) {
free(phy_vars_eNB[CC_id]->lte_eNB_common_vars.txdata[0][i]);
txdata[i] = (int32_t*)(16 + malloc16(16 + samples_per_frame*sizeof(int32_t)));
txdata[i] = (int32_t*)(16 + malloc16(16 + samples_per_frame*sizeof(int32_t))); // FIXME broken memory allocation
phy_vars_eNB[CC_id]->lte_eNB_common_vars.txdata[0][i] = txdata[i];
memset(txdata[i], 0, samples_per_frame*sizeof(int32_t));
printf("txdata[%d] @ %p\n", i, phy_vars_eNB[CC_id]->lte_eNB_common_vars.txdata[0][i]);
......
......@@ -119,7 +119,6 @@ extern int oai_exit;
extern int32_t **rxdata;
extern int32_t **txdata;
extern unsigned int samples_per_frame;
extern unsigned int tx_forward_nsamps;
extern int tx_delay;
......@@ -206,10 +205,11 @@ static void *UE_thread_synch(void *arg)
PHY_VARS_UE *UE = (PHY_VARS_UE*) arg;
int current_band = 0;
int current_offset = 0;
sync_mode_t sync_mode = pss;
sync_mode_t sync_mode = pbch;
int card;
int ind;
int found;
int freq_offset=0;
UE->is_synchronized = 0;
printf("UE_thread_sync in with PHY_vars_UE %p\n",arg);
......@@ -224,7 +224,7 @@ static void *UE_thread_synch(void *arg)
pthread_mutex_unlock(&sync_mutex);
printf("unlocked sync_mutex (UE_sync_thread)\n");
printf("starting UE synch thread\n");
printf("starting UE synch thread (IC %d)\n",UE->instance_cnt_synch);
ind = 0;
found = 0;
......@@ -244,26 +244,28 @@ static void *UE_thread_synch(void *arg)
}
ind++;
} while (current_band < sizeof(eutra_bands) / sizeof(eutra_bands[0]));
} while (ind < sizeof(eutra_bands) / sizeof(eutra_bands[0]));
if (found == 0) {
exit_fun("Can't find EUTRA band for frequency");
return &UE_thread_synch_retval;
}
#ifdef OAI_USRP
// now we know the uplink_frequency_offset
// set the correct TX frequency
for (i=0; i<openair0_cfg[card].tx_num_channels; i++) {
openair0_cfg[0].tx_freq[i] = downlink_frequency[0][i] + uplink_frequency_offset[0][i];
}
openair0_set_frequencies( &openair0, &openair0_cfg[0] );
#endif
LOG_D( PHY, "[SCHED][UE] Check absolute frequency %"PRIu32" (oai_exit %d)\n", downlink_frequency[0][0], oai_exit );
LOG_I( PHY, "[SCHED][UE] Check absolute frequency %"PRIu32" (oai_exit %d)\n", downlink_frequency[0][0], oai_exit );
for (i=0;i<openair0_cfg[0].rx_num_channels;i++) {
openair0_cfg[0].rx_freq[i] = downlink_frequency[0][i];
openair0_cfg[0].tx_freq[i] = downlink_frequency[0][i]+uplink_frequency_offset[0][i];
openair0_cfg[0].autocal[i] = 1;
}
sync_mode = pbch;
} else if (UE->UE_scan == 1) {
current_band=0;
......@@ -298,16 +300,8 @@ static void *UE_thread_synch(void *arg)
printf( "UE synch: setting RX gain (%d,%d) to %f\n", card, i, openair0_cfg[card].rx_gain[i] );
#endif
}
#ifdef EXMIMO
//openair0_config(&openair0_cfg[card],1);
#endif
}
#if defined(OAI_USRP) && !defined(USRP_DEBUG)
openair0_set_frequencies( &openair0, &openair0_cfg[0] );
openair0_set_gains( &openair0, &openair0_cfg[0] );
#endif
}
while (oai_exit==0) {
......@@ -317,6 +311,7 @@ static void *UE_thread_synch(void *arg)
exit_fun("noting to add");
return &UE_thread_synch_retval;
}
while (UE->instance_cnt_synch < 0) {
// the thread waits here most of the time
......@@ -353,8 +348,8 @@ static void *UE_thread_synch(void *arg)
uplink_frequency_offset[card][i] = bands_to_scan.band_info[current_band].ul_min-bands_to_scan.band_info[0].dl_min + current_offset;
openair0_cfg[card].rx_freq[i] = downlink_frequency[card][i]+openair_daq_vars.freq_offset;
openair0_cfg[card].tx_freq[i] = downlink_frequency[card][i]+uplink_frequency_offset[card][i]+openair_daq_vars.freq_offset;
openair0_cfg[card].rx_freq[i] = downlink_frequency[card][i];
openair0_cfg[card].tx_freq[i] = downlink_frequency[card][i]+uplink_frequency_offset[card][i];
#ifdef OAI_USRP
openair0_cfg[card].rx_gain[i] = UE->rx_total_gain_dB-USRP_GAIN_OFFSET; // 65 calibrated for USRP B210 @ 2.6 GHz
......@@ -381,65 +376,100 @@ static void *UE_thread_synch(void *arg)
}
#ifdef EXMIMO
//openair0_config(&openair0_cfg[card],1);
#endif
}
#ifdef OAI_USRP
#ifndef USRP_DEBUG
openair0_set_frequencies(&openair0,&openair0_cfg[0]);
// openair0_set_gains(&openair0,&openair0_cfg[0]);
#endif
#endif
if (UE->UE_scan_carrier) {
break;
for (i=0;i<openair0_cfg[0].rx_num_channels;i++)
openair0_cfg[0].autocal[i] = 1;
}
break;
case pbch:
// This is a hack to fix a bug when using USRP
// FIXME is this necessary anymore? Which bug is fixed by this hack?
memset(PHY_vars_UE_g[0][0]->lte_ue_common_vars.rxdata[0],0,1024);
if (initial_sync( UE, UE->mode ) == 0) {
UE->is_synchronized = 1;
hw_slot_offset = (UE->rx_offset<<1) / UE->lte_frame_parms.samples_per_tti;
LOG_I( HW, "Got synch: hw_slot_offset %d\n", hw_slot_offset );
if (UE->UE_scan_carrier == 1) {
UE->UE_scan_carrier = 0;
// rerun with new cell parameters and frequency-offset
for (i=0;i<openair0_cfg[0].rx_num_channels;i++) {
openair0_cfg[0].rx_freq[i] -= UE->lte_ue_common_vars.freq_offset;
openair0_cfg[0].tx_freq[i] = openair0_cfg[0].rx_freq[i]+uplink_frequency_offset[0][i];
downlink_frequency[0][i] = openair0_cfg[0].rx_freq[i];
freq_offset=0;
}
openair0_stop(0);
sleep(1);
switch(UE->lte_frame_parms.N_RB_DL) {
case 6:
openair0_cfg[0].sample_rate =1.92e6;
break;
case 25:
openair0_cfg[0].sample_rate=7.68e6;
break;
case 50:
openair0_cfg[0].sample_rate=15.36e6;
break;
case 100:
openair0_cfg[0].sample_rate=30.72e6;
break;
}
// reconfigure for potentially different bandwidth
init_frame_parms(&UE->lte_frame_parms,1);
}
else {
UE->is_synchronized = 1;
#ifndef EXMIMO
UE->slot_rx = 0;
UE->slot_tx = 4;
UE->slot_rx = 0;
UE->slot_tx = 4;
#else
UE->slot_rx = 18;
UE->slot_tx = 2;
UE->slot_rx = 18;
UE->slot_tx = 2;
#endif
hw_slot_offset = (UE->rx_offset<<1) / UE->lte_frame_parms.samples_per_tti;
LOG_I( HW, "Got synch: hw_slot_offset %d\n", hw_slot_offset );
}
} else {
// initial sync failed
// calculate new offset and try again
if (openair_daq_vars.freq_offset >= 0) {
openair_daq_vars.freq_offset += 100;
openair_daq_vars.freq_offset *= -1;
} else {
openair_daq_vars.freq_offset *= -1;
}
if (abs(openair_daq_vars.freq_offset) > 7500) {
LOG_I( PHY, "[initial_sync] No cell synchronization found, abandoning\n" );
mac_xface->macphy_exit("No cell synchronization found, abandoning");
return &UE_thread_synch_retval; // not reached
}
LOG_I( PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n", openair_daq_vars.freq_offset,
if (UE->UE_scan_carrier == 1) {
if (freq_offset >= 0) {
freq_offset += 100;
freq_offset *= -1;
} else {
freq_offset *= -1;
}
if (abs(freq_offset) > 7500) {
LOG_I( PHY, "[initial_sync] No cell synchronization found, abandoning\n" );
mac_xface->macphy_exit("No cell synchronization found, abandoning");
return &UE_thread_synch_retval; // not reached
}
}
else {
}
LOG_I( PHY, "[initial_sync] trying carrier off %d Hz, rxgain %d (DL %u, UL %u)\n",
freq_offset,
UE->rx_total_gain_dB,
downlink_frequency[0][0]+openair_daq_vars.freq_offset,
downlink_frequency[0][0]+uplink_frequency_offset[0][0]+openair_daq_vars.freq_offset );
downlink_frequency[0][0]+freq_offset,
downlink_frequency[0][0]+uplink_frequency_offset[0][0]+freq_offset );
for (card=0; card<MAX_CARDS; card++) {
for (i=0; i<openair0_cfg[card].rx_num_channels; i++) {
openair0_cfg[card].rx_freq[i] = downlink_frequency[card][i]+openair_daq_vars.freq_offset;
openair0_cfg[card].tx_freq[i] = downlink_frequency[card][i]+uplink_frequency_offset[card][i]+openair_daq_vars.freq_offset;
openair0_cfg[card].rx_freq[i] = downlink_frequency[card][i]+freq_offset;
openair0_cfg[card].tx_freq[i] = downlink_frequency[card][i]+uplink_frequency_offset[card][i]+freq_offset;
#ifdef OAI_USRP
openair0_cfg[card].rx_gain[i] = UE->rx_total_gain_dB-USRP_GAIN_OFFSET;
openair0_set_frequencies(&openair0,&openair0_cfg[0],0);
switch(UE->lte_frame_parms.N_RB_DL) {
case 6:
openair0_cfg[card].rx_gain[i] -= 12;
......@@ -461,11 +491,12 @@ static void *UE_thread_synch(void *arg)
#endif
}
}
#if defined(OAI_USRP) && !defined(USRP_DEBUG)
openair0_set_frequencies( &openair0, &openair0_cfg[0] );
#endif
} // initial_sync=0
if (UE->UE_scan_carrier==1) {
for (i=0;i<openair0_cfg[0].rx_num_channels;i++)
openair0_cfg[0].autocal[i] = 1;
}
}// initial_sync=0
break;
......@@ -476,6 +507,8 @@ static void *UE_thread_synch(void *arg)
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SYNCH, 0 );
if (pthread_mutex_lock(&UE->mutex_synch) != 0) {
LOG_E( PHY, "[SCHED][UE] error locking mutex for UE synch\n" );
exit_fun("noting to add");
......@@ -830,6 +863,7 @@ void *UE_thread(void *arg)
int rx_correction_timer = 0;
int first_rx = 0;
RTIME T0;
unsigned int rxs;
openair0_timestamp timestamp;
......@@ -863,7 +897,7 @@ void *UE_thread(void *arg)
exit_fun("Nothing to add");
return &UE_thread_retval;
}
h
LOG_I(HW,"[SCHED][eNB] eNB main deadline thread %lu started on CPU %d\n",
(unsigned long)gettid(), sched_getcpu());
......@@ -892,6 +926,7 @@ void *UE_thread(void *arg)
while (!oai_exit) {
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_HW_SUBFRAME, hw_subframe );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_HW_FRAME, frame );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_DUMMY_DUMP, dummy_dump );
while (rxpos < (1+hw_subframe)*UE->lte_frame_parms.samples_per_tti) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 );
......@@ -903,12 +938,15 @@ void *UE_thread(void *arg)
for (int i=0; i<UE->lte_frame_parms.nb_antennas_rx; i++)
rxp[i] = (dummy_dump==0) ? (void*)&rxdata[i][rxpos] : (void*)dummy[i];
// if (dummy_dump == 0)
// printf("writing %d samples to %d\n",spp - ((first_rx==1) ? rx_off_diff : 0),rxpos);
unsigned int rxs = openair0.trx_read_func(&openair0,
&timestamp,
rxp,
spp - ((first_rx==1) ? rx_off_diff : 0),
UE->lte_frame_parms.nb_antennas_rx);
rxs = openair0.trx_read_func(&openair0,
&timestamp,
rxp,
spp - ((first_rx==1) ? rx_off_diff : 0),
UE->lte_frame_parms.nb_antennas_rx);
if (rxs != (spp- ((first_rx==1) ? rx_off_diff : 0))) {
exit_fun("problem in rx");
......@@ -981,13 +1019,12 @@ void *UE_thread(void *arg)
if (UE->mode == rx_calib_ue) {
if (frame == 10) {
LOG_D(PHY,
"[SCHED][UE] Found cell with N_RB_DL %"PRIu8", PHICH CONFIG (%d,%d), Nid_cell %"PRIu16", NB_ANTENNAS_TX %"PRIu8", initial frequency offset %"PRIi32" Hz, frequency offset "PRIi32" Hz, RSSI (digital) %hu dB, measured Gain %d dB, total_rx_gain %"PRIu32" dB, USRP rx gain %f dB\n",
"[SCHED][UE] Found cell with N_RB_DL %"PRIu8", PHICH CONFIG (%d,%d), Nid_cell %"PRIu16", NB_ANTENNAS_TX %"PRIu8", frequency offset "PRIi32" Hz, RSSI (digital) %hu dB, measured Gain %d dB, total_rx_gain %"PRIu32" dB, USRP rx gain %f dB\n",
UE->lte_frame_parms.N_RB_DL,
UE->lte_frame_parms.phich_config_common.phich_duration,
UE->lte_frame_parms.phich_config_common.phich_resource,
UE->lte_frame_parms.Nid_cell,
UE->lte_frame_parms.nb_antennas_tx_eNB,
openair_daq_vars.freq_offset,
UE->lte_ue_common_vars.freq_offset,
UE->PHY_measurements.rx_power_avg_dB[0],
UE->PHY_measurements.rx_power_avg_dB[0] - rx_input_level_dBm,
......@@ -1098,11 +1135,15 @@ void *UE_thread(void *arg)
// dump ahead in time to start of frame
#ifndef USRP_DEBUG
unsigned int rxs = openair0.trx_read_func(&openair0,
&timestamp,
(void**)rxdata,
UE->rx_offset,
UE->lte_frame_parms.nb_antennas_rx);
rxs = openair0.trx_read_func(&openair0,
&timestamp,
(void**)rxdata,
UE->rx_offset,
UE->lte_frame_parms.nb_antennas_rx);
if (rxs != UE->rx_offset) {
exit_fun("problem in rx");
return &UE_thread_retval;
}
#else
rt_sleep_ns(10000000);
#endif
......@@ -1161,7 +1202,7 @@ void *UE_thread(void *arg)
unsigned int flags = 0;
unsigned long mask = 1; // processor 0
#endif
int freq_offset;
#ifdef RTAI
......@@ -1223,7 +1264,7 @@ void *UE_thread(void *arg)
printf("starting UE thread\n");
openair_daq_vars.freq_offset = 0; //-7500;
freq_offset = 0; //-7500;
first_synch = 1;
......@@ -1375,7 +1416,7 @@ void *UE_thread(void *arg)
UE->lte_frame_parms.phich_config_common.phich_resource,
UE->lte_frame_parms.Nid_cell,
UE->lte_frame_parms.nb_antennas_tx_eNB,
openair_daq_vars.freq_offset,
freq_offset,
UE->lte_ue_common_vars.freq_offset,
UE->PHY_measurements.rx_power_avg_dB[0],
UE->PHY_measurements.rx_power_avg_dB[0] - rx_input_level_dBm,
......@@ -1439,11 +1480,14 @@ void *UE_thread(void *arg)
LOG_E(PHY,"[SCHED][UE] error locking mutex for UE initial synch thread\n");
exit_fun("noting to add");
} else {
//printf("Before getting frame IC %d (UE_thread)\n",UE->instance_cnt_synch);
if (UE->instance_cnt_synch < 0) {
wait_sync_cnt=0;
openair0_config(&openair0_cfg[0],1);
// openair0_set_gains(&openair0,&openair0_cfg[0]);
printf("Getting frame\n");
openair0_get_frame(0);
rt_sleep_ns(FRAME_PERIOD);
// increment instance count for sync thread
......@@ -1482,25 +1526,25 @@ void *UE_thread(void *arg)
}
}
else {
if (openair_daq_vars.freq_offset >= 0) {
openair_daq_vars.freq_offset += 100;
openair_daq_vars.freq_offset *= -1;
if (freq_offset >= 0) {
freq_offset += 100;
freq_offset *= -1;
}
else {