我使用gr_moodtools创建了一个模块gr-freqAdaptiveOFDM,我创建了一个文件signal_field.h,它将定义用于块“Packet Header Generator”的函数formatter()。为此,我需要将其称为freqAdaptiveOFDM.signal_field()。formatter(),但是当我调用它时,我得到一个错误,说freqAdaptiveOFDM没有属性signal_field。
定义signal_fields的文件是:
signal_field_impl.h
#ifndef INCLUDED_FREQADAPTIVEOFDM_SIGNAL_FIELD_IMPL_H
#define INCLUDED_FREQADAPTIVEOFDM_SIGNAL_FIELD_IMPL_H
#include <freqAdaptiveOFDM/signal_field.h>
#include "utils.h"
namespace gr {
namespace freqAdaptiveOFDM {
class signal_field_impl : public signal_field
{
public:
signal_field_impl();
~signal_field_impl();
bool header_formatter(long packet_len, unsigned char *out,
const std::vector<tag_t> &tags);
bool header_parser(const unsigned char *header,
std::vector<tag_t> &tags);
private:
int get_bit(int b, int i);
void generate_signal_field(char *out, frame_param &frame, ofdm_param &ofdm);
};
} // namespace freqAdaptiveOFDM
} // namespace gr
#endif /* INCLUDED_FREQADAPTIVEOFDM_SIGNAL_FIELD_IMPL_H */
signal_field.h
#ifndef INCLUDED_FREQADAPTIVEOFDM_SIGNAL_FIELD_H
#define INCLUDED_FREQADAPTIVEOFDM_SIGNAL_FIELD_H
#include <freqAdaptiveOFDM/api.h>
#include <gnuradio/digital/packet_header_default.h>
namespace gr {
namespace freqAdaptiveOFDM {
class FREQADAPTIVEOFDM_API signal_field : virtual public digital::packet_header_default
{
public:
typedef boost::shared_ptr<signal_field> sptr;
static sptr make();
protected:
signal_field();
};
} // namespace freqAdaptiveOFDM
} // namespace gr
#endif /* INCLUDED_FREQADAPTIVEOFDM_SIGNAL_FIELD_H */
我修改了我的swig文件:
#define FREQADAPTIVEOFDM_API
%include "gnuradio.i"
%include "freqAdaptiveOFDM_swig_doc.i"
%{
#include "freqAdaptiveOFDM/mapper.h"
#include "freqAdaptiveOFDM/signal_field.h"
%}
%include "gnuradio/digital/packet_header_default.h"
%include "freqAdaptiveOFDM/mapper.h"
%include "freqAdaptiveOFDM/signal_field.h"
GR_SWIG_BLOCK_MAGIC2(freqAdaptiveOFDM, mapper);
%template(signal_field_sptr) boost::shared_ptr<gr::freqAdaptiveOFDM::signal_field>;
%pythoncode %{
signal_field_sptr.__repr__ = lambda self: "<signal_field>"
signal_field = signal_field.make;
%}
我该怎么做?
提前多多感谢!