CMake chekcs for Qwt6. Fixed UHD close RX stream at exit

master
ismagom 11 years ago
parent e66fe3102c
commit 034b003a85

@ -46,7 +46,6 @@ double cuhd_set_rx_gain(void *h, double gain);
double cuhd_set_rx_freq(void *h, double freq); double cuhd_set_rx_freq(void *h, double freq);
int cuhd_recv(void *h, void *data, int nsamples, int blocking); 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_srate(void *h, double freq);
double cuhd_set_tx_gain(void *h, double gain); double cuhd_set_tx_gain(void *h, double gain);
double cuhd_set_tx_freq(void *h, double freq); double cuhd_set_tx_freq(void *h, double freq);

@ -95,29 +95,23 @@ int cuhd_open(char *args, void **h) {
cuhd_handler* handler = new cuhd_handler(); cuhd_handler* handler = new cuhd_handler();
std::string _args=std::string(args); std::string _args=std::string(args);
handler->usrp = uhd::usrp::multi_usrp::make(_args); handler->usrp = uhd::usrp::multi_usrp::make(_args);
handler->usrp->set_clock_source("internal");
//uhd::msg::register_handler(&my_handler);
std::string otw, cpu; std::string otw, cpu;
otw="sc16"; otw="sc16";
cpu="fc32"; cpu="fc32";
handler->usrp->set_clock_source("internal");
uhd::stream_args_t stream_args(cpu, otw); 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); handler->rx_stream = handler->usrp->get_rx_stream(stream_args);
*h = handler;
handler->tx_stream = handler->usrp->get_tx_stream(stream_args); handler->tx_stream = handler->usrp->get_tx_stream(stream_args);
*h = handler;
return 0; return 0;
} }
int cuhd_close(void *h) { int cuhd_close(void *h) {
/** TODO */ cuhd_stop_rx_stream(h);
/** Something else to close the USRP?? */
return 0; 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<cuhd_handler*>(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) { double cuhd_set_tx_gain(void *h, double gain) {
cuhd_handler* handler = static_cast<cuhd_handler*>(h); cuhd_handler* handler = static_cast<cuhd_handler*>(h);
handler->usrp->set_tx_gain(gain); handler->usrp->set_tx_gain(gain);

@ -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 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 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); printf("Set TX freq: %.2f MHz\n", cuhd_set_tx_freq(uhd, uhd_freq)/1000000);
cuhd_start_tx_stream(uhd);
} }
#endif #endif

@ -34,6 +34,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include <signal.h>
#include "lte.h" #include "lte.h"
@ -62,6 +63,8 @@ int track_len=300;
char *input_file_name = NULL; char *input_file_name = NULL;
int disable_plots = 0; int disable_plots = 0;
int go_exit=0;
float uhd_freq = 2400000000.0, uhd_gain = 20.0; float uhd_freq = 2400000000.0, uhd_gain = 20.0;
char *uhd_args = ""; char *uhd_args = "";
@ -238,10 +241,14 @@ void base_free() {
filesource_free(&fsrc); filesource_free(&fsrc);
} else { } else {
#ifndef DISABLE_UHD #ifndef DISABLE_UHD
cuhd_close(&uhd); cuhd_close(uhd);
#endif #endif
} }
#ifndef DISABLE_GRAPHICS
plot_exit();
#endif
sync_free(&sfind); sync_free(&sfind);
sync_free(&strack); sync_free(&strack);
lte_fft_free(&fft); lte_fft_free(&fft);
@ -302,6 +309,10 @@ int mib_decoder_run(cf_t *input, pbch_mib_t *mib) {
return n; return n;
} }
void sigintHandler(int sig_num)
{
go_exit=1;
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
int frame_cnt; int frame_cnt;
@ -346,6 +357,9 @@ int main(int argc, char **argv) {
#endif #endif
} }
printf("\n --- Press Ctrl+C to exit --- \n");
signal(SIGINT, sigintHandler);
state = FIND; state = FIND;
nslot = 0; nslot = 0;
find_idx = 0; find_idx = 0;
@ -356,7 +370,7 @@ int main(int argc, char **argv) {
sync_set_threshold(&sfind, find_threshold); sync_set_threshold(&sfind, find_threshold);
sync_force_N_id_2(&sfind, -1); 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); INFO(" ----- RECEIVING %d SAMPLES ---- \n", FLEN);
if (input_file_name) { if (input_file_name) {
n = filesource_read(&fsrc, input_buffer, FLEN); 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)); sync_force_N_id_2(&strack, sync_get_N_id_2(&sfind));
cell_id = sync_get_cell_id(&sfind); cell_id = sync_get_cell_id(&sfind);
mib_decoder_init(cell_id); mib_decoder_init(cell_id);
nof_found_mib = 0;
nslot = sync_get_slot_id(&sfind); nslot = sync_get_slot_id(&sfind);
nslot=(nslot+10)%20; nslot=(nslot+10)%20;
cfo = 0; cfo = 0;
@ -393,7 +408,7 @@ int main(int argc, char **argv) {
state = TRACK; state = TRACK;
} }
if (verbose == VERBOSE_NONE) { 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; break;
case TRACK: case TRACK:
@ -408,13 +423,16 @@ int main(int argc, char **argv) {
find_idx += track_idx - track_len; find_idx += track_idx - track_len;
if (nslot != sync_get_slot_id(&strack)) { if (nslot != sync_get_slot_id(&strack)) {
INFO("Expected slot %d but got %d\n", 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) { 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 // Correct CFO
@ -454,7 +472,7 @@ int main(int argc, char **argv) {
base_free(); base_free();
printf("\n\nDone\n"); printf("\nBye\n");
exit(0); exit(0);
} }

@ -100,8 +100,11 @@ ENDFOREACH(_module ${modules})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../) 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(lineplotwraps common/Lineplot.h)
QT4_WRAP_CPP(pointplotwraps common/Pointplot.h) QT4_WRAP_CPP(pointplotwraps common/Pointplot.h)
QT4_WRAP_CPP(spectrogramplotwraps common/Spectrogramplot.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.") 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)

Loading…
Cancel
Save