Commit b977734e authored by 111's avatar 111

ssb cap

parent 7587a72f
......@@ -2119,6 +2119,7 @@ add_executable(nr-uesoftmodem
${OPENAIR_DIR}/executables/nr-uesoftmodem.c
${OPENAIR_DIR}/executables/nr-ue.c
${OPENAIR_DIR}/executables/softmodem-common.c
${OPENAIR_DIR}/executables/cap-interface.c
${OPENAIR_DIR}/radio/COMMON/common_lib.c
${OPENAIR_DIR}/radio/COMMON/record_player.c
${OPENAIR2_DIR}/RRC/NAS/nas_config.c
......
9
\ No newline at end of file
/*
OpenXG RIC socket server
used to send PDSCH/PUSCH DMRS to client
*/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "cap-interface.h"
#include <semaphore.h>
sem_t ric_send_sem;
//uint8_t ric_test_data[]={0,1,2,3,4,5,6,7,8,9};
int ric_ssb_buf[RIC_SSB_LEN];
int g_output_period = 1;
/*
gcc -o ric_s ric-interface.c -DRIC_TEST_SERVER -pthread
*/
void *ric_interface_task(void *args_p)
{
int cnt = 0;
int outputdata = 1;
char c;
int log_cnt=0;
char filename[1024];
FILE *output_fd = NULL;
FILE *input_fd = NULL;
input_fd = fopen("output_period.txt","r");
if (input_fd==NULL){
printf("Error opening0 \n");
}
else
{
c = fgetc(input_fd);
if ((c - '0') > 0)
g_output_period = (c - '0') * 2;
fclose(input_fd);
}
sprintf(filename,"ssb_data_%d.am",0);
output_fd = fopen(filename,"w+");
fclose(output_fd);
printf("ssb output_period %d\n", g_output_period);
while(1)
{
sem_wait (&ric_send_sem);
//printf ("got ric_send_sem ric_send_buf_tmp addr %p ric_send_buf %p\n", ric_send_buf_tmp, ric_send_buf);
if (cnt % 4 == 0)
{
FILE *input_fd=NULL;
input_fd = fopen("output_flag.txt","r");
if (input_fd==NULL){
printf("Error opening0 \n");
}
else
{
c=fgetc(input_fd);
if ((outputdata == 0) && (c - '0' == 1))
{
log_cnt = 0;
}
outputdata = c - '0';
if(outputdata == 0)
printf("~~~~~~~~outputdata is %d, log_cnt %d", outputdata, log_cnt);
fclose(input_fd);
}
}
if (outputdata == 1)
{
sprintf(filename,"ssb_data_%d.am",0);
output_fd = fopen(filename,"a+");
if (output_fd==NULL){
printf("Error opening1 \n");
}
if (output_fd) {
printf("log ssb data, cnt %d\n", cnt);
fwrite(ric_ssb_buf,sizeof(int), RIC_SSB_LEN, output_fd);
fclose(output_fd);
}
}
cnt++;
}
}
#include <semaphore.h>
#define RIC_PBCH_LEN 240*4
#define RIC_PBCH_CH_LEN 240*4
#define RIC_SSB_LEN (RIC_PBCH_LEN+RIC_PBCH_CH_LEN)
extern int ric_ssb_buf[];
extern sem_t ric_send_sem;
extern int g_output_period;
extern void *ric_interface_task(void *args_p);
\ No newline at end of file
......@@ -87,6 +87,8 @@ unsigned short config_frames[4] = {2,9,11,13};
#include <openair1/PHY/MODULATION/nr_modulation.h>
#include "openair2/GNB_APP/gnb_paramdef.h"
#include "executables/cap-interface.h"
extern const char *duplex_mode[];
THREAD_STRUCT thread_struct;
nrUE_params_t nrUE_params;
......@@ -557,6 +559,14 @@ int main( int argc, char **argv ) {
init_NR_UE_threads(1);
printf("UE threads created by %ld\n", gettid());
sem_init(&ric_send_sem,0,0);
pthread_t ntid;
if (pthread_create(&ntid, NULL, ric_interface_task, NULL) < 0) {
fprintf(stderr, "ric_interface_task: Failed to create thread: %s\n",
strerror(errno));
exit(-1);
}
}
// wait for end of program
......
......@@ -52,7 +52,7 @@
#include "executables/nr-uesoftmodem.h"
#include "SCHED_NR_UE/pucch_uci_ue_nr.h"
#include <openair1/PHY/TOOLS/phy_scope_interface.h>
#include "executables/cap-interface.h"
//#define DEBUG_PHY_PROC
//#define NR_PDCCH_SCHED_DEBUG
//#define NR_PUCCH_SCHED
......@@ -856,6 +856,7 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue,
if (cfg->ssb_table.ssb_period == 0 ||
!(frame_rx%(1<<(cfg->ssb_table.ssb_period-1)))){
static int s_log_cnt = 0;
const int estimateSz = fp->symbols_per_slot * fp->ofdm_symbol_size;
// loop over SSB blocks
for(int ssb_index=0; ssb_index<fp->Lmax; ssb_index++) {
......@@ -875,6 +876,11 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue,
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz];
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][fp->ofdm_symbol_size];
nr_slot_fep(ue,
proc,
(ssb_start_symbol)%(fp->symbols_per_slot),
rxdataF);
for (int i=1; i<4; i++) {
nr_slot_fep(ue,
proc,
......@@ -919,6 +925,38 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue,
16384);
}
ue->apply_timing_offset = true;
if ((g_output_period!=0) && ((s_log_cnt%g_output_period)==0) )
{
int sc_start = (fp->first_carrier_offset + fp->ssb_start_subcarrier) % fp->ofdm_symbol_size;
int left_num, right_num;
if(sc_start + 240 > fp->ofdm_symbol_size)
{
left_num = fp->ofdm_symbol_size - sc_start;
right_num = 240 - left_num;
}
else{
left_num = 240;
right_num = 0;
}
for (int ii = 0; ii < 4; ii++)
{
memcpy(&ric_ssb_buf[240*ii], &rxdataF[0][(ssb_start_symbol+ii)%(fp->symbols_per_slot)*fp->ofdm_symbol_size + sc_start], left_num*4);
if (right_num > 0)
{
memcpy(&ric_ssb_buf[240*ii+left_num], &rxdataF[0][(ssb_start_symbol+ii)%(fp->symbols_per_slot)*fp->ofdm_symbol_size], right_num*4);
}
}
for (int ii = 1; ii < 4; ii++)
{
memcpy(&ric_ssb_buf[240*(4+ii-1)], &dl_ch_estimates[0][(ssb_start_symbol+ii)%(fp->symbols_per_slot)*fp->ofdm_symbol_size], 240*4);
}
sem_post(&ric_send_sem);
LOG_I(PHY, "frame %d %d, ssb_slot %d %d, ssb_index %d, ssb_start_symbol %d, ssb_sc_start %d , cell id %d cnt %d, rscp %d\n",
frame_rx, nr_slot_rx, ssb_slot, ssb_slot_2, ssb_index, ssb_start_symbol, sc_start, fp->Nid_cell, s_log_cnt, ue->measurements.ssb_rsrp_dBm[ssb_index]);
}
s_log_cnt++;
}
LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__);
nr_ue_rrc_measurements(ue, proc, rxdataF);
......
......@@ -76,7 +76,6 @@ void init_RA(module_id_t mod_id,
fapi_nr_config_request_t *cfg = &mac->phy_config.config_req;
prach_resources->RA_PREAMBLE_BACKOFF = 0;
//NR_SubcarrierSpacing_t prach_scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing;
NR_SubcarrierSpacing_t prach_scs = cfg->prach_config.prach_sub_c_spacing;
int n_prbs = get_N_RA_RB (prach_scs, mac->current_UL_BWP.scs);
int start_prb = rach_ConfigGeneric->msg1_FrequencyStart + mac->current_UL_BWP.BWPStart;
......@@ -175,7 +174,6 @@ int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_forma
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = mac->current_UL_BWP.rach_ConfigCommon;
fapi_nr_config_request_t *cfg = &mac->phy_config.config_req;
//NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing;
NR_SubcarrierSpacing_t scs = cfg->prach_config.prach_sub_c_spacing;
int prach_sequence_length = nr_rach_ConfigCommon->prach_RootSequenceIndex.present - 1;
uint8_t prachConfigIndex, mu;
......
......@@ -266,7 +266,9 @@ void nr_ue_decode_mib(module_id_t module_id, int cc_id)
ssb_subcarrier_offset = ssb_subcarrier_offset | 0x10;
}
#ifdef DEBUG_MIB
//#ifdef DEBUG_MIB
if ((mac->mib_frame %64) == 0)
{
uint8_t half_frame_bit = (extra_bits >> 4) & 0x1; // extra bits[4]
LOG_I(MAC,"system frame number(6 MSB bits): %d\n", mac->mib->systemFrameNumber.buf[0]);
LOG_I(MAC,"system frame number(with LSB): %d\n", (int) mac->mib_frame);
......@@ -279,7 +281,8 @@ void nr_ue_decode_mib(module_id_t module_id, int cc_id)
LOG_I(MAC,"intra frequency reselection (0=allowed,1=notAllowed): %d\n", (int)mac->mib->intraFreqReselection);
LOG_I(MAC,"half frame bit(extra bits): %d\n", (int)half_frame_bit);
LOG_I(MAC,"ssb index(extra bits): %d\n", (int)mac->mib_ssb);
#endif
}
//#endif
mac->ssb_subcarrier_offset = ssb_subcarrier_offset;
mac->dmrs_TypeA_Position = mac->mib->dmrs_TypeA_Position;
......
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