diff --git a/CMakeLists.txt b/CMakeLists.txt index 31739ebf8..0ce43a359 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,9 +91,8 @@ IF(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0") ELSE(${CMAKE_BUILD_TYPE} STREQUAL "Debug") FIND_PACKAGE(SSE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") IF(HAVE_AVX) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE") ELSEIF(HAVE_SSE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -msse4.1 -DLV_HAVE_SSE") ENDIF(HAVE_AVX) diff --git a/srslte/examples/cell_search.c b/srslte/examples/cell_search.c index 27184d156..737663aeb 100644 --- a/srslte/examples/cell_search.c +++ b/srslte/examples/cell_search.c @@ -170,7 +170,7 @@ int main(int argc, char **argv) { cuhd_set_master_clock_rate(uhd, 30.72e6); // Supress UHD messages - cuhd_supress_stdout(); + cuhd_suppress_stdout(); nof_freqs = srslte_band_get_fd_band(band, channels, earfcn_start, earfcn_end, MAX_EARFCN); if (nof_freqs < 0) { diff --git a/srslte/include/srslte/cuhd/cuhd.h b/srslte/include/srslte/cuhd/cuhd.h index 82fc158fb..cc1a72cd9 100644 --- a/srslte/include/srslte/cuhd/cuhd.h +++ b/srslte/include/srslte/cuhd/cuhd.h @@ -35,6 +35,8 @@ extern "C" { #include "srslte/config.h" +typedef void (*cuhd_msg_handler_t)(const char*); + SRSLTE_API int cuhd_open(char *args, void **handler); @@ -83,7 +85,9 @@ SRSLTE_API double cuhd_get_rx_gain(void *h); SRSLTE_API double cuhd_get_tx_gain(void *h); -SRSLTE_API void cuhd_supress_stdout(); +SRSLTE_API void cuhd_suppress_stdout(); + +SRSLTE_API void cuhd_register_msg_handler(cuhd_msg_handler_t h); SRSLTE_API double cuhd_set_rx_freq(void *h, double freq); @@ -159,4 +163,4 @@ SRSLTE_API int cuhd_send_timed2(void *h, #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/srslte/lib/cuhd/src/cuhd_imp.cpp b/srslte/lib/cuhd/src/cuhd_imp.cpp index 1d3bfee2a..03797c71a 100644 --- a/srslte/lib/cuhd/src/cuhd_imp.cpp +++ b/srslte/lib/cuhd/src/cuhd_imp.cpp @@ -40,11 +40,19 @@ //#define HIDE_MESSAGES -void my_handler(uhd::msg::type_t type, const std::string & msg) +cuhd_msg_handler_t msg_handler; + +void suppress_handler(uhd::msg::type_t type, const std::string & msg) { //handle the message... } +void translate_handler(uhd::msg::type_t type, const std::string & msg) +{ + if(msg_handler) + msg_handler(msg.c_str()); +} + typedef _Complex float complex_t; #define SAMPLE_SZ sizeof(complex_t) @@ -199,8 +207,14 @@ float cuhd_get_rx_gain_offset(void *h) { return 15; } -void cuhd_supress_stdout() { - uhd::msg::register_handler(my_handler); +void cuhd_suppress_stdout() { + uhd::msg::register_handler(suppress_handler); +} + +void cuhd_register_msg_handler(cuhd_msg_handler_t h) +{ + msg_handler = h; + uhd::msg::register_handler(translate_handler); } int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_rx)