discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OOT block swig problem (maybe qmake vs cmake)


From: Ali G. Dezfuli
Subject: OOT block swig problem (maybe qmake vs cmake)
Date: Mon, 25 May 2020 13:00:00 +0430

Hi all,

The story is this:

I always add all the necessary gr_modtool created files to a new project in qt-creator named "pre_gr" and develop a new OOT block there. Then, by building from source, I add the block to GRC, test it, and use it. This way I have developed some nontrivial practical modems.


BUT

I decided to be more organized by using more object-oriented features.
The problem is: the code in qt-creator compiled OK but when I add the block to GRC, I get this error:

Generating: '/home/ali/grdrills/top_block.py'
Executing: /usr/bin/python2 -u /home/ali/grdrills/top_block.py
Traceback (most recent call last):
  File "/home/ali/grdrills/top_block.py", line 168, in <module>
    main()
  File "/home/ali/grdrills/top_block.py", line 156, in main
    tb = top_block_cls()
  File "/home/ali/grdrills/top_block.py", line 69, in __init__
    self.tmp_tmp_cmo_acq0_0 = tmp.tmp_cmo_acq0()
AttributeError: 'module' object has no attribute 'tmp_cmo_acq0'

which is usually related to SWIG.
The point is that the class "_impl.h" has two member variables:
        Prm                 d_p;
        ACQ                 d_acq;
which are Prm class to hold all the parameters, and ACQ class for acquisition, and in "_impl.cpp" the constructor is like this:
    tmp_cmo_acq0_impl::tmp_cmo_acq0_impl()
      : gr::block("tmp_cmo_acq0",
                  gr::io_signature::make(1, 1, sizeof(gr_complex)),
                  gr::io_signature::make(1, 1, sizeof(gr_complex))),
            d_p(awgn, 5),
            d_acq(d_p)
    {
    }
and the problem arises just as I add "d_acq" to the block.
I really wonder why and it drives me crazy these days.
I did a lot of searches but nothing!
I am certain that there are lots of experts on the list and that's my only hope!

The code is as follows:

tmp_cmo_acq0_impl.h:
#ifndef INCLUDED_TMP_TMP_CMO_ACQ0_IMPL_H
#define INCLUDED_TMP_TMP_CMO_ACQ0_IMPL_H
#include <tmp/tmp_cmo_acq0.h>
#include "acq.h"
#include "nco.h"
#include "prm.h"
#include <itpp/itbase.h>
#include <itpp/signal/transforms.h>
#include <complex>
#include <deque>
namespace gr {
  namespace tmp {
    class tmp_cmo_acq0_impl : public tmp_cmo_acq0
    {
     private:
        Prm                 d_p;
        ACQ                 d_acq;

     public:
      tmp_cmo_acq0_impl();
      ~tmp_cmo_acq0_impl();

      // Where all the action really happens
      void forecast (int noutput_items, gr_vector_int &ninput_items_required);

      int general_work(int noutput_items,
           gr_vector_int &ninput_items,
           gr_vector_const_void_star &input_items,
           gr_vector_void_star &output_items);
    };
  } // namespace tmp
} // namespace gr
#endif /* INCLUDED_TMP_TMP_CMO_ACQ0_IMPL_H */



tmp_cmo_acq0_impl.cpp:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "tmp_cmo_acq0_impl.h"
#include "acq.h"
#include "nco.h"
#include "prm.h"
#include <itpp/itbase.h>
#include <itpp/signal/transforms.h>
#include <complex>
#include <deque>

namespace gr {
  namespace tmp {

    tmp_cmo_acq0::sptr
    tmp_cmo_acq0::make()
    {
      return gnuradio::get_initial_sptr
        (new tmp_cmo_acq0_impl());
    }

    tmp_cmo_acq0_impl::tmp_cmo_acq0_impl()
      : gr::block("tmp_cmo_acq0",
                  gr::io_signature::make(1, 1, sizeof(gr_complex)),
                  gr::io_signature::make(1, 1, sizeof(gr_complex))),
            d_p(awgn, 5),
            d_acq(d_p)
    {
    }

    tmp_cmo_acq0_impl::~tmp_cmo_acq0_impl()
    {
    }

    void
    tmp_cmo_acq0_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
    {
      ninput_items_required[0] = noutput_items;
    }

    int
    tmp_cmo_acq0_impl::general_work (int noutput_items,
                       gr_vector_int &ninput_items,
                       gr_vector_const_void_star &input_items,
                       gr_vector_void_star &output_items)
    {
        const gr_complex *in = (const gr_complex *) input_items[0];
        gr_complex *out = (gr_complex *) output_items[0];
        // Do <+signal processing+>
        int i = 0;
        for (i = 0; i < noutput_items; ++i) {
            out[i] = in[i]; // almost nothing !!!
        }

        consume_each (noutput_items);

        return noutput_items;
    }

  } /* namespace tmp */
} /* namespace gr */


prm.h:
#ifndef PRM_H
#define PRM_H

#include <itpp/itbase.h>

using namespace std;
using namespace itpp;

enum CH_MODE {awgn, rayleigh};
class Prm
{
public:
    CH_MODE ch_mode;

    int n_sb;

public:
    Prm(CH_MODE u_ch_mode, int u_n_sb);

};
#endif // PRM_H



prm.cpp:
#include "prm.h"
#include <itpp/itbase.h>

using namespace std;
using namespace itpp;


Prm::Prm(CH_MODE u_ch_mode, int u_n_sb)
    : ch_mode(u_ch_mode),
      n_sb(u_n_sb)
{}



acq.h
#ifndef ACQ_H
#define ACQ_H

#include "nco.h"
#include "prm.h"
#include <itpp/itbase.h>
#include <itpp/signal/transforms.h>
#include <complex>
#include <deque>

class ACQ {
public:
    const Prm           &p;

public:
                        ACQ(const Prm &u_p);

}; // Acq
#endif // ACQ_H




acq.cpp
#include "acq.h"
#include "nco.h"
#include "prm.h"
#include <itpp/itbase.h>
#include <itpp/signal/transforms.h>


ACQ::ACQ(const Prm &u_p)
    : p(u_p)

{}




The versions:
*** cmake: 3.15.1
*** gnuradio: 3.7.13.4
*** ubuntu: 16.04
and IT++ is quite OK in my other OOT blocks. (and of course here)

I really appreciate it,
regards
Ali G. Dezfuli

reply via email to

[Prev in Thread] Current Thread [Next in Thread]