0
我在gnuradio companion(grc)中創建了一個bpsk流程圖,它工作正常。目前,我正在使用gnuradio類編寫一個C++相同的程序。首先我從一個文件中讀取I/Q數據,並且能夠獲得所有bpsk調製的AX.25幀。現在我試圖用UHD替換文件源塊,以便能夠實時讀取I/Q數據。使報告出現錯誤「引用'uhd'含糊不清」。完整的化妝輸出如下所示GNU Radio出錯:「引用'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文件。我基本上修改該文件從原始撥號音C++例如其可以在{YOUR_GNURADIO_DIRECTORY}中找到/ GR-音頻/示例/ 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})
任何幫助將高度讚賞。
Regards
摩西。