Forum: GNU Radio How to write a block - Error adding sub function to a block

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C64f7f638aa2670aa9d5e4a0630e87aa?d=identicon&s=25 E. Ornelas (Guest)
on 2009-05-27 13:12
(Received via mailing list)
Hello!

I've been using the examples from "how to write a block" as a base to
create
my own.

Using one of them a created some kind of sink. In it I added some
auxiliary
function accessible from the outside in order to get the values from the
buffer. So far so good...

With the other one I made a file sink, which stores some statistics
calculated on the block. Then I went to add a simple function just to
close
the current file and open a new one every few hours.
What happens is that I followed the same procedure to add the sub
function
to be accessible from the outside, and for some reason I can't seem to
find
it gives me an error which I never seen on the other one.

The procedure I used on the other was this:
1. On the header define the function as public
2. After the my_class::work() define the function and the code
3. On the howto.i add the function as in header file

I don't know if this was correct but it worked on the first one.

I hope you can help me. Thanks in advance!

Next is the errors and the code:
#--------------------------------------------------------------#
ERROR:

Traceback (most recent call last):
  File "Acquisition.py", line 4, in <module>
    from gnuradio import usrp, howto
  File "/usr/local/lib/python2.5/site-packages/gnuradio/howto.py", line
6,
in <module>
    import _howto
ImportError: /usr/local/lib/python2.5/site-packages/gnuradio/_howto.so:
undefined symbol: _ZN16howto_co_cx_stat14create_new_logEPc

#-------------------------------------------------------------------------------#
HOWTO.I

GR_SWIG_BLOCK_MAGIC(howto,co_cx_stat);

howto_co_cx_stat_sptr howto_make_co_cx_stat ( unsigned int vector_size,

unsigned int sampling,

unsigned int fftsize,

char *filename);

class howto_co_cx_stat : public gr_block
{
private:
  howto_co_cx_stat (unsigned int vector_size,
                              unsigned int sampling,
                              unsigned int fftsize,
                              char *filename);

public:
  int create_new_log(char file_name[255]);      // REFERENCE //
};

#-------------------------------------------------------------------------------#
HOWTO_CO_CX.H

class howto_co_cx_stat : public gr_block
{
//private:
  // The friend declaration allows howto_make_co_cx_stat to
  // access the private constructor.

  friend howto_co_cx_stat_sptr howto_make_co_cx_stat (unsigned int
vector_size,
                                                unsigned int sampling,
                                                unsigned int
fftsize,char *filename);

  howto_co_cx_stat (unsigned int vector_size,
             unsigned int sampling,
                                     unsigned int fftsize,
                                     char *filename);    // private
constructor
  unsigned int d_vector_size;
  unsigned int d_sampling;
  unsigned int d_fftsize;
  char d_filename[255];

  std::vector<gr_complex> band100_CO;
  std::vector<gr_complex> band100_CX;
  std::vector<gr_complex> band4000_Noise;
  std::vector<float> band100_CXi;
  std::vector<float> band100_CXq;

  float amp_co, amp_cx, phase;
  FILE *file;
  MATLAB_MATRIX_HEADER header;

 public:
  ~howto_co_cx_stat ();  // public destructor

  int general_work (int noutput_items,
        gr_vector_int &ninput_items,
        gr_vector_const_void_star &input_items,
        gr_vector_void_star &output_items);

  int create_new_log(char file_name[255]);        // DESIRED FUNCTION //
};

#---------------------------------------------------------------------------------#
HOW_CO_CX.CC

(...default stuff...)

int
howto_co_cx_stat::general_work (int noutput_items,
             gr_vector_int &ninput_items,
             gr_vector_const_void_star &input_items,
             gr_vector_void_star &output_items)
{
    (...work...)
}


int create_new_log(char file_name[255])
{
  printf("\n\n\name changed!!!\n\n\n");
  printf("\nFile 1 C++: %s", file_name);

  return 0;
}
--
View this message in context:
http://www.nabble.com/How-to-write-a-block---Error...
Sent from the GnuRadio mailing list archive at Nabble.com.
781e96b7bd64e8833d71e3914cb1594a?d=identicon&s=25 Michael Dickens (Guest)
on 2009-05-27 16:39
(Received via mailing list)
> ImportError: /usr/local/lib/python2.5/site-packages/gnuradio/
> _howto.so:
> undefined symbol: _ZN16howto_co_cx_stat14create_new_logEPc
> #---------------------------------------------------------------------------------#
> HOW_CO_CX.CC
> int create_new_log(char file_name[255])

You have a basic C++ scope issue ... the above should be:

int howto_co_cx_stat::create_new_log(char file_name[255])
C64f7f638aa2670aa9d5e4a0630e87aa?d=identicon&s=25 E. Ornelas (Guest)
on 2009-05-27 17:23
(Received via mailing list)
I've made the change and now its working.
It's a beginers error :)
Many thanks!


Michael Dickens-3 wrote:
> int howto_co_cx_stat::create_new_log(char file_name[255])
>
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>

--
View this message in context:
http://www.nabble.com/How-to-write-a-block---Error...
Sent from the GnuRadio mailing list archive at Nabble.com.
This topic is locked and can not be replied to.