gpt4 book ai didi

c++ - 在分层 block 中使用 gr::fec::code::cc_encoder 类

转载 作者:行者123 更新时间:2023-11-30 05:02:50 30 4
gpt4 key购买 nike

我已经实现了一个非常基本的 C++ CCSDS 卷积编码器(k = 7r = 1/2)并且工作正常。但是,它非常基础,缺少操作模式(CC_STREAMINGCC_TERMINATEDCC_TAILBITINGCC_TRUNCATED 等选项) 等..等

因此,我决定使用默认的 gnuradio gr::fec::code::cc_encoder 类。我的编码父类(super class)将包括打洞和其他 block ,因此所有内容都将在一个分层 block 中。到目前为止,我将 block 一个一个地放在以 gr::fec::code::cc_encoder 开头的分层 block 中。下面是我的 .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::basic_block_sptr {aka boost::shared_ptr }'"意味着共享指针 gr::fec::generic_encoder 不能按照 hier_block2.connect (basic_block_sptr src, int src_port, basic_block_sptr dst, int dst_port) 的要求转换为 gr::basic_block。

我用这种方式创建了很多层次 block ,但从未遇到过这个错误。我很确定我缺少一些重要的东西。任何帮助将不胜感激。顺便说一下,如果需要更多信息,请告诉我。干杯。

最佳答案

我终于能够解决这个问题。事实证明,Gnu radio FECAPI 提供编码器变量来定义 FEC 属性(派生自 gr::fec::generic_encoder 类的类,例如 cc_encoder、ldpc_encoder 等)和部署变量(与 GNU 中的调度程序和编码器变量交互) radio 流图。部署变量“gr::fec::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);
}

关于c++ - 在分层 block 中使用 gr::fec::code::cc_encoder 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49671107/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com