fix bugs, delete dead code
This commit is contained in:
@@ -117,7 +117,7 @@ typedef struct buffer_s {
|
||||
|
||||
typedef struct {
|
||||
int listen_sock, epollfd;
|
||||
openair0_timestamp nextTimestamp;
|
||||
openair0_timestamp nextRxTstamp;
|
||||
openair0_timestamp lastWroteTS;
|
||||
uint64_t typeStamp;
|
||||
char *ip;
|
||||
@@ -196,7 +196,7 @@ static void removeCirBuf(rfsimulator_state_t *bridge, int sock) {
|
||||
free(bridge->buf[sock].circularBuf);
|
||||
// Fixme: no free_channel_desc_scm(bridge->buf[sock].channel_model) implemented
|
||||
// a lot of mem leaks
|
||||
free(bridge->buf[sock].channel_model);
|
||||
//free(bridge->buf[sock].channel_model);
|
||||
memset(&bridge->buf[sock], 0, sizeof(buffer_t));
|
||||
bridge->buf[sock].conn_sock=-1;
|
||||
}
|
||||
@@ -429,8 +429,6 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp
|
||||
if (!alreadyLocked)
|
||||
pthread_mutex_lock(&Sockmutex);
|
||||
|
||||
LOG_D(HW,"sending %d samples at time: %ld\n", nsamps, timestamp);
|
||||
|
||||
for (int i=0; i<FD_SETSIZE; i++) {
|
||||
buffer_t *b=&t->buf[i];
|
||||
|
||||
@@ -549,14 +547,14 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
|
||||
(t->typeStamp == ENB_MAGICDL && b->th.magic==UE_MAGICDL), "Socket Error in protocol");
|
||||
b->headerMode=false;
|
||||
|
||||
if ( t->nextTimestamp == 0 ) { // First block in UE, resync with the eNB current TS
|
||||
t->nextTimestamp=b->th.timestamp> nsamps_for_initial ?
|
||||
if ( t->nextRxTstamp == 0 ) { // First block in UE, resync with the eNB current TS
|
||||
t->nextRxTstamp=b->th.timestamp> nsamps_for_initial ?
|
||||
b->th.timestamp - nsamps_for_initial :
|
||||
0;
|
||||
b->lastReceivedTS=b->th.timestamp> nsamps_for_initial ?
|
||||
b->th.timestamp :
|
||||
nsamps_for_initial;
|
||||
LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp);
|
||||
LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextRxTstamp);
|
||||
b->trashingPacket=true;
|
||||
} else if ( b->lastReceivedTS < b->th.timestamp) {
|
||||
int nbAnt= b->th.nbAnt;
|
||||
@@ -623,7 +621,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
|
||||
}
|
||||
|
||||
rfsimulator_state_t *t = device->priv;
|
||||
LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps);
|
||||
LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextRxTstamp+nsamps);
|
||||
// deliver data from received data
|
||||
// check if a UE is connected
|
||||
int first_sock;
|
||||
@@ -634,54 +632,22 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
|
||||
|
||||
if ( first_sock == FD_SETSIZE ) {
|
||||
// no connected device (we are eNB, no UE is connected)
|
||||
if ( t->nextTimestamp == 0)
|
||||
if ( t->nextRxTstamp == 0)
|
||||
LOG_W(HW,"No connected device, generating void samples...\n");
|
||||
|
||||
if (!flushInput(t, 10, nsamps)) {
|
||||
for (int x=0; x < nbAnt; x++)
|
||||
memset(samplesVoid[x],0,sampleToByte(nsamps,1));
|
||||
|
||||
t->nextTimestamp+=nsamps;
|
||||
t->nextRxTstamp+=nsamps;
|
||||
|
||||
if ( ((t->nextTimestamp/nsamps)%100) == 0)
|
||||
LOG_D(HW,"No UE, Generated void samples for Rx: %ld\n", t->nextTimestamp);
|
||||
if ( ((t->nextRxTstamp/nsamps)%100) == 0)
|
||||
LOG_D(HW,"No UE, Generated void samples for Rx: %ld\n", t->nextRxTstamp);
|
||||
|
||||
*ptimestamp = t->nextTimestamp-nsamps;
|
||||
*ptimestamp = t->nextRxTstamp-nsamps;
|
||||
return nsamps;
|
||||
}
|
||||
} else {
|
||||
pthread_mutex_lock(&Sockmutex);
|
||||
|
||||
if ( t->nextTimestamp > 0 && t->lastWroteTS < t->nextTimestamp) {
|
||||
pthread_mutex_unlock(&Sockmutex);
|
||||
usleep(10000);
|
||||
pthread_mutex_lock(&Sockmutex);
|
||||
|
||||
if ( t->lastWroteTS < t->nextTimestamp ) {
|
||||
// Assuming Tx is not done fully in another thread
|
||||
// We can never write is the past from the received time
|
||||
// So, the node perform receive but will never write these symbols
|
||||
// let's tell this to the opposite node
|
||||
// We send timestamp for nb samples required
|
||||
// assuming this should have been done earlier if a Tx would exist
|
||||
pthread_mutex_unlock(&Sockmutex);
|
||||
struct complex16 v= {0};
|
||||
void *dummyS[t->tx_num_channels];
|
||||
|
||||
for ( int i=0; i < t->tx_num_channels; i++)
|
||||
dummyS[i]=(void *)&v;
|
||||
|
||||
LOG_I(HW, "No samples Tx occured, so we send 1 sample to notify it: Tx:%lu, Rx:%lu\n",
|
||||
t->lastWroteTS, t->nextTimestamp);
|
||||
rfsimulator_write_internal(t, t->nextTimestamp,
|
||||
dummyS, 1,
|
||||
t->tx_num_channels, 1, true);
|
||||
} else {
|
||||
pthread_mutex_unlock(&Sockmutex);
|
||||
LOG_W(HW, "trx_write came from another thread\n");
|
||||
}
|
||||
} else
|
||||
pthread_mutex_unlock(&Sockmutex);
|
||||
|
||||
bool have_to_wait;
|
||||
|
||||
@@ -692,7 +658,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
|
||||
buffer_t *b=&t->buf[sock];
|
||||
|
||||
if ( b->circularBuf )
|
||||
if ( t->nextTimestamp+nsamps > b->lastReceivedTS ) {
|
||||
if ( t->nextRxTstamp+nsamps > b->lastReceivedTS ) {
|
||||
have_to_wait=true;
|
||||
break;
|
||||
}
|
||||
@@ -701,7 +667,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
|
||||
if (have_to_wait)
|
||||
/*printf("Waiting on socket, current last ts: %ld, expected at least : %ld\n",
|
||||
ptr->lastReceivedTS,
|
||||
t->nextTimestamp+nsamps);
|
||||
t->nextRxTstamp+nsamps);
|
||||
*/
|
||||
flushInput(t, 3, nsamps);
|
||||
} while (have_to_wait);
|
||||
@@ -732,7 +698,7 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
|
||||
a,
|
||||
ptr->channel_model,
|
||||
nsamps,
|
||||
t->nextTimestamp,
|
||||
t->nextRxTstamp,
|
||||
CirSize
|
||||
);
|
||||
else { // no channel modeling
|
||||
@@ -747,8 +713,8 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
|
||||
//LOG_I(HW, "nbAnt_tx %d\n",nbAnt_tx);
|
||||
for (int i=0; i < nsamps; i++) {//loop over nsamps
|
||||
for (int a_tx=0; a_tx<nbAnt_tx; a_tx++) { //sum up signals from nbAnt_tx antennas
|
||||
out[i].r += (short)(ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]);
|
||||
out[i].i += (short)(ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]);
|
||||
out[i].r += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].r*H_awgn_mimo[a][a_tx]);
|
||||
out[i].i += (short)(ptr->circularBuf[((t->nextRxTstamp+i)*nbAnt_tx+a_tx)%CirSize].i*H_awgn_mimo[a][a_tx]);
|
||||
} // end for a_tx
|
||||
} // end for i (number of samps)
|
||||
} // end of no channel modeling
|
||||
@@ -756,11 +722,11 @@ static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimest
|
||||
}
|
||||
}
|
||||
|
||||
*ptimestamp = t->nextTimestamp; // return the time of the first sample
|
||||
t->nextTimestamp+=nsamps;
|
||||
*ptimestamp = t->nextRxTstamp; // return the time of the first sample
|
||||
t->nextRxTstamp+=nsamps;
|
||||
LOG_D(HW,"Rx to upper layer: %d from %ld to %ld, energy in first antenna %d\n",
|
||||
nsamps,
|
||||
*ptimestamp, t->nextTimestamp,
|
||||
*ptimestamp, t->nextRxTstamp,
|
||||
signal_energy(samplesVoid[0], nsamps));
|
||||
return nsamps;
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ void tx_rf(RU_t *ru,
|
||||
int sf_extension = 0;
|
||||
|
||||
if ((SF_type == SF_DL) ||
|
||||
(SF_type == SF_S)) {
|
||||
(SF_type == SF_S) ) {
|
||||
int siglen=fp->samples_per_tti,flags=1;
|
||||
|
||||
if (SF_type == SF_S) {
|
||||
@@ -831,6 +831,23 @@ void tx_rf(RU_t *ru,
|
||||
late_control=STATE_BURST_TERMINATE;
|
||||
LOG_E(PHY,"TX : Timeout (sent %d/%d) state =%d\n",txs, siglen,late_control);
|
||||
}
|
||||
} else if (IS_SOFTMODEM_RFSIM ) {
|
||||
// in case of rfsim, we always enable tx because we need to feed rx of the opposite side
|
||||
// we write 1 single I/Q sample to trigger Rx (rfsim will fill gaps with 0 I/Q)
|
||||
void *dummy_tx[ru->frame_parms->nb_antennas_tx];
|
||||
for (int i=0; i<ru->frame_parms->nb_antennas_tx; i++)
|
||||
dummy_tx[i]=malloc16_clear(4);
|
||||
|
||||
AssertFatal( 1 ==
|
||||
ru->rfdevice.trx_write_func(&ru->rfdevice,
|
||||
timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension,
|
||||
dummy_tx,
|
||||
1,
|
||||
ru->frame_parms->nb_antennas_tx,
|
||||
4),"");
|
||||
|
||||
for (int i=0; i<ru->frame_parms->nb_antennas_tx; i++)
|
||||
free(dummy_tx[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
{"debug-ue-prach", CONFIG_HLP_DBGUEPR, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \
|
||||
{"no-L2-connect", CONFIG_HLP_NOL2CN, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \
|
||||
{"calib-prach-tx", CONFIG_HLP_CALPRACH, PARAMFLAG_BOOL, uptr:NULL, defuintval:1, TYPE_INT, 0}, \
|
||||
{"loop-memory", CONFIG_HLP_UELOOP, 0, strptr:&loopfile, defstrval:"iqs.in", TYPE_STRING,0}, \
|
||||
{"ue-dump-frame", CONFIG_HLP_DUMPFRAME, PARAMFLAG_BOOL, iptr:&dumpframe, defintval:0, TYPE_INT, 0}, \
|
||||
}
|
||||
#define CMDLINE_CALIBUERX_IDX 0
|
||||
|
||||
@@ -276,7 +276,6 @@ uint16_t node_number;
|
||||
static void get_options(void) {
|
||||
int CC_id=0;
|
||||
int tddflag=0;
|
||||
char *loopfile=NULL;
|
||||
int dumpframe=0;
|
||||
int timingadv=0;
|
||||
uint8_t nfapi_mode = NFAPI_MONOLITHIC;
|
||||
@@ -293,14 +292,6 @@ static void get_options(void) {
|
||||
config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL);
|
||||
nfapi_setmode(nfapi_mode);
|
||||
|
||||
|
||||
if (loopfile != NULL) {
|
||||
printf("Input file for hardware emulation: %s",loopfile);
|
||||
mode=loop_through_memory;
|
||||
input_fd = fopen(loopfile,"r");
|
||||
AssertFatal(input_fd != NULL,"Please provide a valid input file\n");
|
||||
}
|
||||
|
||||
get_softmodem_params()->hw_timing_advance = timingadv;
|
||||
|
||||
if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue;
|
||||
|
||||
Reference in New Issue
Block a user