0

I have created a module gr-freqAdaptiveOFDM using gr_moodtools, and I have created a file signal_field.h that will define the function formatter() for being used in the block "Packet Header Generator". For this, I need to call it as freqAdaptiveOFDM.signal_field().formatter(), but when I call it I get an error saying that freqAdaptiveOFDM does not have an attribute signal_field.

The files defining the signal_fields are:

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 */

And I have modified my swig file:

#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;
%}

How can I do it??

Thanks a lot in advance!

Samuel
  • 33
  • 1
  • 4
  • *"freqAdaptiveOFDM does not have an attribute signal_field"* means you need to look at the header where you declare the `freqAdaptiveOFDM` class, so most likely include//freqAdaptiveOFDM.h – Marcus Müller Nov 25 '16 at 11:22
  • "freqAdaptiveOFDM" is my module name, so gr_modtool does not create the file include//freqAdaptiveOFDM.h, but I have there the signal_field.h file. – Samuel Nov 25 '16 at 11:37
  • but if that is your module name, then accessing `signal_field` as a **class** member using the dot operator `.` isn't valid C++... you'd need to use the scope/namespace operator `::` instead! – Marcus Müller Nov 25 '16 at 11:48
  • But I am calling it inside GNU Radio Companion, so it will be called as a Python module, that's why I am calling it with the dot operator. – Samuel Nov 25 '16 at 12:00
  • aaah ok, this happens in Python. Ok. – Marcus Müller Nov 25 '16 at 12:48

0 Answers0