Removed new lines in log macros in all example apps.

master
faluco 4 years ago committed by faluco
parent 77f905dc64
commit 6545df6681

@ -107,7 +107,7 @@ void parse_args(int argc, char** argv)
int srslte_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t) int srslte_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t)
{ {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ---- ", nsamples);
return srslte_rf_recv_with_time((srslte_rf_t*)h, data, nsamples, 1, NULL, NULL); return srslte_rf_recv_with_time((srslte_rf_t*)h, data, nsamples, 1, NULL, NULL);
} }
@ -143,7 +143,7 @@ int main(int argc, char** argv)
printf("Opening RF device...\n"); printf("Opening RF device...\n");
if (srslte_rf_open(&rf, rf_args)) { if (srslte_rf_open(&rf, rf_args)) {
ERROR("Error opening rf\n"); ERROR("Error opening rf");
exit(-1); exit(-1);
} }
if (!cell_detect_config.init_agc) { if (!cell_detect_config.init_agc) {
@ -151,7 +151,7 @@ int main(int argc, char** argv)
} else { } else {
printf("Starting AGC thread...\n"); printf("Starting AGC thread...\n");
if (srslte_rf_start_gain_thread(&rf, false)) { if (srslte_rf_start_gain_thread(&rf, false)) {
ERROR("Error opening rf\n"); ERROR("Error opening rf");
exit(-1); exit(-1);
} }
srslte_rf_set_rx_gain(&rf, 50); srslte_rf_set_rx_gain(&rf, 50);
@ -162,7 +162,7 @@ int main(int argc, char** argv)
nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN);
if (nof_freqs < 0) { if (nof_freqs < 0) {
ERROR("Error getting EARFCN list\n"); ERROR("Error getting EARFCN list");
exit(-1); exit(-1);
} }
@ -173,7 +173,7 @@ int main(int argc, char** argv)
signal(SIGINT, sig_int_handler); signal(SIGINT, sig_int_handler);
if (srslte_ue_cellsearch_init(&cs, cell_detect_config.max_frames_pss, srslte_rf_recv_wrapper, (void*)&rf)) { if (srslte_ue_cellsearch_init(&cs, cell_detect_config.max_frames_pss, srslte_rf_recv_wrapper, (void*)&rf)) {
ERROR("Error initiating UE cell detect\n"); ERROR("Error initiating UE cell detect");
exit(-1); exit(-1);
} }
@ -190,10 +190,9 @@ int main(int argc, char** argv)
} }
for (freq = 0; freq < nof_freqs && !go_exit; freq++) { for (freq = 0; freq < nof_freqs && !go_exit; freq++) {
/* set rf_freq */ /* set rf_freq */
srslte_rf_set_rx_freq(&rf, 0, (double)channels[freq].fd * MHZ); srslte_rf_set_rx_freq(&rf, 0, (double)channels[freq].fd * MHZ);
INFO("Set rf_freq to %.3f MHz\n", (double)channels[freq].fd * MHZ / 1000000); INFO("Set rf_freq to %.3f MHz", (double)channels[freq].fd * MHZ / 1000000);
printf( printf(
"[%3d/%d]: EARFCN %d Freq. %.2f MHz looking for PSS.\n", freq, nof_freqs, channels[freq].id, channels[freq].fd); "[%3d/%d]: EARFCN %d Freq. %.2f MHz looking for PSS.\n", freq, nof_freqs, channels[freq].id, channels[freq].fd);
@ -205,14 +204,14 @@ int main(int argc, char** argv)
bzero(found_cells, 3 * sizeof(srslte_ue_cellsearch_result_t)); bzero(found_cells, 3 * sizeof(srslte_ue_cellsearch_result_t));
INFO("Setting sampling frequency %.2f MHz for PSS search\n", SRSLTE_CS_SAMP_FREQ / 1000000); INFO("Setting sampling frequency %.2f MHz for PSS search", SRSLTE_CS_SAMP_FREQ / 1000000);
srslte_rf_set_rx_srate(&rf, SRSLTE_CS_SAMP_FREQ); srslte_rf_set_rx_srate(&rf, SRSLTE_CS_SAMP_FREQ);
INFO("Starting receiver...\n"); INFO("Starting receiver...");
srslte_rf_start_rx_stream(&rf, false); srslte_rf_start_rx_stream(&rf, false);
n = srslte_ue_cellsearch_scan(&cs, found_cells, NULL); n = srslte_ue_cellsearch_scan(&cs, found_cells, NULL);
if (n < 0) { if (n < 0) {
ERROR("Error searching cell\n"); ERROR("Error searching cell");
exit(-1); exit(-1);
} else if (n > 0) { } else if (n > 0) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -222,7 +221,7 @@ int main(int argc, char** argv)
cell.cp = found_cells[i].cp; cell.cp = found_cells[i].cp;
int ret = rf_mib_decoder(&rf, 1, &cell_detect_config, &cell, NULL); int ret = rf_mib_decoder(&rf, 1, &cell_detect_config, &cell, NULL);
if (ret < 0) { if (ret < 0) {
ERROR("Error decoding MIB\n"); ERROR("Error decoding MIB");
exit(-1); exit(-1);
} }
if (ret == SRSLTE_UE_MIB_FOUND) { if (ret == SRSLTE_UE_MIB_FOUND) {

@ -112,7 +112,7 @@ void parse_args(int argc, char** argv)
int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t)
{ {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ----", nsamples);
void* ptr[SRSLTE_MAX_PORTS]; void* ptr[SRSLTE_MAX_PORTS];
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
ptr[i] = data[i]; ptr[i] = data[i];
@ -184,7 +184,7 @@ int main(int argc, char** argv)
// set rf_freq // set rf_freq
double rf_freq = channels[freq].fd * MHZ + raster_offset[i]; double rf_freq = channels[freq].fd * MHZ + raster_offset[i];
srslte_rf_set_rx_freq(&rf, 0, rf_freq); srslte_rf_set_rx_freq(&rf, 0, rf_freq);
INFO("Set rf_freq to %.3f Hz\n", rf_freq); INFO("Set rf_freq to %.3f Hz", rf_freq);
printf("[%3d/%d]: EARFCN %d, %.2f MHz looking for NPSS.\n", freq, nof_freqs, channels[freq].id, rf_freq / 1e6); printf("[%3d/%d]: EARFCN %d, %.2f MHz looking for NPSS.\n", freq, nof_freqs, channels[freq].id, rf_freq / 1e6);
fflush(stdout); fflush(stdout);
@ -207,9 +207,9 @@ int main(int argc, char** argv)
srslte_ue_sync_nbiot_start_agc(&cs.ue_sync, srslte_rf_set_rx_gain_wrapper, cell_detect_config.init_agc); srslte_ue_sync_nbiot_start_agc(&cs.ue_sync, srslte_rf_set_rx_gain_wrapper, cell_detect_config.init_agc);
} }
INFO("Setting sampling frequency %.2f MHz for NPSS search\n", SRSLTE_CS_SAMP_FREQ / 1000000); INFO("Setting sampling frequency %.2f MHz for NPSS search", SRSLTE_CS_SAMP_FREQ / 1000000);
srslte_rf_set_rx_srate(&rf, SRSLTE_CS_SAMP_FREQ); srslte_rf_set_rx_srate(&rf, SRSLTE_CS_SAMP_FREQ);
INFO("Starting receiver...\n"); INFO("Starting receiver...");
srslte_rf_start_rx_stream(&rf, false); srslte_rf_start_rx_stream(&rf, false);
n = srslte_ue_cellsearch_nbiot_scan(&cs); n = srslte_ue_cellsearch_nbiot_scan(&cs);

@ -489,7 +489,6 @@ int main(int argc, char** argv)
signal(SIGINT, sig_int_handler); signal(SIGINT, sig_int_handler);
if (!output_file_name) { if (!output_file_name) {
int srate = srslte_sampling_freq_hz(cell.base.nof_prb); int srate = srslte_sampling_freq_hz(cell.base.nof_prb);
if (srate != -1) { if (srate != -1) {
printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000);
@ -555,7 +554,7 @@ int main(int argc, char** argv)
srslte_nsss_put_subframe(&nsss_sync, nsss_signal, sf_buffer, sfn, cell.base.nof_prb, cell.nbiot_prb); srslte_nsss_put_subframe(&nsss_sync, nsss_signal, sf_buffer, sfn, cell.base.nof_prb, cell.nbiot_prb);
} else { } else {
// NRS in all other subframes (using CSR signal intentionally) // NRS in all other subframes (using CSR signal intentionally)
// DEBUG("%d.%d: Putting %d NRS pilots\n", sfn, sf_idx, SRSLTE_REFSIGNAL_NUM_SF(1, cell.nof_ports)); // DEBUG("%d.%d: Putting %d NRS pilots", sfn, sf_idx, SRSLTE_REFSIGNAL_NUM_SF(1, cell.nof_ports));
srslte_refsignal_nrs_put_sf(cell, 0, ch_est.nrs_signal.pilots[0][sf_idx], sf_buffer); srslte_refsignal_nrs_put_sf(cell, 0, ch_est.nrs_signal.pilots[0][sf_idx], sf_buffer);
} }
@ -591,14 +590,13 @@ int main(int argc, char** argv)
} }
if (srslte_nbiot_ue_dl_is_sib1_sf(&ue_dl, sfn, sf_idx)) { if (srslte_nbiot_ue_dl_is_sib1_sf(&ue_dl, sfn, sf_idx)) {
INFO("%d.%d: Transmitting SIB1-NB.\n", sfn, sf_idx); INFO("%d.%d: Transmitting SIB1-NB.", sfn, sf_idx);
assert(send_data == false); assert(send_data == false);
// configure DL grant for SIB1-NB transmission // configure DL grant for SIB1-NB transmission
if (sib1_npdsch_cfg.sf_idx == 0) { if (sib1_npdsch_cfg.sf_idx == 0) {
srslte_ra_nbiot_dl_grant_t grant; srslte_ra_nbiot_dl_grant_t grant;
srslte_ra_nbiot_dl_dci_to_grant( srslte_ra_nbiot_dl_dci_to_grant(&ra_dl_sib1, &grant, sfn, sf_idx, DUMMY_R_MAX, true, cell.mode);
&ra_dl_sib1, &grant, sfn, sf_idx, DUMMY_R_MAX, true, cell.mode);
if (srslte_npdsch_cfg(&sib1_npdsch_cfg, cell, &grant, sf_idx)) { if (srslte_npdsch_cfg(&sib1_npdsch_cfg, cell, &grant, sf_idx)) {
fprintf(stderr, "Error configuring NPDSCH\n"); fprintf(stderr, "Error configuring NPDSCH\n");
exit(-1); exit(-1);
@ -626,7 +624,7 @@ int main(int argc, char** argv)
// always transmit NPDCCH on fixed positions if no transmission is going on // always transmit NPDCCH on fixed positions if no transmission is going on
if (sf_idx == NPDCCH_SF_IDX && !npdsch_active) { if (sf_idx == NPDCCH_SF_IDX && !npdsch_active) {
// Encode NPDCCH // Encode NPDCCH
INFO("Putting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L); INFO("Putting DCI to location: n=%d, L=%d", locations[sf_idx][0].ncce, locations[sf_idx][0].L);
srslte_dci_msg_pack_npdsch(&ra_dl, SRSLTE_DCI_FORMATN1, &dci_msg, false); srslte_dci_msg_pack_npdsch(&ra_dl, SRSLTE_DCI_FORMATN1, &dci_msg, false);
if (srslte_npdcch_encode(&npdcch, &dci_msg, locations[sf_idx][0], UE_CRNTI, sf_re_symbols, sf_idx)) { if (srslte_npdcch_encode(&npdcch, &dci_msg, locations[sf_idx][0], UE_CRNTI, sf_re_symbols, sf_idx)) {
fprintf(stderr, "Error encoding DCI message\n"); fprintf(stderr, "Error encoding DCI message\n");
@ -645,7 +643,7 @@ int main(int argc, char** argv)
// catch start of "user" NPDSCH // catch start of "user" NPDSCH
if (!npdsch_active && (sf_idx == npdsch_cfg.grant.start_sfidx && sfn == npdsch_cfg.grant.start_sfn)) { if (!npdsch_active && (sf_idx == npdsch_cfg.grant.start_sfidx && sfn == npdsch_cfg.grant.start_sfn)) {
// generate data only in first sf // generate data only in first sf
INFO("%d.%d: Generating %d random bits\n", sfn, sf_idx, npdsch_cfg.grant.mcs[0].tbs); INFO("%d.%d: Generating %d random bits", sfn, sf_idx, npdsch_cfg.grant.mcs[0].tbs);
for (int i = 0; i < npdsch_cfg.grant.mcs[0].tbs / 8; i++) { for (int i = 0; i < npdsch_cfg.grant.mcs[0].tbs / 8; i++) {
data[i] = srslte_random_uniform_int_dist(random_gen, 0, 255); data[i] = srslte_random_uniform_int_dist(random_gen, 0, 255);
} }
@ -657,7 +655,7 @@ int main(int argc, char** argv)
} }
if (npdsch_active) { if (npdsch_active) {
DEBUG("Current sf_idx=%d, Encoding npdsch.sf_idx=%d start=%d, nof=%d\n", DEBUG("Current sf_idx=%d, Encoding npdsch.sf_idx=%d start=%d, nof=%d",
sf_idx, sf_idx,
npdsch_cfg.sf_idx, npdsch_cfg.sf_idx,
npdsch_cfg.grant.start_sfidx, npdsch_cfg.grant.start_sfidx,
@ -668,7 +666,7 @@ int main(int argc, char** argv)
exit(-1); exit(-1);
} }
if (npdsch_cfg.num_sf == npdsch_cfg.grant.nof_sf * npdsch_cfg.grant.nof_rep) { if (npdsch_cfg.num_sf == npdsch_cfg.grant.nof_sf * npdsch_cfg.grant.nof_rep) {
INFO("Deactive current NPDSCH\n"); INFO("Deactive current NPDSCH");
npdsch_active = false; npdsch_active = false;
} }
} }

@ -274,7 +274,7 @@ void pcap_pack_and_write(FILE* pcap_file,
#ifndef DISABLE_RF #ifndef DISABLE_RF
int srslte_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t) int srslte_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t)
{ {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ----", nsamples);
return srslte_rf_recv_with_time(h, data, nsamples, true, &t->full_secs, &t->frac_secs); return srslte_rf_recv_with_time(h, data, nsamples, true, &t->full_secs, &t->frac_secs);
} }
@ -346,7 +346,6 @@ int main(int argc, char** argv)
#ifndef DISABLE_RF #ifndef DISABLE_RF
if (!prog_args.input_file_name) { if (!prog_args.input_file_name) {
printf("Opening RF device...\n"); printf("Opening RF device...\n");
if (srslte_rf_open_devname(&rf, prog_args.rf_dev, prog_args.rf_args, 1)) { if (srslte_rf_open_devname(&rf, prog_args.rf_dev, prog_args.rf_args, 1)) {
fprintf(stderr, "Error opening rf\n"); fprintf(stderr, "Error opening rf\n");
@ -511,9 +510,8 @@ int main(int argc, char** argv)
srslte_npbch_decode_reset(&ue_mib.npbch); srslte_npbch_decode_reset(&ue_mib.npbch);
INFO("\nEntering main loop...\n\n"); INFO("\nEntering main loop...");
while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) { while (!go_exit && (sf_cnt < prog_args.nof_subframes || prog_args.nof_subframes == -1)) {
ret = srslte_ue_sync_nbiot_zerocopy_multi(&ue_sync, buff_ptrs); ret = srslte_ue_sync_nbiot_zerocopy_multi(&ue_sync, buff_ptrs);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Error calling srslte_nbiot_ue_sync_zerocopy_multi()\n"); fprintf(stderr, "Error calling srslte_nbiot_ue_sync_zerocopy_multi()\n");
@ -542,7 +540,7 @@ int main(int argc, char** argv)
// update SFN and set deployment mode // update SFN and set deployment mode
system_frame_number = (mib.sfn + sfn_offset) % 1024; system_frame_number = (mib.sfn + sfn_offset) % 1024;
cell.mode = mib.mode; cell.mode = mib.mode;
// set number of ports of base cell to that of NB-IoT cell (FIXME: read eutra-NumCRS-Ports-r13) // set number of ports of base cell to that of NB-IoT cell (FIXME: read eutra-NumCRS-Ports-r13)
cell.base.nof_ports = cell.nof_ports; cell.base.nof_ports = cell.nof_ports;
@ -704,7 +702,7 @@ int main(int argc, char** argv)
srslte_ue_sync_nbiot_get_sfidx(&ue_sync), srslte_ue_sync_nbiot_get_sfidx(&ue_sync),
prog_args.rnti); prog_args.rnti);
if (n == SRSLTE_SUCCESS) { if (n == SRSLTE_SUCCESS) {
INFO("NPDSCH decoded ok.\n"); INFO("NPDSCH decoded ok.");
} }
} else { } else {
// decode NPDCCH // decode NPDCCH
@ -716,7 +714,7 @@ int main(int argc, char** argv)
prog_args.rnti, prog_args.rnti,
&dci_msg); &dci_msg);
if (n == SRSLTE_NBIOT_UE_DL_FOUND_DCI) { if (n == SRSLTE_NBIOT_UE_DL_FOUND_DCI) {
INFO("DCI found for rnti=%d\n", prog_args.rnti); INFO("DCI found for rnti=%d", prog_args.rnti);
// convert DCI to grant // convert DCI to grant
srslte_ra_nbiot_dl_dci_t dci_unpacked; srslte_ra_nbiot_dl_dci_t dci_unpacked;
srslte_ra_nbiot_dl_grant_t grant; srslte_ra_nbiot_dl_grant_t grant;
@ -907,9 +905,9 @@ float tmp_plot2[110 * 15 * 2048];
void* plot_thread_run(void* arg) void* plot_thread_run(void* arg)
{ {
uint32_t nof_re = SRSLTE_SF_LEN_RE(ue_dl.cell.base.nof_prb, ue_dl.cell.base.cp); uint32_t nof_re = SRSLTE_SF_LEN_RE(ue_dl.cell.base.nof_prb, ue_dl.cell.base.cp);
#if HAVE_RSRP_PLOT #if HAVE_RSRP_PLOT
float rsrp_lin = 0; float rsrp_lin = 0;
#endif #endif
sdrgui_init_title("Software Radio Systems NB-IoT Receiver"); sdrgui_init_title("Software Radio Systems NB-IoT Receiver");

@ -66,7 +66,7 @@ static int mbsfn_area_id = -1;
static char* rf_args = ""; static char* rf_args = "";
static char* rf_dev = ""; static char* rf_dev = "";
static float rf_amp = 0.8, rf_gain = 60.0, rf_freq = 2400000000; static float rf_amp = 0.8, rf_gain = 60.0, rf_freq = 2400000000;
static bool enable_256qam = false; static bool enable_256qam = false;
static float output_file_snr = +INFINITY; static float output_file_snr = +INFINITY;
static bool use_standard_lte_rate = false; static bool use_standard_lte_rate = false;
@ -142,7 +142,6 @@ static void parse_args(int argc, char** argv)
{ {
int opt; int opt;
while ((opt = getopt(argc, argv, "IadglfmoncpqvutxbwMsBQ")) != -1) { while ((opt = getopt(argc, argv, "IadglfmoncpqvutxbwMsBQ")) != -1) {
switch (opt) { switch (opt) {
case 'I': case 'I':
rf_dev = argv[optind]; rf_dev = argv[optind];
@ -232,7 +231,7 @@ static void base_init()
cell.nof_ports = 2; cell.nof_ports = 2;
break; break;
default: default:
ERROR("Transmission mode %d not implemented or invalid\n", transmission_mode); ERROR("Transmission mode %d not implemented or invalid", transmission_mode);
exit(-1); exit(-1);
} }
@ -269,7 +268,7 @@ static void base_init()
if (output_file_name) { if (output_file_name) {
if (strcmp(output_file_name, "NULL")) { if (strcmp(output_file_name, "NULL")) {
if (srslte_filesink_init(&fsink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { if (srslte_filesink_init(&fsink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) {
ERROR("Error opening file %s\n", output_file_name); ERROR("Error opening file %s", output_file_name);
exit(-1); exit(-1);
} }
null_file_sink = false; null_file_sink = false;
@ -291,12 +290,12 @@ static void base_init()
if (net_port > 0) { if (net_port > 0) {
if (srslte_netsource_init(&net_source, "127.0.0.1", net_port, SRSLTE_NETSOURCE_UDP)) { if (srslte_netsource_init(&net_source, "127.0.0.1", net_port, SRSLTE_NETSOURCE_UDP)) {
ERROR("Error creating input UDP socket at port %d\n", net_port); ERROR("Error creating input UDP socket at port %d", net_port);
exit(-1); exit(-1);
} }
if (null_file_sink) { if (null_file_sink) {
if (srslte_netsink_init(&net_sink, "127.0.0.1", net_port + 1, SRSLTE_NETSINK_TCP)) { if (srslte_netsink_init(&net_sink, "127.0.0.1", net_port + 1, SRSLTE_NETSINK_TCP)) {
ERROR("Error sink\n"); ERROR("Error sink");
exit(-1); exit(-1);
} }
} }
@ -309,7 +308,7 @@ static void base_init()
/* create ifft object */ /* create ifft object */
for (i = 0; i < cell.nof_ports; i++) { for (i = 0; i < cell.nof_ports; i++) {
if (srslte_ofdm_tx_init(&ifft[i], SRSLTE_CP_NORM, sf_buffer[i], output_buffer[i], cell.nof_prb)) { if (srslte_ofdm_tx_init(&ifft[i], SRSLTE_CP_NORM, sf_buffer[i], output_buffer[i], cell.nof_prb)) {
ERROR("Error creating iFFT object\n"); ERROR("Error creating iFFT object");
exit(-1); exit(-1);
} }
@ -317,49 +316,49 @@ static void base_init()
} }
if (srslte_ofdm_tx_init_mbsfn(&ifft_mbsfn, SRSLTE_CP_EXT, sf_buffer[0], output_buffer[0], cell.nof_prb)) { if (srslte_ofdm_tx_init_mbsfn(&ifft_mbsfn, SRSLTE_CP_EXT, sf_buffer[0], output_buffer[0], cell.nof_prb)) {
ERROR("Error creating iFFT object\n"); ERROR("Error creating iFFT object");
exit(-1); exit(-1);
} }
srslte_ofdm_set_non_mbsfn_region(&ifft_mbsfn, 2); srslte_ofdm_set_non_mbsfn_region(&ifft_mbsfn, 2);
srslte_ofdm_set_normalize(&ifft_mbsfn, true); srslte_ofdm_set_normalize(&ifft_mbsfn, true);
if (srslte_pbch_init(&pbch)) { if (srslte_pbch_init(&pbch)) {
ERROR("Error creating PBCH object\n"); ERROR("Error creating PBCH object");
exit(-1); exit(-1);
} }
if (srslte_pbch_set_cell(&pbch, cell)) { if (srslte_pbch_set_cell(&pbch, cell)) {
ERROR("Error creating PBCH object\n"); ERROR("Error creating PBCH object");
exit(-1); exit(-1);
} }
if (srslte_regs_init(&regs, cell)) { if (srslte_regs_init(&regs, cell)) {
ERROR("Error initiating regs\n"); ERROR("Error initiating regs");
exit(-1); exit(-1);
} }
if (srslte_pcfich_init(&pcfich, 1)) { if (srslte_pcfich_init(&pcfich, 1)) {
ERROR("Error creating PBCH object\n"); ERROR("Error creating PBCH object");
exit(-1); exit(-1);
} }
if (srslte_pcfich_set_cell(&pcfich, &regs, cell)) { if (srslte_pcfich_set_cell(&pcfich, &regs, cell)) {
ERROR("Error creating PBCH object\n"); ERROR("Error creating PBCH object");
exit(-1); exit(-1);
} }
if (srslte_pdcch_init_enb(&pdcch, cell.nof_prb)) { if (srslte_pdcch_init_enb(&pdcch, cell.nof_prb)) {
ERROR("Error creating PDCCH object\n"); ERROR("Error creating PDCCH object");
exit(-1); exit(-1);
} }
if (srslte_pdcch_set_cell(&pdcch, &regs, cell)) { if (srslte_pdcch_set_cell(&pdcch, &regs, cell)) {
ERROR("Error creating PDCCH object\n"); ERROR("Error creating PDCCH object");
exit(-1); exit(-1);
} }
if (srslte_pdsch_init_enb(&pdsch, cell.nof_prb)) { if (srslte_pdsch_init_enb(&pdsch, cell.nof_prb)) {
ERROR("Error creating PDSCH object\n"); ERROR("Error creating PDSCH object");
exit(-1); exit(-1);
} }
if (srslte_pdsch_set_cell(&pdsch, cell)) { if (srslte_pdsch_set_cell(&pdsch, cell)) {
ERROR("Error creating PDSCH object\n"); ERROR("Error creating PDSCH object");
exit(-1); exit(-1);
} }
@ -367,7 +366,7 @@ static void base_init()
if (mbsfn_area_id > -1) { if (mbsfn_area_id > -1) {
if (srslte_pmch_init(&pmch, cell.nof_prb, 1)) { if (srslte_pmch_init(&pmch, cell.nof_prb, 1)) {
ERROR("Error creating PMCH object\n"); ERROR("Error creating PMCH object");
} }
srslte_pmch_set_area_id(&pmch, mbsfn_area_id); srslte_pmch_set_area_id(&pmch, mbsfn_area_id);
} }
@ -375,12 +374,12 @@ static void base_init()
for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) {
softbuffers[i] = calloc(sizeof(srslte_softbuffer_tx_t), 1); softbuffers[i] = calloc(sizeof(srslte_softbuffer_tx_t), 1);
if (!softbuffers[i]) { if (!softbuffers[i]) {
ERROR("Error allocating soft buffer\n"); ERROR("Error allocating soft buffer");
exit(-1); exit(-1);
} }
if (srslte_softbuffer_tx_init(softbuffers[i], cell.nof_prb)) { if (srslte_softbuffer_tx_init(softbuffers[i], cell.nof_prb)) {
ERROR("Error initiating soft buffer\n"); ERROR("Error initiating soft buffer");
exit(-1); exit(-1);
} }
} }
@ -472,7 +471,6 @@ static uint32_t prbset_to_bitmask()
static int update_radl() static int update_radl()
{ {
ZERO_OBJECT(dci_dl); ZERO_OBJECT(dci_dl);
/* Configure cell and PDSCH in function of the transmission mode */ /* Configure cell and PDSCH in function of the transmission mode */
@ -666,7 +664,7 @@ static void* net_thread_fnc(void* arg)
1) / 1) /
8; 8;
rpm += n; rpm += n;
INFO("received %d bytes. rpm=%d/%d\n", n, rpm, nbytes); INFO("received %d bytes. rpm=%d/%d", n, rpm, nbytes);
wpm = 0; wpm = 0;
while (rpm >= nbytes) { while (rpm >= nbytes) {
// wait for packet to be transmitted // wait for packet to be transmitted
@ -677,19 +675,19 @@ static void* net_thread_fnc(void* arg)
memcpy(data[0], &data2[wpm], nbytes / (size_t)2); memcpy(data[0], &data2[wpm], nbytes / (size_t)2);
memcpy(data[1], &data2[wpm], nbytes / (size_t)2); memcpy(data[1], &data2[wpm], nbytes / (size_t)2);
} }
INFO("Sent %d/%d bytes ready\n", nbytes, rpm); INFO("Sent %d/%d bytes ready", nbytes, rpm);
rpm -= nbytes; rpm -= nbytes;
wpm += nbytes; wpm += nbytes;
net_packet_ready = true; net_packet_ready = true;
} }
if (wpm > 0) { if (wpm > 0) {
INFO("%d bytes left in buffer for next packet\n", rpm); INFO("%d bytes left in buffer for next packet", rpm);
memcpy(data2, &data2[wpm], rpm * sizeof(uint8_t)); memcpy(data2, &data2[wpm], rpm * sizeof(uint8_t));
} }
} else if (n == 0) { } else if (n == 0) {
rpm = 0; rpm = 0;
} else { } else {
ERROR("Error receiving from network\n"); ERROR("Error receiving from network");
exit(-1); exit(-1);
} }
} while (true); } while (true);
@ -748,22 +746,22 @@ int main(int argc, char** argv)
/* Generate reference signals */ /* Generate reference signals */
if (srslte_refsignal_cs_init(&csr_refs, cell.nof_prb)) { if (srslte_refsignal_cs_init(&csr_refs, cell.nof_prb)) {
ERROR("Error initializing equalizer\n"); ERROR("Error initializing equalizer");
exit(-1); exit(-1);
} }
if (mbsfn_area_id > -1) { if (mbsfn_area_id > -1) {
if (srslte_refsignal_mbsfn_init(&mbsfn_refs, cell.nof_prb)) { if (srslte_refsignal_mbsfn_init(&mbsfn_refs, cell.nof_prb)) {
ERROR("Error initializing equalizer\n"); ERROR("Error initializing equalizer");
exit(-1); exit(-1);
} }
if (srslte_refsignal_mbsfn_set_cell(&mbsfn_refs, cell, mbsfn_area_id)) { if (srslte_refsignal_mbsfn_set_cell(&mbsfn_refs, cell, mbsfn_area_id)) {
ERROR("Error initializing MBSFNR signal\n"); ERROR("Error initializing MBSFNR signal");
exit(-1); exit(-1);
} }
} }
if (srslte_refsignal_cs_set_cell(&csr_refs, cell)) { if (srslte_refsignal_cs_set_cell(&csr_refs, cell)) {
ERROR("Error setting cell\n"); ERROR("Error setting cell");
exit(-1); exit(-1);
} }
@ -780,17 +778,16 @@ int main(int argc, char** argv)
signal(SIGINT, sig_int_handler); signal(SIGINT, sig_int_handler);
if (!output_file_name) { if (!output_file_name) {
int srate = srslte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000);
float srate_rf = srslte_rf_set_tx_srate(&radio, (double)srate); float srate_rf = srslte_rf_set_tx_srate(&radio, (double)srate);
if (srate_rf != srate) { if (srate_rf != srate) {
ERROR("Could not set sampling rate\n"); ERROR("Could not set sampling rate");
exit(-1); exit(-1);
} }
} else { } else {
ERROR("Invalid number of PRB %d\n", cell.nof_prb); ERROR("Invalid number of PRB %d", cell.nof_prb);
exit(-1); exit(-1);
} }
srslte_rf_set_tx_gain(&radio, rf_gain); srslte_rf_set_tx_gain(&radio, rf_gain);
@ -876,17 +873,17 @@ int main(int argc, char** argv)
/* Update DL resource allocation from control port */ /* Update DL resource allocation from control port */
if (update_control()) { if (update_control()) {
ERROR("Error updating parameters from control port\n"); ERROR("Error updating parameters from control port");
} }
/* Transmit PDCCH + PDSCH only when there is data to send */ /* Transmit PDCCH + PDSCH only when there is data to send */
if ((net_port > 0) && (mch_table[sf_idx] == 1 && mbsfn_area_id > -1)) { if ((net_port > 0) && (mch_table[sf_idx] == 1 && mbsfn_area_id > -1)) {
send_data = net_packet_ready; send_data = net_packet_ready;
if (net_packet_ready) { if (net_packet_ready) {
INFO("Transmitting packet from port\n"); INFO("Transmitting packet from port");
} }
} else { } else {
INFO("SF: %d, Generating %d random bits\n", sf_idx, pdsch_cfg.grant.tb[0].tbs + pdsch_cfg.grant.tb[1].tbs); INFO("SF: %d, Generating %d random bits", sf_idx, pdsch_cfg.grant.tb[0].tbs + pdsch_cfg.grant.tb[1].tbs);
for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) {
if (pdsch_cfg.grant.tb[tb].enabled) { if (pdsch_cfg.grant.tb[tb].enabled) {
for (i = 0; i < pdsch_cfg.grant.tb[tb].tbs / 8; i++) { for (i = 0; i < pdsch_cfg.grant.tb[tb].tbs / 8; i++) {
@ -906,24 +903,24 @@ int main(int argc, char** argv)
dl_sf.sf_type = SRSLTE_SF_NORM; dl_sf.sf_type = SRSLTE_SF_NORM;
/* Encode PDCCH */ /* Encode PDCCH */
INFO("Putting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L); INFO("Putting DCI to location: n=%d, L=%d", locations[sf_idx][0].ncce, locations[sf_idx][0].L);
srslte_dci_msg_pack_pdsch(&cell, &dl_sf, NULL, &dci_dl, &dci_msg); srslte_dci_msg_pack_pdsch(&cell, &dl_sf, NULL, &dci_dl, &dci_msg);
dci_msg.location = locations[sf_idx][0]; dci_msg.location = locations[sf_idx][0];
if (srslte_pdcch_encode(&pdcch, &dl_sf, &dci_msg, sf_symbols)) { if (srslte_pdcch_encode(&pdcch, &dl_sf, &dci_msg, sf_symbols)) {
ERROR("Error encoding DCI message\n"); ERROR("Error encoding DCI message");
exit(-1); exit(-1);
} }
/* Configure pdsch_cfg parameters */ /* Configure pdsch_cfg parameters */
if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, transmission_mode, enable_256qam, &dci_dl, &pdsch_cfg.grant)) { if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, transmission_mode, enable_256qam, &dci_dl, &pdsch_cfg.grant)) {
ERROR("Error configuring PDSCH\n"); ERROR("Error configuring PDSCH");
exit(-1); exit(-1);
} }
/* Encode PDSCH */ /* Encode PDSCH */
if (srslte_pdsch_encode(&pdsch, &dl_sf, &pdsch_cfg, data, sf_symbols)) { if (srslte_pdsch_encode(&pdsch, &dl_sf, &pdsch_cfg, data, sf_symbols)) {
ERROR("Error encoding PDSCH\n"); ERROR("Error encoding PDSCH");
exit(-1); exit(-1);
} }
if (net_port > 0 && net_packet_ready) { if (net_port > 0 && net_packet_ready) {
@ -931,7 +928,7 @@ int main(int argc, char** argv)
for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) { for (uint32_t tb = 0; tb < SRSLTE_MAX_CODEWORDS; tb++) {
srslte_bit_pack_vector(data[tb], data_tmp, pdsch_cfg.grant.tb[tb].tbs); srslte_bit_pack_vector(data[tb], data_tmp, pdsch_cfg.grant.tb[tb].tbs);
if (srslte_netsink_write(&net_sink, data_tmp, 1 + (pdsch_cfg.grant.tb[tb].tbs - 1) / 8) < 0) { if (srslte_netsink_write(&net_sink, data_tmp, 1 + (pdsch_cfg.grant.tb[tb].tbs - 1) / 8) < 0) {
ERROR("Error sending data through UDP socket\n"); ERROR("Error sending data through UDP socket");
} }
} }
} }
@ -952,7 +949,7 @@ int main(int argc, char** argv)
/* Configure pdsch_cfg parameters */ /* Configure pdsch_cfg parameters */
if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, enable_256qam, &dci_dl, &pmch_cfg.pdsch_cfg.grant)) { if (srslte_ra_dl_dci_to_grant(&cell, &dl_sf, SRSLTE_TM1, enable_256qam, &dci_dl, &pmch_cfg.pdsch_cfg.grant)) {
ERROR("Error configuring PDSCH\n"); ERROR("Error configuring PDSCH");
exit(-1); exit(-1);
} }
@ -964,14 +961,14 @@ int main(int argc, char** argv)
/* Encode PMCH */ /* Encode PMCH */
if (srslte_pmch_encode(&pmch, &dl_sf, &pmch_cfg, data_mbms, sf_symbols)) { if (srslte_pmch_encode(&pmch, &dl_sf, &pmch_cfg, data_mbms, sf_symbols)) {
ERROR("Error encoding PDSCH\n"); ERROR("Error encoding PDSCH");
exit(-1); exit(-1);
} }
if (net_port > 0 && net_packet_ready) { if (net_port > 0 && net_packet_ready) {
if (null_file_sink) { if (null_file_sink) {
srslte_bit_pack_vector(data[0], data_tmp, pmch_cfg.pdsch_cfg.grant.tb[0].tbs); srslte_bit_pack_vector(data[0], data_tmp, pmch_cfg.pdsch_cfg.grant.tb[0].tbs);
if (srslte_netsink_write(&net_sink, data_tmp, 1 + (pmch_cfg.pdsch_cfg.grant.tb[0].tbs - 1) / 8) < 0) { if (srslte_netsink_write(&net_sink, data_tmp, 1 + (pmch_cfg.pdsch_cfg.grant.tb[0].tbs - 1) / 8) < 0) {
ERROR("Error sending data through UDP socket\n"); ERROR("Error sending data through UDP socket");
} }
} }
net_packet_ready = false; net_packet_ready = false;

@ -337,7 +337,7 @@ cf_t* sf_buffer[SRSLTE_MAX_PORTS] = {NULL};
int srslte_rf_recv_wrapper(void* h, cf_t* data_[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) int srslte_rf_recv_wrapper(void* h, cf_t* data_[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t)
{ {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ----", nsamples);
void* ptr[SRSLTE_MAX_PORTS]; void* ptr[SRSLTE_MAX_PORTS];
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
ptr[i] = data_[i]; ptr[i] = data_[i];
@ -415,7 +415,6 @@ int main(int argc, char** argv)
generate_mcch_table(mch_table, prog_args.mbsfn_sf_mask); generate_mcch_table(mch_table, prog_args.mbsfn_sf_mask);
} }
if (prog_args.cpu_affinity > -1) { if (prog_args.cpu_affinity > -1) {
cpu_set_t cpuset; cpu_set_t cpuset;
pthread_t thread; pthread_t thread;
@ -426,7 +425,7 @@ int main(int argc, char** argv)
CPU_SET((size_t)i, &cpuset); CPU_SET((size_t)i, &cpuset);
} }
if (pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset)) { if (pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset)) {
ERROR("Error setting main thread affinity to %d \n", prog_args.cpu_affinity); ERROR("Error setting main thread affinity to %d", prog_args.cpu_affinity);
exit(-1); exit(-1);
} }
} }
@ -434,7 +433,7 @@ int main(int argc, char** argv)
if (prog_args.net_port > 0) { if (prog_args.net_port > 0) {
if (srslte_netsink_init(&net_sink, prog_args.net_address, prog_args.net_port, SRSLTE_NETSINK_UDP)) { if (srslte_netsink_init(&net_sink, prog_args.net_address, prog_args.net_port, SRSLTE_NETSINK_UDP)) {
ERROR("Error initiating UDP socket to %s:%d\n", prog_args.net_address, prog_args.net_port); ERROR("Error initiating UDP socket to %s:%d", prog_args.net_address, prog_args.net_port);
exit(-1); exit(-1);
} }
srslte_netsink_set_nonblocking(&net_sink); srslte_netsink_set_nonblocking(&net_sink);
@ -442,7 +441,7 @@ int main(int argc, char** argv)
if (prog_args.net_port_signal > 0) { if (prog_args.net_port_signal > 0) {
if (srslte_netsink_init( if (srslte_netsink_init(
&net_sink_signal, prog_args.net_address_signal, prog_args.net_port_signal, SRSLTE_NETSINK_UDP)) { &net_sink_signal, prog_args.net_address_signal, prog_args.net_port_signal, SRSLTE_NETSINK_UDP)) {
ERROR("Error initiating UDP socket to %s:%d\n", prog_args.net_address_signal, prog_args.net_port_signal); ERROR("Error initiating UDP socket to %s:%d", prog_args.net_address_signal, prog_args.net_port_signal);
exit(-1); exit(-1);
} }
srslte_netsink_set_nonblocking(&net_sink_signal); srslte_netsink_set_nonblocking(&net_sink_signal);
@ -452,7 +451,6 @@ int main(int argc, char** argv)
#ifndef DISABLE_RF #ifndef DISABLE_RF
if (!prog_args.input_file_name) { if (!prog_args.input_file_name) {
printf("Opening RF device with %d RX antennas...\n", prog_args.rf_nof_rx_ant); printf("Opening RF device with %d RX antennas...\n", prog_args.rf_nof_rx_ant);
if (srslte_rf_open_devname(&rf, prog_args.rf_dev, prog_args.rf_args, prog_args.rf_nof_rx_ant)) { if (srslte_rf_open_devname(&rf, prog_args.rf_dev, prog_args.rf_args, prog_args.rf_nof_rx_ant)) {
fprintf(stderr, "Error opening rf\n"); fprintf(stderr, "Error opening rf\n");
@ -464,7 +462,7 @@ int main(int argc, char** argv)
} else { } else {
printf("Starting AGC thread...\n"); printf("Starting AGC thread...\n");
if (srslte_rf_start_gain_thread(&rf, false)) { if (srslte_rf_start_gain_thread(&rf, false)) {
ERROR("Error opening rf\n"); ERROR("Error opening rf");
exit(-1); exit(-1);
} }
srslte_rf_set_rx_gain(&rf, srslte_rf_get_rx_gain(&rf)); srslte_rf_set_rx_gain(&rf, srslte_rf_get_rx_gain(&rf));
@ -486,7 +484,7 @@ int main(int argc, char** argv)
ret = rf_search_and_decode_mib( ret = rf_search_and_decode_mib(
&rf, prog_args.rf_nof_rx_ant, &cell_detect_config, prog_args.force_N_id_2, &cell, &search_cell_cfo); &rf, prog_args.rf_nof_rx_ant, &cell_detect_config, prog_args.force_N_id_2, &cell, &search_cell_cfo);
if (ret < 0) { if (ret < 0) {
ERROR("Error searching for cell\n"); ERROR("Error searching for cell");
exit(-1); exit(-1);
} else if (ret == 0 && !go_exit) { } else if (ret == 0 && !go_exit) {
printf("Cell not found after %d trials. Trying again (Press Ctrl+C to exit)\n", ntrial++); printf("Cell not found after %d trials. Trying again (Press Ctrl+C to exit)\n", ntrial++);
@ -504,11 +502,11 @@ int main(int argc, char** argv)
printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000);
float srate_rf = srslte_rf_set_rx_srate(&rf, (double)srate); float srate_rf = srslte_rf_set_rx_srate(&rf, (double)srate);
if (srate_rf != srate) { if (srate_rf != srate) {
ERROR("Could not set sampling rate\n"); ERROR("Could not set sampling rate");
exit(-1); exit(-1);
} }
} else { } else {
ERROR("Invalid number of PRB %d\n", cell.nof_prb); ERROR("Invalid number of PRB %d", cell.nof_prb);
exit(-1); exit(-1);
} }
@ -532,7 +530,7 @@ int main(int argc, char** argv)
prog_args.file_offset_time, prog_args.file_offset_time,
prog_args.file_offset_freq, prog_args.file_offset_freq,
prog_args.rf_nof_rx_ant)) { prog_args.rf_nof_rx_ant)) {
ERROR("Error initiating ue_sync\n"); ERROR("Error initiating ue_sync");
exit(-1); exit(-1);
} }
@ -553,11 +551,11 @@ int main(int argc, char** argv)
prog_args.rf_nof_rx_ant, prog_args.rf_nof_rx_ant,
(void*)&rf, (void*)&rf,
decimate)) { decimate)) {
ERROR("Error initiating ue_sync\n"); ERROR("Error initiating ue_sync");
exit(-1); exit(-1);
} }
if (srslte_ue_sync_set_cell(&ue_sync, cell)) { if (srslte_ue_sync_set_cell(&ue_sync, cell)) {
ERROR("Error initiating ue_sync\n"); ERROR("Error initiating ue_sync");
exit(-1); exit(-1);
} }
#endif #endif
@ -569,20 +567,20 @@ int main(int argc, char** argv)
} }
srslte_ue_mib_t ue_mib; srslte_ue_mib_t ue_mib;
if (srslte_ue_mib_init(&ue_mib, sf_buffer[0], cell.nof_prb)) { if (srslte_ue_mib_init(&ue_mib, sf_buffer[0], cell.nof_prb)) {
ERROR("Error initaiting UE MIB decoder\n"); ERROR("Error initaiting UE MIB decoder");
exit(-1); exit(-1);
} }
if (srslte_ue_mib_set_cell(&ue_mib, cell)) { if (srslte_ue_mib_set_cell(&ue_mib, cell)) {
ERROR("Error initaiting UE MIB decoder\n"); ERROR("Error initaiting UE MIB decoder");
exit(-1); exit(-1);
} }
if (srslte_ue_dl_init(&ue_dl, sf_buffer, cell.nof_prb, prog_args.rf_nof_rx_ant)) { if (srslte_ue_dl_init(&ue_dl, sf_buffer, cell.nof_prb, prog_args.rf_nof_rx_ant)) {
ERROR("Error initiating UE downlink processing module\n"); ERROR("Error initiating UE downlink processing module");
exit(-1); exit(-1);
} }
if (srslte_ue_dl_set_cell(&ue_dl, cell)) { if (srslte_ue_dl_set_cell(&ue_dl, cell)) {
ERROR("Error initiating UE downlink processing module\n"); ERROR("Error initiating UE downlink processing module");
exit(-1); exit(-1);
} }
@ -667,7 +665,7 @@ int main(int argc, char** argv)
srslte_pbch_decode_reset(&ue_mib.pbch); srslte_pbch_decode_reset(&ue_mib.pbch);
INFO("\nEntering main loop...\n\n"); INFO("\nEntering main loop...");
// Variables for measurements // Variables for measurements
uint32_t nframes = 0; uint32_t nframes = 0;
@ -715,7 +713,7 @@ int main(int argc, char** argv)
} }
ret = srslte_ue_sync_zerocopy(&ue_sync, buffers, max_num_samples); ret = srslte_ue_sync_zerocopy(&ue_sync, buffers, max_num_samples);
if (ret < 0) { if (ret < 0) {
ERROR("Error calling srslte_ue_sync_work()\n"); ERROR("Error calling srslte_ue_sync_work()");
} }
#ifdef CORRECT_SAMPLE_OFFSET #ifdef CORRECT_SAMPLE_OFFSET
@ -726,7 +724,6 @@ int main(int argc, char** argv)
/* srslte_ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */ /* srslte_ue_sync_get_buffer returns 1 if successfully read 1 aligned subframe */
if (ret == 1) { if (ret == 1) {
bool acks[SRSLTE_MAX_CODEWORDS] = {false}; bool acks[SRSLTE_MAX_CODEWORDS] = {false};
struct timeval t[3]; struct timeval t[3];
@ -739,7 +736,7 @@ int main(int argc, char** argv)
int sfn_offset; int sfn_offset;
n = srslte_ue_mib_decode(&ue_mib, bch_payload, NULL, &sfn_offset); n = srslte_ue_mib_decode(&ue_mib, bch_payload, NULL, &sfn_offset);
if (n < 0) { if (n < 0) {
ERROR("Error decoding UE MIB\n"); ERROR("Error decoding UE MIB");
exit(-1); exit(-1);
} else if (n == SRSLTE_UE_MIB_FOUND) { } else if (n == SRSLTE_UE_MIB_FOUND) {
srslte_pbch_mib_unpack(bch_payload, &cell, &sfn); srslte_pbch_mib_unpack(bch_payload, &cell, &sfn);
@ -824,7 +821,6 @@ int main(int argc, char** argv)
get_time_interval(t); get_time_interval(t);
if (n > 0) { if (n > 0) {
/* Send data if socket active */ /* Send data if socket active */
if (prog_args.net_port > 0) { if (prog_args.net_port > 0) {
if (sf_idx == 1) { if (sf_idx == 1) {
@ -1134,7 +1130,6 @@ void* plot_thread_run(void* arg)
void init_plots() void init_plots()
{ {
if (sem_init(&plot_sem, 0, 0)) { if (sem_init(&plot_sem, 0, 0)) {
perror("sem_init"); perror("sem_init");
exit(-1); exit(-1);

@ -201,7 +201,7 @@ void parse_args(prog_args_t* args, int argc, char** argv)
#ifndef DISABLE_RF #ifndef DISABLE_RF
int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t)
{ {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ----", nsamples);
void* ptr[SRSLTE_MAX_PORTS]; void* ptr[SRSLTE_MAX_PORTS];
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
ptr[i] = data[i]; ptr[i] = data[i];
@ -229,7 +229,7 @@ int main(int argc, char** argv)
srslte_sl_comm_resource_pool_t sl_comm_resource_pool; srslte_sl_comm_resource_pool_t sl_comm_resource_pool;
if (srslte_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell_sl) != SRSLTE_SUCCESS) { if (srslte_sl_comm_resource_pool_get_default_config(&sl_comm_resource_pool, cell_sl) != SRSLTE_SUCCESS) {
ERROR("Error initializing sl_comm_resource_pool\n"); ERROR("Error initializing sl_comm_resource_pool");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -245,7 +245,7 @@ int main(int argc, char** argv)
printf("Opening RF device...\n"); printf("Opening RF device...\n");
if (srslte_rf_open_multi(&radio, prog_args.rf_args, prog_args.nof_rx_antennas)) { if (srslte_rf_open_multi(&radio, prog_args.rf_args, prog_args.nof_rx_antennas)) {
ERROR("Error opening rf\n"); ERROR("Error opening rf");
exit(-1); exit(-1);
} }
@ -260,11 +260,11 @@ int main(int argc, char** argv)
printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000);
float srate_rf = srslte_rf_set_rx_srate(&radio, (double)srate); float srate_rf = srslte_rf_set_rx_srate(&radio, (double)srate);
if (srate_rf != srate) { if (srate_rf != srate) {
ERROR("Could not set sampling rate\n"); ERROR("Could not set sampling rate");
exit(-1); exit(-1);
} }
} else { } else {
ERROR("Invalid number of PRB %d\n", cell_sl.nof_prb); ERROR("Invalid number of PRB %d", cell_sl.nof_prb);
exit(-1); exit(-1);
} }
} }
@ -307,7 +307,7 @@ int main(int argc, char** argv)
ofdm_cfg.out_buffer = sf_buffer[0]; ofdm_cfg.out_buffer = sf_buffer[0];
if (srslte_ofdm_rx_init_cfg(&fft[i], &ofdm_cfg)) { if (srslte_ofdm_rx_init_cfg(&fft[i], &ofdm_cfg)) {
ERROR("Error initiating FFT\n"); ERROR("Error initiating FFT");
goto clean_exit; goto clean_exit;
} }
} }
@ -320,12 +320,12 @@ int main(int argc, char** argv)
// init PSCCH object // init PSCCH object
if (srslte_pscch_init(&pscch, SRSLTE_MAX_PRB) != SRSLTE_SUCCESS) { if (srslte_pscch_init(&pscch, SRSLTE_MAX_PRB) != SRSLTE_SUCCESS) {
ERROR("Error in PSCCH init\n"); ERROR("Error in PSCCH init");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pscch_set_cell(&pscch, cell_sl) != SRSLTE_SUCCESS) { if (srslte_pscch_set_cell(&pscch, cell_sl) != SRSLTE_SUCCESS) {
ERROR("Error in PSCCH set cell\n"); ERROR("Error in PSCCH set cell");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -333,19 +333,19 @@ int main(int argc, char** argv)
srslte_chest_sl_cfg_t pscch_chest_sl_cfg = {}; srslte_chest_sl_cfg_t pscch_chest_sl_cfg = {};
srslte_chest_sl_t pscch_chest = {}; srslte_chest_sl_t pscch_chest = {};
if (srslte_chest_sl_init(&pscch_chest, SRSLTE_SIDELINK_PSCCH, cell_sl, sl_comm_resource_pool) != SRSLTE_SUCCESS) { if (srslte_chest_sl_init(&pscch_chest, SRSLTE_SIDELINK_PSCCH, cell_sl, sl_comm_resource_pool) != SRSLTE_SUCCESS) {
ERROR("Error in chest PSCCH init\n"); ERROR("Error in chest PSCCH init");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
if (srslte_pssch_init(&pssch, cell_sl, sl_comm_resource_pool) != SRSLTE_SUCCESS) { if (srslte_pssch_init(&pssch, cell_sl, sl_comm_resource_pool) != SRSLTE_SUCCESS) {
ERROR("Error initializing PSSCH\n"); ERROR("Error initializing PSSCH");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
srslte_chest_sl_cfg_t pssch_chest_sl_cfg = {}; srslte_chest_sl_cfg_t pssch_chest_sl_cfg = {};
srslte_chest_sl_t pssch_chest = {}; srslte_chest_sl_t pssch_chest = {};
if (srslte_chest_sl_init(&pssch_chest, SRSLTE_SIDELINK_PSSCH, cell_sl, sl_comm_resource_pool) != SRSLTE_SUCCESS) { if (srslte_chest_sl_init(&pssch_chest, SRSLTE_SIDELINK_PSSCH, cell_sl, sl_comm_resource_pool) != SRSLTE_SUCCESS) {
ERROR("Error in chest PSSCH init\n"); ERROR("Error in chest PSSCH init");
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
@ -373,7 +373,7 @@ int main(int argc, char** argv)
} }
if (srslte_ue_sync_set_cell(&ue_sync, cell)) { if (srslte_ue_sync_set_cell(&ue_sync, cell)) {
ERROR("Error initiating ue_sync\n"); ERROR("Error initiating ue_sync");
exit(-1); exit(-1);
} }
@ -414,7 +414,7 @@ int main(int argc, char** argv)
// receive subframe from radio // receive subframe from radio
int ret = srslte_ue_sync_zerocopy(&ue_sync, rx_buffer, sf_len); int ret = srslte_ue_sync_zerocopy(&ue_sync, rx_buffer, sf_len);
if (ret < 0) { if (ret < 0) {
ERROR("Error calling srslte_ue_sync_work()\n"); ERROR("Error calling srslte_ue_sync_work()");
} }
// update SF index // update SF index
@ -429,7 +429,6 @@ int main(int argc, char** argv)
pscch_prb_start_idx = sub_channel_idx * sl_comm_resource_pool.size_sub_channel; pscch_prb_start_idx = sub_channel_idx * sl_comm_resource_pool.size_sub_channel;
for (uint32_t cyclic_shift = 0; cyclic_shift <= 9; cyclic_shift += 3) { for (uint32_t cyclic_shift = 0; cyclic_shift <= 9; cyclic_shift += 3) {
// PSCCH Channel estimation // PSCCH Channel estimation
pscch_chest_sl_cfg.cyclic_shift = cyclic_shift; pscch_chest_sl_cfg.cyclic_shift = cyclic_shift;
pscch_chest_sl_cfg.prb_start_idx = pscch_prb_start_idx; pscch_chest_sl_cfg.prb_start_idx = pscch_prb_start_idx;

@ -118,11 +118,11 @@ int main(int argc, char** argv)
fflush(stdout); fflush(stdout);
if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { if (srslte_filesource_init(&fsrc, input_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) {
ERROR("Error opening file %s\n", input_file_name); ERROR("Error opening file %s", input_file_name);
exit(-1); exit(-1);
} }
if (srslte_filesink_init(&fsink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) { if (srslte_filesink_init(&fsink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN)) {
ERROR("Error opening file %s\n", output_file_name); ERROR("Error opening file %s", output_file_name);
exit(-1); exit(-1);
} }
@ -143,7 +143,7 @@ int main(int argc, char** argv)
} }
if (srslte_cfo_init(&cfocorr, frame_length)) { if (srslte_cfo_init(&cfocorr, frame_length)) {
ERROR("Error initiating CFO\n"); ERROR("Error initiating CFO");
return -1; return -1;
} }
@ -154,19 +154,19 @@ int main(int argc, char** argv)
*/ */
for (N_id_2 = 0; N_id_2 < 3; N_id_2++) { for (N_id_2 = 0; N_id_2 < 3; N_id_2++) {
if (srslte_pss_init_fft(&pss[N_id_2], frame_length, symbol_sz)) { if (srslte_pss_init_fft(&pss[N_id_2], frame_length, symbol_sz)) {
ERROR("Error initializing PSS object\n"); ERROR("Error initializing PSS object");
exit(-1); exit(-1);
} }
if (srslte_pss_set_N_id_2(&pss[N_id_2], N_id_2)) { if (srslte_pss_set_N_id_2(&pss[N_id_2], N_id_2)) {
ERROR("Error initializing N_id_2\n"); ERROR("Error initializing N_id_2");
exit(-1); exit(-1);
} }
if (srslte_sss_init(&sss[N_id_2], symbol_sz)) { if (srslte_sss_init(&sss[N_id_2], symbol_sz)) {
ERROR("Error initializing SSS object\n"); ERROR("Error initializing SSS object");
exit(-1); exit(-1);
} }
if (srslte_sss_set_N_id_2(&sss[N_id_2], N_id_2)) { if (srslte_sss_set_N_id_2(&sss[N_id_2], N_id_2)) {
ERROR("Error initializing N_id_2\n"); ERROR("Error initializing N_id_2");
exit(-1); exit(-1);
} }
} }
@ -180,7 +180,6 @@ int main(int argc, char** argv)
/* read all file or nof_frames */ /* read all file or nof_frames */
frame_cnt = 0; frame_cnt = 0;
while (frame_length == srslte_filesource_read(&fsrc, input, frame_length) && frame_cnt < nof_frames) { while (frame_length == srslte_filesource_read(&fsrc, input, frame_length) && frame_cnt < nof_frames) {
gettimeofday(&tdata[1], NULL); gettimeofday(&tdata[1], NULL);
if (force_cfo != CFO_AUTO) { if (force_cfo != CFO_AUTO) {
srslte_cfo_correct(&cfocorr, input, input, force_cfo / 128); srslte_cfo_correct(&cfocorr, input, input, force_cfo / 128);
@ -206,7 +205,6 @@ int main(int argc, char** argv)
/* If peak detected */ /* If peak detected */
if (peak_value[N_id_2] > corr_peak_threshold) { if (peak_value[N_id_2] > corr_peak_threshold) {
sss_idx = peak_pos[N_id_2] - 2 * (symbol_sz + SRSLTE_CP_LEN(symbol_sz, SRSLTE_CP_NORM_LEN)); sss_idx = peak_pos[N_id_2] - 2 * (symbol_sz + SRSLTE_CP_LEN(symbol_sz, SRSLTE_CP_NORM_LEN));
if (sss_idx >= 0) { if (sss_idx >= 0) {
srslte_sss_m0m1_diff(&sss[N_id_2], &input[sss_idx], &m0, &m0_value, &m1, &m1_value); srslte_sss_m0m1_diff(&sss[N_id_2], &input[sss_idx], &m0, &m0_value, &m1, &m1_value);

@ -113,9 +113,9 @@ int main(int argc, char** argv)
srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN); srslte_filesink_init(&sink, output_file_name, SRSLTE_COMPLEX_FLOAT_BIN);
printf("Opening RF device...\n"); printf("Opening RF device...");
if (srslte_rf_open_multi(&rf, rf_args, nof_rx_antennas)) { if (srslte_rf_open_multi(&rf, rf_args, nof_rx_antennas)) {
ERROR("Error opening rf\n"); ERROR("Error opening rf");
exit(-1); exit(-1);
} }
@ -132,7 +132,7 @@ int main(int argc, char** argv)
if (srate != rf_rate) { if (srate != rf_rate) {
srate = srslte_rf_set_rx_srate(&rf, rf_rate); srate = srslte_rf_set_rx_srate(&rf, rf_rate);
if (srate != rf_rate) { if (srate != rf_rate) {
ERROR("Error setting samplign frequency %.2f MHz\n", rf_rate * 1e-6); ERROR("Error setting samplign frequency %.2f MHz", rf_rate * 1e-6);
exit(-1); exit(-1);
} }
} }
@ -143,7 +143,7 @@ int main(int argc, char** argv)
while ((sample_count < nof_samples || nof_samples == -1) && keep_running) { while ((sample_count < nof_samples || nof_samples == -1) && keep_running) {
n = srslte_rf_recv_with_time_multi(&rf, (void**)buffer, buflen, true, NULL, NULL); n = srslte_rf_recv_with_time_multi(&rf, (void**)buffer, buflen, true, NULL, NULL);
if (n < 0) { if (n < 0) {
ERROR("Error receiving samples\n"); ERROR("Error receiving samples");
exit(-1); exit(-1);
} }

@ -111,7 +111,7 @@ void parse_args(int argc, char** argv)
int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t) int srslte_rf_recv_wrapper(void* h, cf_t* data[SRSLTE_MAX_PORTS], uint32_t nsamples, srslte_timestamp_t* t)
{ {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ----", nsamples);
void* ptr[SRSLTE_MAX_PORTS]; void* ptr[SRSLTE_MAX_PORTS];
for (int i = 0; i < SRSLTE_MAX_PORTS; i++) { for (int i = 0; i < SRSLTE_MAX_PORTS; i++) {
ptr[i] = data[i]; ptr[i] = data[i];
@ -138,7 +138,7 @@ int main(int argc, char** argv)
printf("Opening RF device...\n"); printf("Opening RF device...\n");
if (srslte_rf_open_multi(&rf, rf_args, nof_rx_antennas)) { if (srslte_rf_open_multi(&rf, rf_args, nof_rx_antennas)) {
ERROR("Error opening rf\n"); ERROR("Error opening rf");
exit(-1); exit(-1);
} }
@ -160,11 +160,11 @@ int main(int argc, char** argv)
printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000); printf("Setting sampling rate %.2f MHz\n", (float)srate / 1000000);
float srate_rf = srslte_rf_set_rx_srate(&rf, (double)srate); float srate_rf = srslte_rf_set_rx_srate(&rf, (double)srate);
if (srate_rf != srate) { if (srate_rf != srate) {
ERROR("Could not set sampling rate\n"); ERROR("Could not set sampling rate");
exit(-1); exit(-1);
} }
} else { } else {
ERROR("Invalid number of PRB %d\n", nof_prb); ERROR("Invalid number of PRB %d", nof_prb);
exit(-1); exit(-1);
} }
srslte_rf_start_rx_stream(&rf, false); srslte_rf_start_rx_stream(&rf, false);
@ -180,7 +180,7 @@ int main(int argc, char** argv)
exit(-1); exit(-1);
} }
if (srslte_ue_sync_set_cell(&ue_sync, cell)) { if (srslte_ue_sync_set_cell(&ue_sync, cell)) {
ERROR("Error initiating ue_sync\n"); ERROR("Error initiating ue_sync");
exit(-1); exit(-1);
} }
@ -191,7 +191,7 @@ int main(int argc, char** argv)
while ((subframe_count < nof_subframes || nof_subframes == -1) && !stop_capture) { while ((subframe_count < nof_subframes || nof_subframes == -1) && !stop_capture) {
n = srslte_ue_sync_zerocopy(&ue_sync, buffer, max_num_samples); n = srslte_ue_sync_zerocopy(&ue_sync, buffer, max_num_samples);
if (n < 0) { if (n < 0) {
ERROR("Error receiving samples\n"); ERROR("Error receiving samples");
exit(-1); exit(-1);
} }
if (n == 1) { if (n == 1) {

@ -83,7 +83,7 @@ void parse_args(int argc, char** argv)
int srslte_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t) int srslte_rf_recv_wrapper(void* h, void* data, uint32_t nsamples, srslte_timestamp_t* t)
{ {
DEBUG(" ---- Receive %d samples ---- \n", nsamples); DEBUG(" ---- Receive %d samples ----", nsamples);
return srslte_rf_recv(h, data, nsamples, 1); return srslte_rf_recv(h, data, nsamples, 1);
} }

@ -76,7 +76,7 @@ void parse_args(int argc, char** argv)
case 'p': case 'p':
nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); nof_prb = (uint32_t)strtol(argv[optind], NULL, 10);
if (!srslte_nofprb_isvalid(nof_prb)) { if (!srslte_nofprb_isvalid(nof_prb)) {
ERROR("Invalid number of UL RB %d\n", nof_prb); ERROR("Invalid number of UL RB %d", nof_prb);
exit(-1); exit(-1);
} }
break; break;
@ -128,7 +128,7 @@ int main(int argc, char** argv)
srslte_rf_t rf; srslte_rf_t rf;
printf("Opening RF device...\n"); printf("Opening RF device...\n");
if (srslte_rf_open(&rf, rf_args)) { if (srslte_rf_open(&rf, rf_args)) {
ERROR("Error opening rf\n"); ERROR("Error opening rf");
exit(-1); exit(-1);
} }

@ -87,12 +87,12 @@ int main(int argc, char** argv)
// Initializes ZMQ // Initializes ZMQ
if (init_zmq()) { if (init_zmq()) {
ERROR("Initializing ZMQ\n"); ERROR("Initializing ZMQ");
exit(-1); exit(-1);
} }
if (init_radio(&buflen)) { if (init_radio(&buflen)) {
ERROR("Initializing Radio\n"); ERROR("Initializing Radio");
exit(-1); exit(-1);
} }
@ -111,7 +111,7 @@ int main(int argc, char** argv)
while (keep_running) { while (keep_running) {
n = rx_radio(buffer, buflen); n = rx_radio(buffer, buflen);
if (n < 0) { if (n < 0) {
ERROR("Error receiving samples\n"); ERROR("Error receiving samples");
exit(-1); exit(-1);
} }
if (srslte_verbose == SRSLTE_VERBOSE_INFO) { if (srslte_verbose == SRSLTE_VERBOSE_INFO) {
@ -157,7 +157,7 @@ static int init_radio(uint32_t* buffer_len)
// Uses srsLTE RF API to open a device, could use other code here // Uses srsLTE RF API to open a device, could use other code here
printf("Opening RF device...\n"); printf("Opening RF device...\n");
if (srslte_rf_open_multi(&radio, rf_args, nof_rx_antennas)) { if (srslte_rf_open_multi(&radio, rf_args, nof_rx_antennas)) {
ERROR("Error opening rf\n"); ERROR("Error opening rf");
return -1; return -1;
} }
srslte_rf_set_rx_gain(&radio, rf_gain); srslte_rf_set_rx_gain(&radio, rf_gain);
@ -167,7 +167,7 @@ static int init_radio(uint32_t* buffer_len)
printf("Set RX gain: %.2f dB\n", rf_gain); printf("Set RX gain: %.2f dB\n", rf_gain);
float srate = srslte_rf_set_rx_srate(&radio, rf_rate); float srate = srslte_rf_set_rx_srate(&radio, rf_rate);
if (srate != rf_rate) { if (srate != rf_rate) {
ERROR("Error setting samplign frequency %.2f MHz\n", rf_rate * 1e-6); ERROR("Error setting samplign frequency %.2f MHz", rf_rate * 1e-6);
return -1; return -1;
} }

Loading…
Cancel
Save