Adding message handler interface
This commit is contained in:
parent
ee098fe54d
commit
ed87963d39
3 changed files with 24 additions and 6 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
#endif
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue