C++ def“uuu init”(self,*args,**kwargs):引发AttributeError(“未定义构造函数”)AttributeError:未定义构造函数
我正在尝试使用gr_modtool.py在gnuradio中创建一个新的DSP块。gnuradio版本是3.3.0。 我在include文件夹的abc.h文件中有以下代码C++ def“uuu init”(self,*args,**kwargs):引发AttributeError(“未定义构造函数”)AttributeError:未定义构造函数,c++,python,wrapper,swig,gnuradio,C++,Python,Wrapper,Swig,Gnuradio,我正在尝试使用gr_modtool.py在gnuradio中创建一个新的DSP块。gnuradio版本是3.3.0。 我在include文件夹的abc.h文件中有以下代码 ifndef INCLUDED_ENERGYDETECTOR_LOCAL_SENSING_FF_H #define INCLUDED_ENERGYDETECTOR_LOCAL_SENSING_FF_H #include <gr_block.h> namespace gr { namespace en
ifndef INCLUDED_ENERGYDETECTOR_LOCAL_SENSING_FF_H
#define INCLUDED_ENERGYDETECTOR_LOCAL_SENSING_FF_H
#include <gr_block.h>
namespace gr {
namespace energydetector {
class ENERGYDETECTOR_API local_sensing_ff : virtual public gr_block
{
private:
public:
typedef boost::shared_ptr<local_sensing_ff> sptr;
float d_pfa; int d_L; int d_samples;
static sptr make(float pfa=0.01,int L=16,int samples=1000);
virtual void set_pfa(float input_a) { d_pfa = input_a; }
virtual int get_pfa() { return d_pfa; }
virtual void set_L(int input_b) { d_L = input_b; }
virtual int get_L() { return d_L; }
virtual void set_samples(int input_c) { d_samples = input_c; }
virtual int get_samples() { return d_samples; }
};
} // namespace energydetector
} // namespace gr
#endif /* INCLUDED_ENERGYDETECTOR_LOCAL_SENSING_FF_H */
它已成功构建,但在执行时出现以下错误:def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
AttributeError: No constructor defined
请帮我调试一下。最后我知道这是由于版本不受支持。 gr_modtool.py仅受GNURadio 3.6或更高版本的支持 虽然我们可以构建块并在GRC中使用它,但不确定为什么它不能工作。 它必须是gr_modtool生成的代码结构。py不适用于3.3.0版 所以任何回答这个问题的人都要确保你有Gnuradio3.6及以上版本。
但是如果有人通过修改gr_modtool.py或任何代码解决了这个问题,那么请在这个问题中告诉我们。SWIG不会为没有公共构造函数或抽象的类生成构造函数
请参见当我从代码中删除“from gnuradio.gr import*”时,这个问题消失了也向我们展示Python代码。你是说SWIG生成的文件我实际上对该库一无所知,但当你“执行”你的代码时,你会得到一个Python
AttributeError
,因此,我认为您正在编写Python并使用这个C++/Python混合库。不是这样吗?事实上,不要理会。我花了一点时间来看看是否有人和你和我有类似的问题,你意识到你可能会写C++。顺便说一下,我和你有同样的问题。有人建议他升级到3.6.4,他再也没有回到线程上来说它是否有效。但是,嘿,看看吧。是的,我在那个论坛上看过,但没有解决办法
#define ENERGY_DETECTOR_API
%include "gnuradio.i" // the common stuff
%include "energydetector_swig_doc.i"
%{
#include "energydetector/local_sensing_ff.h"
%}
%include "energydetector/local_sensing_ff.h"
GR_SWIG_BLOCK_MAGIC2(energydetector, local_sensing_ff);
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
AttributeError: No constructor defined