Commit 6835ac82 authored by Raphael Defosseux's avatar Raphael Defosseux

RFSIMULATOR: final integration of Laurent Thomas's review feedback

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent c409da3b
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include "UTIL/MATH/oml.h" #include "UTIL/MATH/oml.h"
#include "common/utils/LOG/vcd_signal_dumper.h" #include "common/utils/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h" #include "UTIL/OPT/opt.h"
#include "lte-softmodem.h"
#include "common/config/config_userapi.h" #include "common/config/config_userapi.h"
#include "T.h" #include "T.h"
...@@ -1511,6 +1512,23 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) ...@@ -1511,6 +1512,23 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg)
* \param arg unused * \param arg unused
* \returns a pointer to an int. The storage is not on the heap and must not be freed. * \returns a pointer to an int. The storage is not on the heap and must not be freed.
*/ */
void write_dummy(PHY_VARS_UE *UE, openair0_timestamp timestamp) {
// we have to write to tell explicitly to the eNB, else it will wait for us forever
// we write the next subframe (always write in future of what we received)
//
struct complex16 v= {0};
void *samplesVoid[UE->frame_parms.nb_antennas_tx];
for ( int i=0; i < UE->frame_parms.nb_antennas_tx; i++)
samplesVoid[i]=(void *)&v;
AssertFatal(1 == UE->rfdevice.trx_write_func(&UE->rfdevice,
timestamp+2*UE->frame_parms.samples_per_tti,
samplesVoid,
1,
UE->frame_parms.nb_antennas_tx,
1),"");
}
void *UE_thread(void *arg) void *UE_thread(void *arg)
{ {
...@@ -1564,16 +1582,20 @@ void *UE_thread(void *arg) ...@@ -1564,16 +1582,20 @@ void *UE_thread(void *arg)
if (is_synchronized == 0) { if (is_synchronized == 0) {
if (instance_cnt_synch < 0) { // we can invoke the synch if (instance_cnt_synch < 0) { // we can invoke the synch
// grab 10 ms of signal and wakeup synch thread // grab 10 ms of signal and wakeup synch thread
if (UE->mode != loop_through_memory) {
for(int sf=0; sf<10; sf++) {
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&UE->common_vars.rxdata[i][0]; rxp[i] = (void *)&UE->common_vars.rxdata[i][UE->frame_parms.samples_per_tti*sf];
if (UE->mode != loop_through_memory) AssertFatal(UE->frame_parms.samples_per_tti == UE->rfdevice.trx_read_func(&UE->rfdevice,
AssertFatal( UE->frame_parms.samples_per_tti*10 ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
rxp, rxp,
UE->frame_parms.samples_per_tti*10, UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx), ""); UE->frame_parms.nb_antennas_rx), "");
if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp);
}
}
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), ""); AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
instance_cnt_synch = ++UE->proc.instance_cnt_synch; instance_cnt_synch = ++UE->proc.instance_cnt_synch;
...@@ -1591,21 +1613,22 @@ void *UE_thread(void *arg) ...@@ -1591,21 +1613,22 @@ void *UE_thread(void *arg)
(void)dummy_rx; /* avoid gcc warnings */ (void)dummy_rx; /* avoid gcc warnings */
usleep(500); usleep(500);
#else #else
// grab 10 ms of signal into dummy buffer // grab 10 ms of signal into dummy buffer
if (UE->mode != loop_through_memory) { if (UE->mode != loop_through_memory) {
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++) for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
rxp[i] = (void *)&dummy_rx[i][0]; rxp[i] = (void *)&dummy_rx[i][0];
for (int sf=0; sf<10; sf++) for (int sf=0; sf<10; sf++) {
// printf("Reading dummy sf %d\n",sf); // printf("Reading dummy sf %d\n",sf);
UE->rfdevice.trx_read_func(&UE->rfdevice, UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
rxp, rxp,
UE->frame_parms.samples_per_tti, UE->frame_parms.samples_per_tti,
UE->frame_parms.nb_antennas_rx); UE->frame_parms.nb_antennas_rx);
if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp);
}
} }
#endif #endif
} }
} // UE->is_synchronized==0 } // UE->is_synchronized==0
...@@ -1616,12 +1639,17 @@ void *UE_thread(void *arg) ...@@ -1616,12 +1639,17 @@ void *UE_thread(void *arg)
if (UE->mode != loop_through_memory) { if (UE->mode != loop_through_memory) {
if (UE->no_timing_correction==0) { if (UE->no_timing_correction==0) {
LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode); LOG_I(PHY,"Resynchronizing RX by %d samples (mode = %d)\n",UE->rx_offset,UE->mode);
AssertFatal(UE->rx_offset == while ( UE->rx_offset ) {
UE->rfdevice.trx_read_func(&UE->rfdevice, size_t s=min(UE->rx_offset,UE->frame_parms.samples_per_tti);
AssertFatal(s == UE->rfdevice.trx_read_func(&UE->rfdevice,
&timestamp, &timestamp,
(void **)UE->common_vars.rxdata, (void **)UE->common_vars.rxdata,
UE->rx_offset, s,
UE->frame_parms.nb_antennas_rx),""); UE->frame_parms.nb_antennas_rx),"");
if (IS_SOFTMODEM_RFSIM )
write_dummy(UE, timestamp);
UE->rx_offset-=s;
}
} }
UE->rx_offset=0; UE->rx_offset=0;
...@@ -1662,6 +1690,7 @@ void *UE_thread(void *arg) ...@@ -1662,6 +1690,7 @@ void *UE_thread(void *arg)
pthread_mutex_unlock(&proc->mutex_rxtx); pthread_mutex_unlock(&proc->mutex_rxtx);
} }
usleep(300);
} }
LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]); LOG_D(PHY,"Process Subframe %d thread Idx %d \n", sub_frame, UE->current_thread_id[sub_frame]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment