discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] How to write a block - Error adding sub function to a


From: E. Ornelas
Subject: [Discuss-gnuradio] How to write a block - Error adding sub function to a block
Date: Wed, 27 May 2009 04:11:30 -0700 (PDT)

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-adding-sub-function-to-a-block-tp23740353p23740353.html
Sent from the GnuRadio mailing list archive at Nabble.com.





reply via email to

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