diff --git a/cuhd/include/cuhd.h b/cuhd/include/cuhd.h index 7e8b00d70..188f127c3 100644 --- a/cuhd/include/cuhd.h +++ b/cuhd/include/cuhd.h @@ -46,7 +46,6 @@ double cuhd_set_rx_gain(void *h, double gain); double cuhd_set_rx_freq(void *h, double freq); int cuhd_recv(void *h, void *data, int nsamples, int blocking); -int cuhd_start_tx_stream(void *h); double cuhd_set_tx_srate(void *h, double freq); double cuhd_set_tx_gain(void *h, double gain); double cuhd_set_tx_freq(void *h, double freq); diff --git a/cuhd/lib/cuhd_imp.cpp b/cuhd/lib/cuhd_imp.cpp index 0010bfefd..88e1ce27f 100644 --- a/cuhd/lib/cuhd_imp.cpp +++ b/cuhd/lib/cuhd_imp.cpp @@ -95,29 +95,23 @@ int cuhd_open(char *args, void **h) { cuhd_handler* handler = new cuhd_handler(); std::string _args=std::string(args); handler->usrp = uhd::usrp::multi_usrp::make(_args); - - //uhd::msg::register_handler(&my_handler); + handler->usrp->set_clock_source("internal"); std::string otw, cpu; otw="sc16"; cpu="fc32"; - - handler->usrp->set_clock_source("internal"); - uhd::stream_args_t stream_args(cpu, otw); -// stream_args.channels.push_back(0); -// stream_args.args["noclear"] = "1"; - handler->rx_stream = handler->usrp->get_rx_stream(stream_args); - *h = handler; - handler->tx_stream = handler->usrp->get_tx_stream(stream_args); + *h = handler; + return 0; } int cuhd_close(void *h) { - /** TODO */ + cuhd_stop_rx_stream(h); + /** Something else to close the USRP?? */ return 0; } @@ -160,17 +154,6 @@ int cuhd_recv(void *h, void *data, int nsamples, int blocking) { } } - - -int cuhd_start_tx_stream(void *h) { - cuhd_handler* handler = static_cast(h); - uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); - cmd.time_spec = handler->usrp->get_time_now(); - cmd.stream_now = true; - handler->usrp->issue_stream_cmd(cmd); - return 0; -} - double cuhd_set_tx_gain(void *h, double gain) { cuhd_handler* handler = static_cast(h); handler->usrp->set_tx_gain(gain); diff --git a/examples/enodeb_bch.c b/examples/enodeb_bch.c index 133bfe568..4250ae8a5 100644 --- a/examples/enodeb_bch.c +++ b/examples/enodeb_bch.c @@ -233,7 +233,6 @@ int main(int argc, char **argv) { printf("Set TX rate: %.2f MHz\n", cuhd_set_tx_srate(uhd, UHD_SAMP_FREQ)/1000000); printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain)); printf("Set TX freq: %.2f MHz\n", cuhd_set_tx_freq(uhd, uhd_freq)/1000000); - cuhd_start_tx_stream(uhd); } #endif diff --git a/examples/mib_track.c b/examples/mib_track.c index 29d31d422..4506ec893 100644 --- a/examples/mib_track.c +++ b/examples/mib_track.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "lte.h" @@ -62,6 +63,8 @@ int track_len=300; char *input_file_name = NULL; int disable_plots = 0; +int go_exit=0; + float uhd_freq = 2400000000.0, uhd_gain = 20.0; char *uhd_args = ""; @@ -238,10 +241,14 @@ void base_free() { filesource_free(&fsrc); } else { #ifndef DISABLE_UHD - cuhd_close(&uhd); + cuhd_close(uhd); #endif } +#ifndef DISABLE_GRAPHICS + plot_exit(); +#endif + sync_free(&sfind); sync_free(&strack); lte_fft_free(&fft); @@ -302,6 +309,10 @@ int mib_decoder_run(cf_t *input, pbch_mib_t *mib) { return n; } +void sigintHandler(int sig_num) +{ + go_exit=1; +} int main(int argc, char **argv) { int frame_cnt; @@ -346,6 +357,9 @@ int main(int argc, char **argv) { #endif } + printf("\n --- Press Ctrl+C to exit --- \n"); + signal(SIGINT, sigintHandler); + state = FIND; nslot = 0; find_idx = 0; @@ -356,7 +370,7 @@ int main(int argc, char **argv) { sync_set_threshold(&sfind, find_threshold); sync_force_N_id_2(&sfind, -1); - while(frame_cnt < nof_frames || nof_frames==-1) { + while(!go_exit && (frame_cnt < nof_frames || nof_frames==-1)) { INFO(" ----- RECEIVING %d SAMPLES ---- \n", FLEN); if (input_file_name) { n = filesource_read(&fsrc, input_buffer, FLEN); @@ -386,6 +400,7 @@ int main(int argc, char **argv) { sync_force_N_id_2(&strack, sync_get_N_id_2(&sfind)); cell_id = sync_get_cell_id(&sfind); mib_decoder_init(cell_id); + nof_found_mib = 0; nslot = sync_get_slot_id(&sfind); nslot=(nslot+10)%20; cfo = 0; @@ -393,7 +408,7 @@ int main(int argc, char **argv) { state = TRACK; } if (verbose == VERBOSE_NONE) { - printf("Tracking... PAR=%.2f\r", sync_get_peak_to_avg(&sfind)); + printf("Finding PSS... PAR=%.2f\r", sync_get_peak_to_avg(&sfind)); } break; case TRACK: @@ -408,13 +423,16 @@ int main(int argc, char **argv) { find_idx += track_idx - track_len; if (nslot != sync_get_slot_id(&strack)) { INFO("Expected slot %d but got %d\n", nslot, sync_get_slot_id(&strack)); - state = TRACK; + printf("\r\n");fflush(stdout); + state = FIND; } } - /* if we missed too many PSS go back to track */ + /* if we missed too many PSS go back to FIND */ if (frame_cnt - last_found > max_track_lost) { - INFO("%d frames lost. Going back to TRACK\n", frame_cnt - last_found); + INFO("%d frames lost. Going back to FIND", frame_cnt - last_found); + printf("\r\n");fflush(stdout); + state = FIND; } // Correct CFO @@ -454,7 +472,7 @@ int main(int argc, char **argv) { base_free(); - printf("\n\nDone\n"); + printf("\nBye\n"); exit(0); } diff --git a/graphics/lib/CMakeLists.txt b/graphics/lib/CMakeLists.txt index fc9b5b51d..65457ee23 100644 --- a/graphics/lib/CMakeLists.txt +++ b/graphics/lib/CMakeLists.txt @@ -100,8 +100,11 @@ ENDFOREACH(_module ${modules}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) +IF(QWT_MAJOR_VERSION LESS 6) + MESSAGE(STATUS "QWT6 is required.") +ENDIF(QWT_MAJOR_VERSION LESS 6) -IF(QT4_FOUND AND QWT_FOUND AND Boost_FOUND) +IF(QT4_FOUND AND QWT_FOUND AND Boost_FOUND AND QWT_MAJOR_VERSION EQUAL 6) QT4_WRAP_CPP(lineplotwraps common/Lineplot.h) QT4_WRAP_CPP(pointplotwraps common/Pointplot.h) QT4_WRAP_CPP(spectrogramplotwraps common/Spectrogramplot.h) @@ -128,11 +131,11 @@ IF(QT4_FOUND AND QWT_FOUND AND Boost_FOUND) MESSAGE(STATUS " GRAPHICS library will be installed.") -ELSE(QT4_FOUND AND QWT_FOUND AND Boost_FOUND) +ELSE(QT4_FOUND AND QWT_FOUND AND Boost_FOUND AND QWT_MAJOR_VERSION EQUAL 6) - MESSAGE(STATUS " QT4/Qwt or Boost not found. GRAPHICS library is not generated") + MESSAGE(STATUS " QT4/Qwt6 or Boost not found. GRAPHICS library is not generated") -ENDIF(QT4_FOUND AND QWT_FOUND AND Boost_FOUND) +ENDIF(QT4_FOUND AND QWT_FOUND AND Boost_FOUND AND QWT_MAJOR_VERSION EQUAL 6)