Fixed examples not compiling

This commit is contained in:
ismagom 2015-03-19 17:38:52 +01:00
parent 49627c2919
commit a85a29afba
7 changed files with 32 additions and 46 deletions

View File

@ -45,4 +45,5 @@ ADD_CUSTOM_TARGET (add_srslte_headers SOURCES ${HEADERS_ALL})
# Add subdirectories
########################################################################
ADD_SUBDIRECTORY(lib)
ADD_SUBDIRECTORY(examples)

View File

@ -58,7 +58,7 @@ IF(${CUHD_FIND} EQUAL -1)
SET_TARGET_PROPERTIES(pdsch_ue PROPERTIES COMPILE_DEFINITIONS "DISABLE_UHD")
SET_TARGET_PROPERTIES(pdsch_enodeb PROPERTIES COMPILE_DEFINITIONS "DISABLE_UHD")
ELSE(${CUHD_FIND} EQUAL -1)
target_link_libraries(pdsch_ue cuhd)
target_link_libraries(pdsch_ue cuhd pthread)
target_link_libraries(pdsch_enodeb cuhd)
ENDIF(${CUHD_FIND} EQUAL -1)

View File

@ -36,7 +36,6 @@
#include <assert.h>
#include <signal.h>
#include "srslte/rrc/rrc.h"
#include "srslte/srslte.h"
#include "srslte/cuhd/cuhd.h"
#include "cuhd_utils.h"
@ -118,7 +117,7 @@ int parse_args(prog_args_t *args, int argc, char **argv) {
/**********************************************************************/
/* TODO: Do something with the output data */
uint8_t data[10000], data_unpacked[1000];
uint8_t data[10000];
int cuhd_recv_wrapper(void *h, void *data, uint32_t nsamples, srslte_timestamp_t *q) {
DEBUG(" ---- Receive %d samples ---- \n", nsamples);
@ -146,7 +145,7 @@ int main(int argc, char **argv) {
uint32_t nof_trials = 0;
uint32_t sfn = 0; // system frame number
int n;
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN];
uint8_t bch_payload[BCH_PAYLOAD_LEN];
uint32_t sfn_offset;
float rssi_utra=0,rssi=0, rsrp=0, rsrq=0, snr=0;
cf_t *ce[SRSLTE_MAX_PORTS];
@ -242,14 +241,13 @@ int main(int argc, char **argv) {
switch (state) {
case DECODE_MIB:
if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) {
decode_reset(&ue_mib.pbch);
n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset);
srslte_pbch_decode_reset(&ue_mib.pbch);
n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload, NULL, &sfn_offset);
if (n < 0) {
fprintf(stderr, "Error decoding UE MIB\n");
return -1;
} else if (n == SRSLTE_UE_MIB_FOUND) {
srslte_bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn);
} else if (n == SRSLTE_UE_MIB_FOUND) {
srslte_pbch_mib_unpack(bch_payload, &cell, &sfn);
printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset);
sfn = (sfn + sfn_offset)%1024;
state = DECODE_SIB;
@ -271,16 +269,9 @@ int main(int argc, char **argv) {
(float) ue_dl.nof_detected/nof_trials);
nof_trials++;
} else {
srslte_bit_unpack_vector(data, data_unpacked, n);
void *dlsch_msg = bcch_dlsch_unpack(data_unpacked, n);
if (dlsch_msg) {
printf("\n");fflush(stdout);
cell_access_info_t cell_info;
bcch_dlsch_sib1_get_cell_access_info(dlsch_msg, &cell_info);
printf("Decoded SIB1. Cell ID: 0x%x\n", cell_info.cell_id);
bcch_dlsch_fprint(dlsch_msg, stdout);
state = MEASURE;
}
printf("Decoded SIB1. Payload: ");
srslte_vec_fprint_hex(stdout, data, n);;
state = MEASURE;
}
}
break;

View File

@ -36,7 +36,6 @@
#include <unistd.h>
#include "srslte/srslte.h"
#include "srslte/rrc/rrc.h"
#include "cuhd_utils.h"
@ -54,7 +53,7 @@ int cuhd_recv_wrapper_cs(void *h, void *data, uint32_t nsamples, srslte_timestam
int cuhd_mib_decoder(void *uhd, uint32_t max_nof_frames, srslte_cell_t *cell) {
int ret = SRSLTE_ERROR;
srslte_ue_mib_sync_t ue_mib;
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN];
uint8_t bch_payload[BCH_PAYLOAD_LEN];
if (srslte_ue_mib_sync_init(&ue_mib, cell->id, cell->cp, cuhd_recv_wrapper_cs, uhd)) {
fprintf(stderr, "Error initiating srslte_ue_mib_sync\n");
@ -75,8 +74,7 @@ int cuhd_mib_decoder(void *uhd, uint32_t max_nof_frames, srslte_cell_t *cell) {
goto clean_exit;
}
if (ret == 1) {
srslte_bit_unpack_vector(bch_payload, bch_payload_unpacked, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload_unpacked, BCH_PAYLOAD_LEN, cell, NULL);
srslte_pbch_mib_unpack(bch_payload, cell, NULL);
}
clean_exit:

View File

@ -35,7 +35,6 @@
#include <semaphore.h>
#include "srslte/srslte.h"
#include "srslte/rrc/rrc.h"
#ifndef DISABLE_UHD
#include "srslte/cuhd/cuhd.h"
@ -246,7 +245,7 @@ void base_init() {
exit(-1);
}
if (srslte_pdsrslte_sch_init(&pdsch, cell)) {
if (srslte_pdsch_init(&pdsch, cell)) {
fprintf(stderr, "Error creating PDSCH object\n");
exit(-1);
}
@ -261,7 +260,7 @@ void base_init() {
void base_free() {
harq_free(&harq_process);
srslte_harq_free(&harq_process);
srslte_pdsch_free(&pdsch);
srslte_pdcch_free(&pdcch);
srslte_regs_free(&regs);
@ -442,7 +441,7 @@ int main(int argc, char **argv) {
cf_t pss_signal[SRSLTE_PSS_LEN];
float sss_signal0[SRSLTE_SSS_LEN]; // for subframe 0
float sss_signal5[SRSLTE_SSS_LEN]; // for subframe 5
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_packed[BCH_PAYLOAD_LEN/8];
uint8_t bch_payload[BCH_PAYLOAD_LEN];
int i;
cf_t *sf_symbols[SRSLTE_MAX_PORTS];
cf_t *slot1_symbols[SRSLTE_MAX_PORTS];
@ -532,8 +531,7 @@ int main(int argc, char **argv) {
srslte_refsignal_cs_put_sf(cell, 0, est.csr_signal.pilots[0][sf_idx], sf_buffer);
bcch_bch_pack(&cell, sfn, bch_payload_packed, BCH_PAYLOAD_LEN/8);
srslte_bit_pack_vector(bch_payload_packed, bch_payload, BCH_PAYLOAD_LEN);
srslte_pbch_mib_pack(&cell, sfn, bch_payload);
if (sf_idx == 0) {
srslte_pbch_encode(&pbch, bch_payload, slot1_symbols);
}
@ -566,7 +564,7 @@ int main(int argc, char **argv) {
if (send_data) {
srslte_dci_msg_pack_pdsch(&ra_dl, &dci_msg, SRSLTE_DCI_FORMAT1, cell.nof_prb, false);
INFO("Putting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L);
if (encode(&pdcch, &dci_msg, locations[sf_idx][0], 1234, sf_symbols, sf_idx, cfi)) {
if (srslte_pdcch_encode(&pdcch, &dci_msg, locations[sf_idx][0], 1234, sf_symbols, sf_idx, cfi)) {
fprintf(stderr, "Error encoding DCI message\n");
exit(-1);
}

View File

@ -38,7 +38,6 @@
#include <pthread.h>
#include <semaphore.h>
#include "srslte/rrc/rrc.h"
#include "srslte/srslte.h"
@ -57,7 +56,7 @@ cell_search_cfg_t cell_detect_config = {
//#define STDOUT_COMPACT
#ifndef DISABLE_GRAPHICS
#include "srslte/graphics/plot.h"
#include "libsdrgui/libsdrgui.h"
void init_plots();
pthread_t plot_thread;
sem_t plot_sem;
@ -236,7 +235,7 @@ int main(int argc, char **argv) {
#endif
uint32_t nof_trials = 0;
int n;
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN];
uint8_t bch_payload[BCH_PAYLOAD_LEN];
uint32_t sfn_offset;
parse_args(&prog_args, argc, argv);
@ -371,14 +370,14 @@ int main(int argc, char **argv) {
switch (state) {
case DECODE_MIB:
if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) {
decode_reset(&ue_mib.pbch);
n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset);
srslte_pbch_decode_reset(&ue_mib.pbch);
n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload, NULL, &sfn_offset);
if (n < 0) {
fprintf(stderr, "Error decoding UE MIB\n");
exit(-1);
} else if (n == SRSLTE_UE_MIB_FOUND) {
srslte_bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn);
srslte_pbch_mib_unpack(bch_payload, &cell, &sfn);
srslte_pbch_mib_fprint(stdout, &cell, sfn, cell.id);
printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset);
sfn = (sfn + sfn_offset)%1024;
state = DECODE_PDSCH;
@ -575,7 +574,7 @@ void *plot_thread_run(void *arg) {
void init_plots() {
plot_init();
sdrgui_init();
//plot_waterfall_init(&poutfft, SRSLTE_NRE * ue_dl.cell.nof_prb, 1000);
//plot_waterfall_setTitle(&poutfft, "Output FFT - Magnitude");

View File

@ -38,7 +38,6 @@
#include <pthread.h>
#include <semaphore.h>
#include "srslte/rrc/rrc.h"
#include "srslte/srslte.h"
@ -296,7 +295,7 @@ int main(int argc, char **argv) {
srslte_ue_mib_t ue_mib;
void *uhd;
int n;
uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN];
uint8_t bch_payload[BCH_PAYLOAD_LEN];
uint32_t sfn_offset;
rar_msg_t rar_msg;
srslte_ra_pusch_t ra_pusch;
@ -470,14 +469,14 @@ int main(int argc, char **argv) {
switch (state) {
case DECODE_MIB:
if (srslte_ue_sync_get_sfidx(&ue_sync) == 0) {
decode_reset(&ue_mib.pbch);
n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload_unpacked, NULL, &sfn_offset);
srslte_pbch_decode_reset(&ue_mib.pbch);
n = srslte_ue_mib_decode(&ue_mib, sf_buffer, bch_payload, NULL, &sfn_offset);
if (n < 0) {
fprintf(stderr, "Error decoding UE MIB\n");
exit(-1);
} else if (n == SRSLTE_UE_MIB_FOUND) {
srslte_bit_unpack_vector(bch_payload_unpacked, bch_payload, BCH_PAYLOAD_LEN);
bcch_bch_unpack(bch_payload, BCH_PAYLOAD_LEN, &cell, &sfn);
} else if (n == SRSLTE_UE_MIB_FOUND) {
srslte_pbch_mib_unpack(bch_payload, &cell, &sfn);
srslte_pbch_mib_fprint(stdout, &cell, sfn, cell.id);
printf("Decoded MIB. SFN: %d, offset: %d\n", sfn, sfn_offset);
sfn = (sfn + sfn_offset)%1024;
state = SEND_PRACH;
@ -551,7 +550,7 @@ int main(int argc, char **argv) {
time_adv_sec = prog_args.ta_usec*1e-6;
}
#define N_TX 1
const uint32_t rv[N_TX]={0,2,3,1,0};
const uint32_t rv[N_TX]={0};
for (int i=0; i<N_TX;i++) {
ra_pusch.rv_idx = rv[i];
ul_sf_idx = (srslte_ue_sync_get_sfidx(&ue_sync)+6+i*8)%10;