在层次结构块中使用gr::fec::code::cc_encoder类
Using gr::fec::code::cc_encoder class in a hierarchical block
我已经实现了一个非常基本的C++CCSDS卷积编码器(k = 7
,r = 1/2
),它工作得很好。然而,它是非常基本的,并且缺乏操作模式(CC_STREAMING
、CC_TERMINATED
、CC_TAILBITING
、CC_TRUNCATED
)等选项。。等
因此,我决定使用默认的gnuradio gr::fec::code::cc_encoder类。我的编码超类将包括打孔和其他块,因此所有内容都将在一个层次块中。到目前为止,我将把这些块一个接一个地放在以gr::fec::code::cc_encoder开头的分层块中。下面是我的.cc实现文件。
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "debug_conv_encoder_impl.h"
namespace gr {
namespace baseband {
debug_conv_encoder::sptr
debug_conv_encoder::make(int frame_size, std::vector<int> polys, int mode, int pad)
{
return gnuradio::get_initial_sptr
(new debug_conv_encoder_impl(frame_size, polys, mode, pad));
}
/*
* The private constructor
*/
debug_conv_encoder_impl::debug_conv_encoder_impl(int frame_size, std::vector<int> polys, int mode, int pad)
: gr::hier_block2("debug_conv_encoder",
gr::io_signature::make(1, 1, sizeof(unsigned char)),
gr::io_signature::make(1, 1, sizeof(unsigned char)))
{
//Creating convolutional encoder
int k = 7;
int rate = 2;
bool d_pad = (pad == 1) ? true : false;
cc_mode_t d_mode = get_mode(mode);
gr::fec::code::cc_encoder::sptr encoder(gr::fec::code::cc_encoder::make(frame_size,k,rate,polys,0,d_mode,d_pad));
//connect(self(),0,self(),0); -- Works fine
connect(self() , 0 , encoder , 0); // --gives an error
connect(encoder , 0 , self() , 0); // --gives an error
//connect(encoder);
}
cc_mode_t debug_conv_encoder_impl::get_mode(int mode)
{
switch(mode)
{
case 0:
return CC_STREAMING;
case 1:
return CC_TERMINATED;
case 2:
return CC_TRUNCATED;
case 3:
return CC_TAILBITING;
default:
return CC_STREAMING;
}
}
/*
* Our virtual destructor.
*/
debug_conv_encoder_impl::~debug_conv_encoder_impl()
{
}
} /* namespace baseband */
} /* namespace gr */
这是头文件
#ifndef INCLUDED_BASEBAND_DEBUG_CONV_ENCODER_IMPL_H
#define INCLUDED_BASEBAND_DEBUG_CONV_ENCODER_IMPL_H
#include <baseband/debug_conv_encoder.h>
#include <gnuradio/fec/cc_encoder.h>
namespace gr {
namespace baseband {
class debug_conv_encoder_impl : public debug_conv_encoder
{
private:
cc_mode_t get_mode(int mode);
public:
debug_conv_encoder_impl(int frame_size, std::vector<int> polys, int mode, int pad);
~debug_conv_encoder_impl();
// Where all the action really happens
};
} // namespace baseband
} // namespace gr
#endif /* INCLUDED_BASEBAND_DEBUG_CONV_ENCODER_IMPL_H */
不幸的是,编译和链接文件(cmake..&&make)会出现以下错误:
xxx/GRC/baseband/gr-baseband/lib/debug_conv_encoder_impl.cc:53:39: error: no matching function for call to ‘gr::baseband::debug_conv_encoder_impl::connect(gr::hier_block2::opaque_self, int, gr::fec::generic_encoder::sptr&, int)’
connect(self() , 0 , encoder , 0);
/usr/local/include/gnuradio/hier_block2.h:105:10: note: no known conversion for argument 3 from ‘gr::fec::generic_encoder::sptr {aka boost::shared_ptr<gr::fec::generic_encoder>}’ to ‘gr::basic_block_sptr {aka boost::shared_ptr<gr::basic_block>}’
基本上;gr::fec::generic_encoder::sptr{aka boost::shared_ptr<gr::ffe::genetic_encoder>}'到'gr::basic_block_sptr{;意味着共享指针gr::fec::generic_encoder不能按照hier_block2.connect(basic_block_sptr src,int src_port,basic_blocks_sptr dst,int dst_port)的要求转换为gr::basic_block。
我已经用这种方式创建了许多分层块,但从未遇到过这个错误。我很确定我错过了什么大事。如有任何帮助,我们将不胜感激。顺便说一句,如果需要更多信息,请告诉我。干杯
我终于解决了这个问题。Gnu无线电FECAPI提供了编码器变量来定义FEC属性(从gr::FEC::generic_encoder类派生的类,例如cc_encoder、ldpc_encoder等)和部署变量(它们与Gnu无线电流程图中的调度器和编码器变量交互)。部署变量">gr::ffe::encoder"可以与诸如cc_ encoder或LDPC编码器之类的多个编码器变量一起使用。工作函数现在如下所示。OOT现在编译并正常工作。
debug_conv_encoder_impl::debug_conv_encoder_impl(int frame_size, std::vector<int> polys, int mode, int pad)
: gr::hier_block2("debug_conv_encoder",
gr::io_signature::make(1, 1, sizeof(unsigned char)),
gr::io_signature::make(1, 1, sizeof(unsigned char)))
{
//Creating a coder variable
int k = 7;
int rate = 2;
bool d_pad = (pad == 1) ? true : false;
cc_mode_t d_mode = get_mode(mode);
gr::fec::code::cc_encoder::sptr coder_variable(gr::fec::code::cc_encoder::make(frame_size,k,rate,polys,0,d_mode,d_pad));
//Creating a deployment variable
gr::fec::encoder::sptr coder_deployment(gr::fec::encoder::make(coder_variable,sizeof(unsigned char),sizeof(unsigned char)));
connect(self() , 0 , coder_deployment , 0);
connect(coder_deployment , 0 , self() , 0);
//connect(encoder);
}
cc_encoder
不是一个块,因此不能像块一样在流图中连接它。
事实上,您不应该能够实例化它,即使它只是一个抽象基类:
https://gnuradio.org/doc/doxygen/classgr_1_1fec_1_1code_1_1cc__encoder.html
我不太确定你需要什么编码器,但无论如何,这类都不是最好的选择。
- "throw expression code" 1e7 >返回 d 是什么?投掷标准::overflow_error( "too big" ) : d;意味 着?
- Visual Studio Code - C++ Debugger 無法啟動
- Visual Studio Code "undefined reference to `WinMain@16'"
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- 使用VS Code和CMake Tools运行自定义命令
- 修改 VS Code 中的默认C++代码段
- 如何配置Visual Studio Code以使用cygwin,cmake和gcc进行调试
- std::to_string - 'to_string' 不是 'std' 的成员 - Visual Studio Code 1.42.0
- VS Code C++:不准确的系统包括路径错误(wchar.h,boost/lambda/lambda.hpp)
- C++新手,想知道如何使用VS code 2019播放音频文件
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- 如何在Visual Studio Code中重命名我的a.exe文件?
- C++ Visual Studio Code 的设置不起作用
- 以某种方式告诉编译器"Do not process line of code"
- 在VS Code中编译C / C ++时如何禁用自动创建EXE文件?
- 将Qt与Visual Studio Code(Windows)一起使用
- 可视化 使用 VS Code 查找C++应用程序中的内存泄漏
- 将Visual Studio Code路径设置为.clang_format文件
- C++ Code 在 for 循环期间不会累积变量中的总和,仅提供最终迭代值
- 在层次结构块中使用gr::fec::code::cc_encoder类