GNU 电台出错:"reference to ‘uhd’ is ambiguous"



我在gnuradio companion(GRC(中创建了一个bpsk flowgraph,它工作正常。目前,我使用gnuradio类编写同一程序的C 等效。首先,我从文件中读取I/Q数据,然后能够获得所有BPSK调制的AX.25帧。现在,我试图用UHD替换文件源块,以便能够实时读取I/Q数据。使报告错误"引用'uhd'是模棱两可的"。完整的功能如下所示

 $ make
[ 50%] Building CXX object CMakeFiles/bpsk.dir/bpsk.cc.o
/home/mbkitine/Dropbox/Lulea/GRC/SSC/PSK/bpsk/RX_C++/bpsk.cc: In function ‘int main(int, char**)’:
/home/mbkitine/Dropbox/Lulea/GRC/SSC/PSK/bpsk/RX_C++/bpsk.cc:85:78: error: reference to ‘uhd’ is ambiguous
   gr::uhd::usrp_source::sptr uhd_source = gr::uhd::usrp_source::make(address,uhd::stream_args_t("fc32"));
                                                                              ^
In file included from /usr/local/include/uhd/types/metadata.hpp:22:0,
                 from /usr/local/include/uhd/stream.hpp:22,
                 from /usr/local/include/uhd/device.hpp:22,
                 from /usr/local/include/uhd/usrp/multi_usrp.hpp:37,
                 from /usr/local/include/gnuradio/uhd/usrp_block.h:28,
                 from /usr/local/include/gnuradio/uhd/usrp_source.h:26,
                 from /home/mbkitine/Dropbox/Lulea/GRC/SSC/PSK/bpsk/RX_C++/bpsk.cc:56:
/usr/local/include/uhd/types/time_spec.hpp:25:14: note: candidates are: namespace uhd { }
 namespace uhd{
              ^
In file included from /usr/local/include/gnuradio/uhd/usrp_source.h:26:0,
                 from /home/mbkitine/Dropbox/Lulea/GRC/SSC/PSK/bpsk/RX_C++/bpsk.cc:56:
/usr/local/include/gnuradio/uhd/usrp_block.h:31:17: note:                 namespace gr::uhd { }
   namespace uhd {
                 ^
CMakeFiles/bpsk.dir/build.make:62: recipe for target 'CMakeFiles/bpsk.dir/bpsk.cc.o' failed
make[2]: *** [CMakeFiles/bpsk.dir/bpsk.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/bpsk.dir/all' failed
make[1]: *** [CMakeFiles/bpsk.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

这是我的bpsk.cc代码

// Include header files for each block used in flowgraph
#include <gnuradio/top_block.h>
#include <gnuradio/analog/sig_source_f.h>
#include <gnuradio/analog/agc2_cc.h>
#include <gnuradio/digital/fll_band_edge_cc.h>
#include <gnuradio/digital/pfb_clock_sync_ccf.h>
#include <gnuradio/filter/firdes.h>
#include <gnuradio/digital/cma_equalizer_cc.h>
#include <gnuradio/digital/costas_loop_cc.h>
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
#include <gnuradio/digital/binary_slicer_fb.h>
#include <gnuradio/digital/diff_decoder_bb.h>
#include <gnuradio/digital/hdlc_deframer_bp.h>
#include <gnuradio/blocks/message_debug.h>
#include <gnuradio/audio/sink.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/uhd/usrp_source.h>
#include <ais/invert.h>
#include <gnuradio/blocks/complex_to_real.h>
#include <iostream>
#include <string>
using namespace gr;
int main(int argc, char **argv)
{
  //Extracting variables from the menu
  char* filename = argv[1];
  //UHD Default parameters
  double samp_rate = 1000000;
  double baud_rate = 250000;
  double fc        = 100e6;
  int sps          = int(samp_rate/baud_rate);
  //Receiver parameters
  int dec       = 10;
  float loop_bw = 2 * 3.14/100;
  // Construct a top block that will contain flowgraph blocks.  Alternatively,
  // one may create a derived class from top_block and hold instantiated blocks
  // as member data for later manipulation.
  top_block_sptr tb = make_top_block("bpsk");
  //UHD block
  std::string address = "192.168.10.2";
  gr::uhd::usrp_source::sptr uhd_source = gr::uhd::usrp_source::make(address,uhd::stream_args_t("fc32"));
  uhd_source->set_samp_rate(samp_rate);
  uhd_source->set_center_freq(fc);
  //Reading bpsk signal from file
  //blocks::file_source::sptr file = blocks::file_source::make(sizeof(gr_complex),filename,false);
  //Automatic gain controller
  analog::agc2_cc::sptr agc = analog::agc2_cc::make(1e-1, 1e-2, 1.0, 1.0);
  //FLL band edge filter
  digital::fll_band_edge_cc::sptr fll = digital::fll_band_edge_cc::make(sps, 0.5, 44, loop_bw);
  //PFB symbol time recovery
  const int nfilts = 32;
  std::vector<float> rrc_taps = filter::firdes::root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts);
  digital::pfb_clock_sync_ccf::sptr pfb = digital::pfb_clock_sync_ccf::make(sps,loop_bw,rrc_taps,nfilts,0,1.5,2);
  //CMA equalization
  digital::cma_equalizer_cc::sptr cma = digital::cma_equalizer_cc::make(15,1,0.01,2);
  //Costas loop
  digital::costas_loop_cc::sptr costas = digital::costas_loop_cc::make(loop_bw,2);
  //Taking the real part
  gr::blocks::complex_to_real::sptr comp_to_real = blocks::complex_to_real::make(1);
  //Binary slicer
  digital::binary_slicer_fb::sptr slicer  = digital::binary_slicer_fb::make();
  //Differential decoder
  digital::diff_decoder_bb::sptr differential_decoder = digital::diff_decoder_bb::make(2);
  //Inverting bit values
  //invert::sptr inverter = ais::invert::make();
  //HDLC Deframer
  digital::hdlc_deframer_bp::sptr deframer =  digital::hdlc_deframer_bp::make(32,500);
  //Output data
  gr::blocks::message_debug::sptr msg = gr::blocks::message_debug::make();
  std::cout << "Blocks declared successfully " << std::endl;
  //Connections
  tb->connect(uhd_source,0,agc,0);
  tb->connect(agc,0,fll,0);
  tb->connect(fll,0,pfb,0);
  tb->connect(pfb,0,cma,0);
  tb->connect(cma,0,costas,0);
  tb->connect(costas,0,comp_to_real,0);
  tb->connect(comp_to_real,0,slicer,0);
  tb->connect(slicer,0,differential_decoder,0);
  tb->connect(differential_decoder,0,deframer,0);
  //tb->connect(inverter,0,deframer,0);
  tb->msg_connect(deframer,"out",msg,"print_pdu");
  tb->run();
  std::cout << "The GNU Radio Thread is Running " << std::endl;
  // Exit normally.
  return 0;
}

最后是我的cmakelists.txt文件。我基本上从原始的dialtone C 示例中修改了此文件,该示例可以在{your_gnuradio_directory}/gr-audio/示例/c

中找到。
cmake_minimum_required(VERSION 2.6)
project(bpsk CXX)
find_package(Boost "1.35" COMPONENTS system)
set(GR_REQUIRED_COMPONENTS RUNTIME ANALOG AUDIO BLOCKS FILTER DIGITAL UHD)
find_package(Gnuradio "3.7.2" REQUIRED)
include_directories(${GNURADIO_ALL_INCLUDE_DIRS})
add_executable(bpsk bpsk.cc)
target_link_libraries(bpsk ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES})

任何帮助将不胜感激。

问候

摩西。

错误说明那里有什么问题:

因为您正在做

 using namespace gr;

您的编译器不能知道您是指gr::uhd还是uhd

我只建议丢弃using namespace gr指令。或者,当您确实是指非gr::名称空间时使用::uhd

相关内容

最新更新