Commit 3169792e authored by Florian Kaltenberger's avatar Florian Kaltenberger

emos-raw now can store aggregated channels


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5146 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 842258c6
...@@ -154,8 +154,8 @@ int fs4_test=0; ...@@ -154,8 +154,8 @@ int fs4_test=0;
char UE_flag=0; char UE_flag=0;
u8 eNB_id=0,UE_id=0; u8 eNB_id=0,UE_id=0;
//u32 carrier_freq[4]= {1907600000,1907600000,1907600000,1907600000};
u32 carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0},{0,0,0,0}}; u32 carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{2605000000,2605000000,0,0},{0,0,0,0},{0,0,0,0}};
//u32 carrier_freq[MAX_CARDS][4] = {{2590000000,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
exmimo_bw_t bandwidth[MAX_CARDS] = {BW20,BW10,BW5,BW5}; exmimo_bw_t bandwidth[MAX_CARDS] = {BW20,BW10,BW5,BW5};
char *conf_config_file_name = NULL; char *conf_config_file_name = NULL;
...@@ -173,7 +173,7 @@ struct timing_info_t { ...@@ -173,7 +173,7 @@ struct timing_info_t {
extern s16* sync_corr_ue0; extern s16* sync_corr_ue0;
extern s16 prach_ifft[4][1024*2]; extern s16 prach_ifft[4][1024*2];
unsigned int frame;
int rx_input_level_dBm; int rx_input_level_dBm;
#ifdef XFORMS #ifdef XFORMS
extern int otg_enabled; extern int otg_enabled;
...@@ -321,8 +321,10 @@ void *scope_thread(void *arg) { ...@@ -321,8 +321,10 @@ void *scope_thread(void *arg) {
int dummy_tx_buffer[3840*4] __attribute__((aligned(16))); int dummy_tx_buffer[3840*4] __attribute__((aligned(16)));
#ifdef EMOS #ifdef EMOS
#define NO_ESTIMATES_DISK 20 //No. of estimates that are aquired before dumped to disk #define AQU_LENGTH_FRAMES 100 //Aquisition time in frames
int channel_buffer_size = SAMPLES_PER_SLOT*4; //one slot, 4 byte per sample #define AQU_PERIOD_FRAMES 200 //Repetition time of aquisition in frames
#define AQU_LENGTH_SLOTS (AQU_LENGTH_FRAMES*LTE_SLOTS_PER_FRAME) //Aquisition time in slots
#define AQU_PERIOD_SLOTS (AQU_PERIOD_FRAMES*LTE_SLOTS_PER_FRAME) //Repetition time of aquisition in slots
void* gps_thread (void *arg) void* gps_thread (void *arg)
{ {
...@@ -408,6 +410,10 @@ void *emos_thread (void *arg) ...@@ -408,6 +410,10 @@ void *emos_thread (void *arg)
struct sched_param sched_param; struct sched_param sched_param;
int ret; int ret;
int card, ant;
int channel_buffer_size=0; //in bytes
sched_param.sched_priority = sched_get_priority_max(SCHED_FIFO)-1; sched_param.sched_priority = sched_get_priority_max(SCHED_FIFO)-1;
sched_setscheduler(0, SCHED_FIFO,&sched_param); sched_setscheduler(0, SCHED_FIFO,&sched_param);
...@@ -417,15 +423,16 @@ void *emos_thread (void *arg) ...@@ -417,15 +423,16 @@ void *emos_thread (void *arg)
timer = time(NULL); timer = time(NULL);
now = localtime(&timer); now = localtime(&timer);
/* for (card=0; card<number_of_cards; card++)
if (UE_flag==0) for (ant=0; ant<4; ant++)
channel_buffer_size = sizeof(fifo_dump_emos_eNB); if (carrier_freq[card][ant] != 0) {
else printf("card %d, ant %d\n",card,ant);
channel_buffer_size = sizeof(fifo_dump_emos_UE); channel_buffer_size += SAMPLES_PER_SLOT/(1<<openair0_exmimo_pci[card].exmimo_config_ptr->framing.resampling_factor[ant]);
*/ }
channel_buffer_size *= 4; //4 bytes per sample
// allocate memory for NO_FRAMES_DISK channes estimations // allocate memory for NO_FRAMES_DISK channes estimations
fifo2file_buffer = malloc(NO_ESTIMATES_DISK*channel_buffer_size); fifo2file_buffer = malloc(AQU_LENGTH_SLOTS*channel_buffer_size);
fifo2file_ptr = fifo2file_buffer; fifo2file_ptr = fifo2file_buffer;
if (fifo2file_buffer == NULL) if (fifo2file_buffer == NULL)
...@@ -454,8 +461,8 @@ void *emos_thread (void *arg) ...@@ -454,8 +461,8 @@ void *emos_thread (void *arg)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
printf("[EMOS] starting dump, channel_buffer_size=%d ...\n",channel_buffer_size); printf("[EMOS] starting dump, channel_buffer_size=%d ...\n",channel_buffer_size);
while (!oai_exit) while (!oai_exit)
{ {
bytes = rtf_read_timed(fifo, fifo2file_ptr, channel_buffer_size,100); bytes = rtf_read_timed(fifo, fifo2file_ptr, channel_buffer_size,100);
...@@ -472,26 +479,28 @@ void *emos_thread (void *arg) ...@@ -472,26 +479,28 @@ void *emos_thread (void *arg)
counter ++; counter ++;
total_bytes += bytes; total_bytes += bytes;
if ((counter%NO_ESTIMATES_DISK)==0) if ((counter%AQU_LENGTH_SLOTS)==0)
{ {
//reset stuff //reset stuff
fifo2file_ptr = fifo2file_buffer; fifo2file_ptr = fifo2file_buffer;
//counter = 0; //counter = 0;
//flush buffer to disk //flush buffer to disk
if (fwrite(fifo2file_buffer, sizeof(char), NO_ESTIMATES_DISK*channel_buffer_size, dumpfile_id) != NO_ESTIMATES_DISK*channel_buffer_size) if (fwrite(fifo2file_buffer, sizeof(char), AQU_LENGTH_SLOTS*channel_buffer_size, dumpfile_id) != AQU_LENGTH_SLOTS*channel_buffer_size)
{ {
fprintf(stderr, "[EMOS] Error writing to dumpfile\n"); fprintf(stderr, "[EMOS] Error writing to dumpfile\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
else
} printf("[EMOS] Frame %d: wrote %d bytes to disk\n",frame,AQU_LENGTH_SLOTS*channel_buffer_size);
}
if ((counter%2000)==0) { if ((counter%AQU_LENGTH_SLOTS)==0) {
time(&starttime_tmp); time(&starttime_tmp);
localtime_r(&starttime_tmp,&starttime); localtime_r(&starttime_tmp,&starttime);
printf("[EMOS] %02d:%02d:%02d, frame %d, total bytes wrote %llu, bytes lost %d\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, counter/20, total_bytes,lost_bytes); printf("[EMOS] %02d:%02d:%02d, frame %d, total bytes wrote %llu, bytes lost %d\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, frame, total_bytes,lost_bytes);
printf("[EMOS] %02d:%02d:%02d, frame %d, rssi_lin %d, rssi_lin_avg %d, rssi_avg_dB %d, rx_gain %d, LNA %d\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, counter/20, rssi_lin, rssi_lin_avg, rssi_avg_dB, p_exmimo_config->rf.rx_gain[0][0], (p_exmimo_config->rf.rf_mode[0] & LNAGAINMASK) >> 14); printf("[EMOS] %02d:%02d:%02d, frame %d, rssi_lin %d, rssi_lin_avg %d, rssi_avg_dB %d, rx_gain %d, LNA %d\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, frame, rssi_lin, rssi_lin_avg, rssi_avg_dB, p_exmimo_config->rf.rx_gain[0][0], (p_exmimo_config->rf.rf_mode[0] & LNAGAINMASK) >> 14);
//printf("[EMOS] %02d:%02d:%02d, frame %d, GPS time %e, GPS mode %d, lat %e, lon %e, alt %e, speed %e\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, counter/20, dummy_gps_data.time, dummy_gps_data.mode, dummy_gps_data.latitude, dummy_gps_data.longitude, dummy_gps_data.altitude, dummy_gps_data.speed); //printf("[EMOS] %02d:%02d:%02d, frame %d, GPS time %e, GPS mode %d, lat %e, lon %e, alt %e, speed %e\n", starttime.tm_hour, starttime.tm_min, starttime.tm_sec, counter/20, dummy_gps_data.time, dummy_gps_data.mode, dummy_gps_data.latitude, dummy_gps_data.longitude, dummy_gps_data.altitude, dummy_gps_data.speed);
} }
} }
...@@ -511,8 +520,7 @@ static void *eNB_thread(void *arg) ...@@ -511,8 +520,7 @@ static void *eNB_thread(void *arg)
#ifdef RTAI #ifdef RTAI
RT_TASK *task; RT_TASK *task;
#endif #endif
unsigned char slot=0,last_slot, next_slot; unsigned char slot=0,last_slot, next_slot, hw_slot;
int hw_slot,frame=0;
unsigned int msg1; unsigned int msg1;
unsigned int aa,slot_offset, slot_offset_F; unsigned int aa,slot_offset, slot_offset_F;
int diff; int diff;
...@@ -521,10 +529,10 @@ static void *eNB_thread(void *arg) ...@@ -521,10 +529,10 @@ static void *eNB_thread(void *arg)
int mbox_target=0,mbox_current=0; int mbox_target=0,mbox_current=0;
int i,ret; int i,ret;
int tx_offset; int tx_offset;
int bytes; int bytes, bytes_tot, bytes_len;
long long int k1=1000; long long int k1=1000;
long long int k2=1024-k1; long long int k2=1024-k1;
int len,card = 0; int ant,len,card = 0;
#ifdef RTAI #ifdef RTAI
task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF); task = rt_task_init_schmod(nam2num("TASK0"), 0, 0, 0, SCHED_FIFO, 0xF);
...@@ -605,7 +613,7 @@ static void *eNB_thread(void *arg) ...@@ -605,7 +613,7 @@ static void *eNB_thread(void *arg)
last_slot+=20; last_slot+=20;
next_slot = (slot+3)%LTE_SLOTS_PER_FRAME; next_slot = (slot+3)%LTE_SLOTS_PER_FRAME;
if (frame>5) if (frame>AQU_LENGTH_FRAMES)
{ {
timing_info.time_last = timing_info.time_now; timing_info.time_last = timing_info.time_now;
timing_info.time_now = rt_get_time_ns(); timing_info.time_now = rt_get_time_ns();
...@@ -630,33 +638,38 @@ static void *eNB_thread(void *arg) ...@@ -630,33 +638,38 @@ static void *eNB_thread(void *arg)
rssi_avg_dB = dB_fixed(rssi_lin_avg); rssi_avg_dB = dB_fixed(rssi_lin_avg);
if (frame%100==0) { if (frame%100==0) {
gain_control_all(rssi_avg_dB,card); gain_control_all(rssi_avg_dB,card);
printf("AGC for card %d: rx_power_fil_dB=%d, rx_gain=%d, LNA=%d (1=Byp,2=Med,3=Max)\n",card,rssi_avg_dB,openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0],(openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0]&LNAGAINMASK)>>14); //printf("AGC for card %d: rx_power_fil_dB=%d, rx_gain=%d, LNA=%d (1=Byp,2=Med,3=Max)\n",card,rssi_avg_dB,openair0_exmimo_pci[card].exmimo_config_ptr->rf.rx_gain[0][0],(openair0_exmimo_pci[card].exmimo_config_ptr->rf.rf_mode[0]&LNAGAINMASK)>>14);
} }
} }
} }
#ifdef EMOS #ifdef EMOS
// save raw samples here // save raw samples here
/* if ((last_slot==0) && ((frame%AQU_PERIOD_FRAMES)==0)) {
bytes = rtf_put(CHANSOUNDER_FIFO_MINOR, &(((s32*) openair0_exmimo_pci[card].adc_head[0])[last_slot*SAMPLES_PER_SLOT]), channel_buffer_size/2); printf("[EMOS] Frame %d: start writing to FIFO\n",frame);
if (bytes!=channel_buffer_size/2) { bytes_tot=0;
lost_bytes += channel_buffer_size/2 - bytes;
LOG_W(PHY,"Frame %d, slot %d: Problem writing EMOS data to FIFO (bytes=%d, size=%d)\n",
frame, last_slot, bytes, channel_buffer_size/2);
}
*/
bytes = rtf_put(CHANSOUNDER_FIFO_MINOR, &(((s32*) openair0_exmimo_pci[card].adc_head[0])[last_slot*SAMPLES_PER_SLOT]), channel_buffer_size);
if (bytes!=channel_buffer_size) {
lost_bytes += channel_buffer_size - bytes;
LOG_W(PHY,"Frame %d, slot %d: Problem writing EMOS data to FIFO (bytes=%d, size=%d)\n",
frame, last_slot, bytes, channel_buffer_size);
} }
else {
if (frame%100==0) { if ((frame%AQU_PERIOD_FRAMES)<AQU_LENGTH_FRAMES) {
LOG_I(PHY,"Frame %d, slot %d: Writing %d bytes EMOS data to FIFO\n", for (card=0; card<number_of_cards; card++) {
frame, last_slot, bytes); for (ant=0; ant<4; ant++) {
if (carrier_freq[card][ant] != 0) {
len = SAMPLES_PER_SLOT/(1<<openair0_exmimo_pci[card].exmimo_config_ptr->framing.resampling_factor[ant]);
bytes_len = len*4;
bytes = rtf_put(CHANSOUNDER_FIFO_MINOR, &(((s32*) openair0_exmimo_pci[card].adc_head[ant])[last_slot*len]), bytes_len);
bytes_tot += bytes;
if (bytes!=bytes_len) {
lost_bytes += bytes_len - bytes;
LOG_W(PHY,"Frame %d, slot %d: Problem writing EMOS data to FIFO (bytes=%d, size=%d)\n",
frame, last_slot, bytes, bytes_len);
}
}
} }
} }
if ((last_slot==19) && ((frame%AQU_PERIOD_FRAMES)==99))
printf("[EMOS] Frame %d: sent %d bytes to FIFO\n",frame,bytes_tot);
}
#endif #endif
} }
...@@ -930,7 +943,7 @@ int main(int argc, char **argv) { ...@@ -930,7 +943,7 @@ int main(int argc, char **argv) {
#ifdef OPENAIR2 #ifdef OPENAIR2
g_log->log_component[PHY].level = LOG_INFO; g_log->log_component[PHY].level = LOG_INFO;
#else #else
g_log->log_component[PHY].level = LOG_INFO; g_log->log_component[PHY].level = LOG_DEBUG;
#endif #endif
g_log->log_component[PHY].flag = LOG_HIGH; g_log->log_component[PHY].flag = LOG_HIGH;
g_log->log_component[MAC].level = LOG_INFO; g_log->log_component[MAC].level = LOG_INFO;
......
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