diff --git a/lte/phy/examples/cell_search_utils.c b/lte/phy/examples/cell_search_utils.c index e511af237..0ba0d8393 100644 --- a/lte/phy/examples/cell_search_utils.c +++ b/lte/phy/examples/cell_search_utils.c @@ -214,7 +214,7 @@ int cell_search(void *uhd, int force_N_id_2, lte_cell_t *cell) { int ret; uint32_t nof_tx_ports; - uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_packed[BCH_PAYLOAD_LEN]; + uint8_t bch_payload[BCH_PAYLOAD_LEN], bch_payload_unpacked[BCH_PAYLOAD_LEN]; ue_celldetect_result_t found_cells[3]; bzero(found_cells, 3*sizeof(ue_celldetect_result_t)); @@ -256,9 +256,9 @@ int cell_search(void *uhd, int force_N_id_2, lte_cell_t *cell) cell->cp = found_cells[max_peak_cell].cp; cell->id = found_cells[max_peak_cell].cell_id; cell->nof_ports = nof_tx_ports; - - bit_pack_vector(bch_payload, bch_payload_packed, BCH_PAYLOAD_LEN); - bcch_bch_mib_unpack(bch_payload_packed, BCH_PAYLOAD_LEN, cell, NULL); + + bit_unpack_vector(bch_payload, bch_payload_unpacked, BCH_PAYLOAD_LEN); + bcch_bch_mib_unpack(bch_payload_unpacked, BCH_PAYLOAD_LEN, cell, NULL); /* set sampling frequency */ int srate = lte_sampling_freq_hz(cell->nof_prb); diff --git a/lte/phy/lib/phch/src/pbch.c b/lte/phy/lib/phch/src/pbch.c index 26f10a3b6..b2171b831 100644 --- a/lte/phy/lib/phch/src/pbch.c +++ b/lte/phy/lib/phch/src/pbch.c @@ -253,13 +253,13 @@ uint32_t pbch_crc_check(pbch_t *q, uint8_t *bits, uint32_t nof_ports) { int ret = crc_checksum(&q->crc, data, BCH_PAYLOADCRC_LEN); if (ret == 0) { uint32_t chkzeros=0; - for (int i=0;ipbch_rm_f[j]) || isinf(q->pbch_rm_f[j])) { - return 0; + return LIBLTE_ERROR; } } - + /* decode */ viterbi_decode_f(&q->decoder, q->pbch_rm_f, q->data, BCH_PAYLOADCRC_LEN); @@ -412,6 +412,7 @@ int pbch_decode(pbch_t *q, cf_t *slot1_symbols, cf_t *ce_slot1[MAX_PORTS], } if (bch_payload) { memcpy(bch_payload, q->data, sizeof(uint8_t) * BCH_PAYLOAD_LEN); + vec_fprint_hex(stdout, bch_payload, BCH_PAYLOAD_LEN); } } return ret; diff --git a/lte/phy/lib/phch/test/pbch_test.c b/lte/phy/lib/phch/test/pbch_test.c index 4f1a106b1..ffeece5a0 100644 --- a/lte/phy/lib/phch/test/pbch_test.c +++ b/lte/phy/lib/phch/test/pbch_test.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "liblte/phy/phy.h" @@ -109,6 +110,7 @@ int main(int argc, char **argv) { exit(-1); } + srand(time(NULL)); for (i=0;iname : ""); return LIBLTE_ERROR; - } else { - printf("Encoding ok\n"); - } + } asn_fprint(stdout, &asn_DEF_MasterInformationBlock, &req); return LIBLTE_SUCCESS; } @@ -106,13 +104,12 @@ int bcch_bch_mib_unpack(uint8_t *buffer, uint32_t msg_nof_bits, lte_cell_t *cell perror("calloc"); return LIBLTE_ERROR; } - asn_dec_rval_t n = uper_decode(opt_codec_ctx, &asn_DEF_MasterInformationBlock, (void**) &req, &buffer, msg_nof_bits/8,0,msg_nof_bits%8); + asn_dec_rval_t n = uper_decode(opt_codec_ctx, &asn_DEF_MasterInformationBlock, + (void**) &req, buffer, msg_nof_bits/8,0,msg_nof_bits%8); if (n.consumed == -1) { printf("Decoding failed.\n"); return LIBLTE_ERROR; - } else { - printf("Decoding ok\n"); - } + } asn_fprint(stdout, &asn_DEF_MasterInformationBlock, req); switch(req->dl_Bandwidth) {