discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Problem with new blocks


From: Loic Danceg
Subject: Re: [Discuss-gnuradio] Problem with new blocks
Date: Mon, 19 Mar 2012 09:28:13 -0300

Hi Ben,


I didn't find my error, so i decide to proceed with another method:

I use a project which works.
I create the file : rfid_file.cc and rfid_file.h
I modify the file rfid.i

I use the command: ./boostrap
                              ./configure
                              ./make
                              ./make configure

And i have no errors :-),

But i have an error after that, when i import my block in my file .py.

Traceback (most recent call last):
  File "./test.py", line 20, in <module>
    from gnuradio import rfid
  File "/usr/local/lib/python2.7/dist-packages/gnuradio/rfid.py", line 24, in <module>
    _rfid = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/gnuradio/rfid.py", line 20, in swig_import_helper
    _mod = imp.load_module('_rfid', fp, pathname, description)
ImportError: /usr/local/lib/python2.7/dist-packages/gnuradio/_rfid.so: undefined symbol: _Z14rfid_make_fileiP5state


Do you know why?


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <rfid_file.h>
#include <gr_io_signature.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#ifndef READER_VARS
#include "reader_vars.h"
#endif

#include <sys/time.h>
#include <float.h>
#include <signal.h>
#include <math.h>



bool trigger_next_cycle = false;


static itimerval timer;




rfid_file_sptr
rfid_make_file(int dec2, state * reader_state2)
{
  return rfid_file_sptr(new rfid_file(dec2, reader_state2));
}

rfid_file::rfid_file(int dec2, state * reader_state2):
  gr_block("rfid_file", gr_make_io_signature (1, 1, sizeof(float)), gr_make_io_signature (1,1,sizeof(float)))
{

  printf("test1");

}

rfid_file::~rfid_file()
{

}

int
rfid_file::general_work(int noutput_items,
              gr_vector_int &ninput_items,
              gr_vector_const_void_star &input_items,
              gr_vector_void_star &output_items)
 
{
  const float * in = (const float *)input_items[0];
  float * out = (float * )output_items[0];
  int nout = 0;
  int debug_out_cnt = 0;

  out[0] = in[0];
  consume_each(noutput_items);
  printf("test2");
 
return nout;
}


void
rfid_file::forecast (int noutput_items, gr_vector_int &ninput_items_required)
{
  unsigned ninputs = ninput_items_required.size ();
  for (unsigned i = 0; i < ninputs; i++){
    ninput_items_required[i] = noutput_items;
  }  
}




#ifndef INCLUDED_RFID_FILE_H
#define INCLUDED_RFID_FILE_H

#include <gr_block.h>
#include <gr_message.h>
#include <gr_msg_queue.h>

#include "reader_vars.h"

class rfid_file;
typedef boost::shared_ptr<rfid_file> rfid_file_sptr;

rfid_file_sptr
rfid_make_file (int dec2, state * reader_state2 );

class rfid_file : public gr_block
{
private:
  friend rfid_file_sptr rfid_make_file(int dec2, state * reader_state2);
 
  rfid_file(int dec2,  state * reader_state2);


  state * d_reader_state2;



  void forecast (int noutput_items, gr_vector_int &ninput_items_required);



public:
  ~rfid_file();
  int general_work(int noutput_items,
           gr_vector_int &ninput_items,
           gr_vector_const_void_star &input_items,
           gr_vector_void_star &output_items);
 
};

#endif




%include "exception.i"
%include "gnuradio.i"                            // the common stuff
 
%{
#include "gnuradio_swig_bug_workaround.h"       // mandatory bug fix
#include "rfid_clock_recovery_zc_ff.h"
#include "rfid_cmd_gate.h"
#include "rfid_gen2_reader.h"
#include "rfid_reader_decoder.h"
#include "rfid_file.h"
%}
 


//-----------------------------------------------------------------
GR_SWIG_BLOCK_MAGIC(rfid, reader_decoder);

rfid_reader_decoder_sptr
rfid_make_reader_decoder (float us_per_sample, float tari);


class rfid_reader_decoder: public gr_sync_block{
 
  rfid_reader_decoder (float us_per_sample, float tari);

public:
  ~rfid_reader_decoder();
  gr_msg_queue_sptr get_log() const;

 
};


//-----------------------------------------------------------------
GR_SWIG_BLOCK_MAGIC(rfid, cmd_gate);

rfid_cmd_gate_sptr rfid_make_cmd_gate (int dec, state * reader_state);


class rfid_cmd_gate: public gr_block{
 
  rfid_cmd_gate (int dec, state * reader_state);

public:
  ~rfid_cmd_gate();

 
 
};

//-----------------------------------------------------------------
GR_SWIG_BLOCK_MAGIC(rfid, file);

rfid_file_sptr rfid_make_file (int dec2, state * reader_state2);


class rfid_file: public gr_block{
 
  rfid_file (int dec2, state * reader_state2);

public:
  ~rfid_file();

 
 
};

//-----------------------------------------------------------------

GR_SWIG_BLOCK_MAGIC(rfid, gen2_reader);

rfid_gen2_reader_sptr rfid_make_gen2_reader (int dec, int interp, int miller, bool elg, int dev_corr);


class rfid_gen2_reader: public gr_block{
 
  rfid_gen2_reader (int dec, int interp, int miller, bool elg, int dev_corr);

public:
  ~rfid_gen2_reader();
  state * STATE_PTR;
  gr_msg_queue_sptr get_log() const;

 
 
};


//-----------------------------------------------------------------
GR_SWIG_BLOCK_MAGIC(rfid, clock_recovery_zc_ff);

rfid_clock_recovery_zc_ff_sptr
rfid_make_clock_recovery_zc_ff(int samples_per_pulse, int interp_factor, float us_per_sample, float blf, bool elg);

class rfid_clock_recovery_zc_ff: public gr_block{
  rfid_clock_recovery_zc_ff(int samples_per_pulse, int interp_factor, float us_per_sample, float blf, bool elg);

public:
  ~rfid_clock_recovery_zc_ff();
 
};


Btw, thank you a lot for your help!


Le 16 mars 2012 14:18, Ben Hilburn <address@hidden> a écrit :
Sorry, last e-mail should have said, "Check out Martin's and Zhonghua's advice..."

Cheers,
Ben

On Fri, Mar 16, 2012 at 10:17 AM, Ben Hilburn <address@hidden> wrote:
Aha - you suspect a SWIG error?  That may indeed be the issue.

Check out Martin's advice, and let us know how it goes.  Have you generally tested the SWIG for your class?

Cheers,
Ben


On Fri, Mar 16, 2012 at 6:37 AM, Loic Danceg <address@hidden> wrote:
Hi Ben

Thank you for your help.
I am really familiar with Python, i think is more an error with the file .i or another error but i don't find my error :-(

Le 14 mars 2012 21:34, Ben Hilburn <address@hidden> a écrit :

Loic -

That is a Python error, telling you that your class 'rfid' doesn't have the member 'test'.  This is an error in your code.

How familiar are you with Python?  You may want to read up on some Python documentation to help you understand how that all works.


Cheers,
Ben



On Tue, Mar 13, 2012 at 9:37 AM, Loic Danceg <address@hidden> wrote:
Hi everybody!

I try to create my own block in a current project (rfid). So there are currently other blocks which works correctly.
I had create my file.cc, my file.h and add the part that i need to add in the file rfid.i

After that, I enter the following command line:

./configure
make
make configure

But when i use my application.py i have this error:

Traceback (most recent call last):
  File "./test.py", line 215, in <module>
    main ()
  File "./test.py", line 65, in main
    tb = my_top_block()
  File "./test.py", line 43, in __init__
    d1 = rfid.test()
AttributeError: 'module' object has no attribute 'test'

Someone know why?

Thank you a lot for your time!


_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio







reply via email to

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