Compare commits

...

2 Commits

Author SHA1 Message Date
Nitha Sagar Jayanna
0d7055da3d code clean up of merge differences 2021-02-14 13:47:46 +01:00
Nitha Sagar Jayanna
183b015847 project final update: semester project 2021-02-12 20:05:36 +01:00
2 changed files with 69 additions and 12 deletions

View File

@@ -200,14 +200,17 @@ void start_background_system(void) {
void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority){
pthread_attr_t attr;
pthread_attr_init(&attr);
/*
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
struct sched_param sparam={0};
sparam.sched_priority = priority;
pthread_attr_setschedparam(&attr, &sparam);
pthread_create(t, &attr, func, param);
*/
AssertFatal(pthread_create(t, &attr, func, param)==0, "Error creating thread");
pthread_create(t, &attr, func, param);
pthread_setname_np(*t, name);
if (affinity != -1 ) {

View File

@@ -422,15 +422,23 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp
int flags_msb = (flags>>8)&0xff;
int beam_enabled = (flags_msb>>3)&1;
int beam_id = flags_msb&7;
LOG_I(HW,"sending %d samples at time: %ld, beam_enabled %d, beam_id %d\n", nsamps, timestamp, beam_enabled, beam_id);
if(t->typeStamp == ENB_MAGICDL_FDD){
LOG_I(HW,"sending %d timestamp: %ld, beam_enabled %d, beam_id %d\n", nsamps, timestamp, beam_enabled, beam_id);
}
for (int i=0; i<FD_SETSIZE; i++) {
buffer_t *b=&t->buf[i];
if (b->conn_sock >= 0 ) {
samplesBlockHeader_t header= {t->typeStamp, nsamps, nbAnt, timestamp};
samplesBlockHeader_t header= {t->typeStamp, nsamps, nbAnt, timestamp, beam_id};
fullwrite(b->conn_sock,&header, sizeof(header), t);
// LOG_I(HW,"Hello,World %d \n",header.beam_id);
sample_t tmpSamples[nsamps][nbAnt];
for(int a=0; a<nbAnt; a++) {
@@ -472,7 +480,6 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
// store the data in lists
struct epoll_event events[FD_SETSIZE]= {{0}};
int nfds = epoll_wait(t->epollfd, events, FD_SETSIZE, timeout);
if ( nfds==-1 ) {
if ( errno==EINTR || errno==EAGAIN ) {
return false;
@@ -505,6 +512,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
}
buffer_t *b=&t->buf[fd];
//LOG_I(HW,"======= beam index ==========\n", b);
if ( b->circularBuf == NULL ) {
LOG_E(HW, "received data on not connected socket %d\n", events[nbEv].data.fd);
@@ -513,8 +522,20 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
ssize_t blockSz;
if ( b->headerMode)
if(t->typeStamp == ENB_MAGICDL_FDD){
LOG_I(HW,"Server side info: Beam index %d, path loss %lf\n", b->th.option_value, t->chan_pathloss);
}else {
LOG_I(HW,"Receiver side info: Beam index %d, path loss %lf\n", b->th.option_value,t->chan_pathloss);
}
//pathloss = beam_id*10
t->chan_pathloss = b->th.option_value * 10;
if ( b->headerMode){
blockSz=b->remainToTransfer;
//LOG_I(HW,"====== Timestamp %lu ===== Beam Index ====== %d , path loss %lf \n ", b->th.timestamp, b->th.option_value, t->chan_pathloss);
}
else
blockSz= b->transferPtr + b->remainToTransfer <= b->circularBufEnd ?
b->remainToTransfer :
@@ -552,7 +573,19 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
nsamps_for_initial;
LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp);
b->trashingPacket=true;
} else if ( b->lastReceivedTS < b->th.timestamp) {
}
else if ( b->lastReceivedTS < b->th.timestamp) {
int nbAnt= b->th.nbAnt;
if ( b->th.timestamp-b->lastReceivedTS < CirSize ) {
@@ -615,8 +648,20 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
if (nbAnt != 1) {
LOG_W(HW, "rfsimulator: only 1 antenna tested\n");
}
rfsimulator_state_t *t = device->priv;
for(int sock=0;sock<FD_SETSIZE;sock++){
buffer_t *b=&t->buf[sock];
//LOG_W(HW,"beam index %d",b->th.option_value);
}
//Printing the pathloss
if(t->typeStamp == UE_MAGICDL_FDD){
LOG_I(HW," RX side, pathLoss-defualt %lf\n", t->chan_pathloss);
}
LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps);
// deliver data from received data
// check if a UE is connected
@@ -645,7 +690,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
}
} else {
pthread_mutex_lock(&Sockmutex);
if ( t->nextTimestamp > 0 && t->lastWroteTS < t->nextTimestamp) {
pthread_mutex_unlock(&Sockmutex);
usleep(10000);
@@ -667,6 +712,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
LOG_I(HW, "No samples Tx occured, so we send 1 sample to notify it: Tx:%lu, Rx:%lu\n",
t->lastWroteTS, t->nextTimestamp);
//LOG_I(HW,"Testing Log");
rfsimulator_write_internal(t, t->nextTimestamp,
dummyS, 1,
t->tx_num_channels, 1, true);
@@ -708,6 +754,8 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
// Add all input nodes signal in the output buffer
for (int sock=0; sock<FD_SETSIZE; sock++) {
buffer_t *ptr=&t->buf[sock];
//LOG_I(HW,"Beam id %d\n", ptr->th.option_value);
if ( ptr->circularBuf ) {
bool reGenerateChannel=false;
@@ -716,23 +764,28 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
// it seems legacy behavior is: never in UL, each frame in DL
if (reGenerateChannel)
random_channel(ptr->channel_model,0);
if (t->poll_telnetcmdq)
t->poll_telnetcmdq(t->telnetcmd_qid,t);
for (int a=0; a<nbAnt; a++) {//loop over number of Rx antennas
if ( ptr->channel_model != NULL ) // apply a channel model
rxAddInput( ptr->circularBuf, (struct complex16 *) samplesVoid[a],
{
rxAddInput( ptr->circularBuf, (struct complex16 *) samplesVoid[a],
a,
ptr->channel_model,
nsamps,
t->nextTimestamp,
CirSize
);
else { // no channel modeling
buffer_t *b=&t->buf[a];
//ptr->channel_model->path_loss_dB=-132.24+10* b->th.option_value -RC.ru[0]->frame_parms->pdsch_config_common.referenceSignalPower;
//LOG_I(HW,"====== path loss in dB %f \n ", ptr->channel_model->path_loss_dB);
}
else { // no channel modeling
sample_t *out=(sample_t *)samplesVoid[a];
int nbAnt_tx = ptr->th.nbAnt;//number of Tx antennas
//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
@@ -752,6 +805,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
*ptimestamp, t->nextTimestamp,
signal_energy(samplesVoid[0], nsamps));
return nsamps;
}
int rfsimulator_request(openair0_device *device, void *msg, ssize_t msg_len) {
abort();