Search code examples
gnuradiognuradio-companionuhd

How to use existing UHD function calls in a custom OOT module in Gnu Radio


I am making a custom OOT module called test3 in GNU Radio which needs to use some uhd functions.

For example, I need to call the uhd::set_thread_priority_safe() function, so I import the thread.hpp file:

#include <uhd/utils/thread.hpp>

Since the function call is in the uhd namespace, so I try to use the namespace to call the function:

namespace gr {
  namespace test3 {
    using namespace uhd;
    .
    .
    .
    int get_time_impl::work(int noutput_items,
    gr_vector_const_void_star &input_items,
    gr_vector_void_star &output_items)
    {
        uhd::set_thread_priority_safe();
        return 0;
    }
}

But doing this does not work, and I get the following error:

AttributeError: module 'test3' has no attribute 'get_time'

But when I remove the uhd function call, the error goes away.

How can I solve this problem?


Solution

  • I solved the issue by the following steps.

    1. In gr-module/CMakeLists.txt, I added 'find_package(UHD)' in the 'find gnuradio build dependencies' section.
    2. In gr-module/lib/CMakeLists.txt, I updated the target link libraries command to 'target_link_libraries(gnuradio-module gnuradio::gnuradio-runtime UHD::UHD)'.

    After running cmake and make commands after the above changes, the issue was resolved.