Hey,
I’m a new to use gnuradio and USRP B210, now I want to generate my OOT module 
start with the example ‘howto_detect’, and I followed guided tutorial in 
gnuradio.org. But there are still some problems as follows.

[  6%] Building CXX object 
lib/CMakeFiles/gnuradio-howto.dir/howto_detect_ff_impl.cc.o
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:32:5: error: 
prototype for ‘gr::howto::howto_detect_ff::sptr 
gr::howto::howto_detect_ff::make(float, int, int)’ does not match any in class 
‘gr::howto::howto_detect_ff’
     howto_detect_ff::make(float pfa, int L, int samples)
     ^
In file included from 
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.h:24:0,
                 from 
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:26:
/home/mint/Documents/gr-howto/include/howto/howto_detect_ff.h:49:19: error: 
candidate is: static gr::howto::howto_detect_ff::sptr 
gr::howto::howto_detect_ff::make()
       static sptr make();
                   ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc: In constructor 
‘gr::howto::howto_detect_ff_impl::howto_detect_ff_impl(float, int, int)’:
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:52:24: error: 
expression cannot be used as a function
               d_pfa(pfa), d_L(L), d_samples(samples))
                        ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:52:32: error: 
expression cannot be used as a function
               d_pfa(pfa), d_L(L), d_samples(samples))
                                ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:52:52: error: 
expression cannot be used as a function
               d_pfa(pfa), d_L(L), d_samples(samples))
                                                    ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc: In function ‘float 
gr::howto::TracyWidom(float)’:
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:71:46: error: 
‘printf’ was not declared in this scope
 tw = 18*(pd - (17/75)); printf("a - %f\n", tw);
                                              ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:73:47: error: 
‘printf’ was not declared in this scope
 tw = 8*(pd - (179/400)); printf("b - %f\n", tw);
                                               ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:75:53: error: 
‘printf’ was not declared in this scope
 tw = (87/20)*(pd - (643/870)); printf("c - %f\n", tw);
                                                     ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:77:52: error: 
‘printf’ was not declared in this scope
 tw = (16/5)*(pd - (287/320)); printf("d - %f\n", tw);
                                                    ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:79:52: error: 
‘printf’ was not declared in this scope
 tw = (17/5)*(pd - (297/340)); printf("e - %f\n", tw);
                                                    ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:81:49: error: 
‘printf’ was not declared in this scope
 tw = (5.2)*(pd - (0.813)); printf("f - %f\n", tw);
                                                 ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:83:53: error: 
‘printf’ was not declared in this scope
 tw = (53/5)*(pd - (909/1060)); printf("g - %f\n", tw);
                                                     ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:85:48: error: 
‘printf’ was not declared in this scope
 tw = 26*(pd - (593/650)); printf("h - %f\n", tw);
                                                ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:87:56: error: 
‘printf’ was not declared in this scope
 printf ("wrong pfa value: it must be between 0 and 1\n");
                                                        ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc: In member function 
‘virtual int gr::howto::howto_detect_ff_impl::general_work(int, gr_vector_int&, 
gr_vector_const_void_star&, gr_vector_void_star&)’:
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:141:9: error: 
‘gsl_matrix’ was not declared in this scope
         gsl_matrix * hankel = gsl_matrix_alloc (lenght,d_L);
         ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:141:22: error: 
‘hankel’ was not declared in this scope
         gsl_matrix * hankel = gsl_matrix_alloc (lenght,d_L);
                      ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:141:59: error: 
‘gsl_matrix_alloc’ was not declared in this scope
         gsl_matrix * hankel = gsl_matrix_alloc (lenght,d_L);
                                                           ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:142:22: error: ‘V’ 
was not declared in this scope
         gsl_matrix * V = gsl_matrix_alloc (d_L,d_L);
                      ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:143:9: error: 
‘gsl_vector’ was not declared in this scope
         gsl_vector * S = gsl_vector_alloc (d_L);
         ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:143:22: error: ‘S’ 
was not declared in this scope
         gsl_vector * S = gsl_vector_alloc (d_L);
                      ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:143:47: error: 
‘gsl_vector_alloc’ was not declared in this scope
         gsl_vector * S = gsl_vector_alloc (d_L);
                                               ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:144:22: error: ‘temp’ 
was not declared in this scope
         gsl_vector * temp = gsl_vector_alloc (d_ L);
                      ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:144:47: error: ‘d_’ 
was not declared in this scope
         gsl_vector * temp = gsl_vector_alloc (d_ L);
                                               ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:147:36: error: 
‘gsl_matrix_set_zero’ was not declared in this scope
         gsl_matrix_set_zero (hankel);
                                    ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:156:47: error: 
‘fopen’ was not declared in this scope
             story = fopen("filestory.txt", "a");
                                               ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:159:60: error: 
‘gsl_matrix_set’ was not declared in this scope
                     gsl_matrix_set (hankel, p, j, vett[p+j]);
                                                            ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:162:57: error: 
‘gsl_linalg_SV_decomp’ was not declared in this scope
                 gsl_linalg_SV_decomp (hankel, V, S, temp);
                                                         ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:163:43: error: 
‘gsl_vector_get’ was not declared in this scope
                 lmax = gsl_vector_get(S, 0);
                                           ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:167:79: error: 
‘fprintf’ was not declared in this scope
                 fprintf(story, "%f - ratio=%f - soglia=%f\n ", mem, ratio, 
thr);
                                                                               ^
/home/mint/Documents/gr-howto/lib/howto_detect_ff_impl.cc:168:29: error: 
‘fclose’ was not declared in this scope
                 fclose(story);
                             ^
make[2]: *** [lib/CMakeFiles/gnuradio-howto.dir/howto_detect_ff_impl.cc.o] 
Error 1
make[1]: *** [lib/CMakeFiles/gnuradio-howto.dir/all] Error 2
make: *** [all] Error 2

Any solution to sort an error will be appreciated.

Thanks a lot,

Yan





This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.

/* -*- c++ -*- */
/* 
 * Copyright 2015 <+YOU OR YOUR COMPANY+>.
 * 
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <gnuradio/io_signature.h>
#include "howto_detect_ff_impl.h"

namespace gr {
  namespace howto {

    howto_detect_ff::sptr
    howto_detect_ff::make(float pfa, int L, int samples)
    {
      return gnuradio::get_initial_sptr
        (new howto_detect_ff_impl(pfa, L, samples));
    }
    
    static const int MIN_IN = 1; // mininum number of input streams
    static const int MAX_IN = 1; // maximum number of input streams
    static const int MIN_OUT = 1; // minimum number of output streams
    static const int MAX_OUT = 1; // maximum number of output streams
    float mem = 0; //Global Variable
    
    /*
     * The private constructor
     */
     
    howto_detect_ff_impl::howto_detect_ff_impl(float pfa, int L, int samples)
      : gr::block("howto_detect_ff",
              gr::io_signature::make(MIN_IN, MAX_IN, sizeof(float)),
              gr::io_signature::make(MIN_OUT, MAX_OUT, sizeof(float)),
              d_pfa(pfa), d_L(L), d_samples(samples))
    {}

    /*
     * Our virtual destructor.
     */
    howto_detect_ff_impl::~howto_detect_ff_impl()
    {
    }
//------------functions---------------

/*This function gives the CDF value for the pfa in input*/

float TracyWidom (float p){

float pd, tw;
tw = 0.45;
pd = 1 - p;
if (pd >= 0.01 && pd <= 0.05){
tw = 18*(pd - (17/75)); printf("a - %f\n", tw);
}else if (pd >= 0.05 && pd <= 0.1){
tw = 8*(pd - (179/400)); printf("b - %f\n", tw);
}else if (pd >= 0.1 && pd <= 0.3){
tw = (87/20)*(pd - (643/870)); printf("c - %f\n", tw);
}else if (pd >= 0.3 && pd <= 0.5){
tw = (16/5)*(pd - (287/320)); printf("d - %f\n", tw);
}else if (pd >= 0.5 && pd <= 0.7){
tw = (17/5)*(pd - (297/340)); printf("e - %f\n", tw);
}else if (pd >= 0.7 && pd <= 0.9){
tw = (5.2)*(pd - (0.813)); printf("f - %f\n", tw);
}else if (pd >= 0.9 && pd <= 0.95){
tw = (53/5)*(pd - (909/1060)); printf("g - %f\n", tw);
}else if (pd >= 0.95 && pd <= 1){
tw = 26*(pd - (593/650)); printf("h - %f\n", tw);
}else{
printf ("wrong pfa value: it must be between 0 and 1\n");
printf ("the pfa value standard is 0.1\n");
tw = (53/5)*(0.9 - (909/1060));
}
return tw;
}
/*this function calculates the threshold for the test
the inputs are: ns = numbers of samples;
L = length of the correlation function;
pfa = probability of false alarm*/
float gamma (int ns, int L, float pfa){
  float A, B, C, ratio1, ratio2, g;
  A = sqrt(ns)+sqrt(L);
  B = sqrt(ns)-sqrt(L);
  C = ns*L;
  ratio1 = pow(A,2)/pow(B,2);
  ratio2 = 1+( pow(A,-0.667) / pow(C,0.167) )*pfa;
  g = ratio1*ratio2;

  return g;
}
/*This function makes the detection test*/

float test (float r, float t){
    float decision;
    if(r > -1){
      if(r <= t){
        decision = 0;
       }else{
        decision = 1;
}
}
return decision;}
//-------------end functions-----------

   // void
  //  howto_detect_ff_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
   // {
    //    /* <+forecast+> e.g. ninput_items_required[0] = noutput_items */
  //  }

    int
    howto_detect_ff_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 float *in = (const float *) input_items[0];
        float *out = (float *) output_items[0];
        float vett [d_samples];
        int lenght = floor(d_samples / d_L) * d_L;
        int p, j, k;
        float thr, lmax, lmin, ratio, TW;
        // char c[1];
        gsl_matrix * hankel = gsl_matrix_alloc (lenght,d_L);
        gsl_matrix * V = gsl_matrix_alloc (d_L,d_L);
        gsl_vector * S = gsl_vector_alloc (d_L);
        gsl_vector * temp = gsl_vector_alloc (d_ L);
        FILE *story;
        k=0; ratio = -1;
        gsl_matrix_set_zero (hankel);
        TW = TracyWidom (d_pfa);
        thr = gamma(lenght, d_L, TW);
	for (int i = 0; i < noutput_items; i++){
         vett[k]=in[i];
         k++;

         if (k >= lenght){
            k = 0;
            story = fopen("filestory.txt", "a");
            for( p=0; p<lenght; p++ ){
                for( j=0; j<d_L; j++ ){
                    gsl_matrix_set (hankel, p, j, vett[p+j]);
}
}
                gsl_linalg_SV_decomp (hankel, V, S, temp);
                lmax = gsl_vector_get(S, 0);
                lmin = gsl_vector_get(S, (d_L -1));
                ratio = lmax/lmin;
                mem = test(ratio, thr);
                fprintf(story, "%f - ratio=%f - soglia=%f\n ", mem, ratio, thr);
                fclose(story);
}
                out[i] = mem;
}
        // Do <+signal processing+>
        // Tell runtime system how many input items we consumed on
        // each input stream.
        consume_each (noutput_items);

        // Tell runtime system how many output items we produced.
        return noutput_items;
    }

  } /* namespace howto */
} /* namespace gr */

/* -*- c++ -*- */
/* 
 * Copyright 2015 <+YOU OR YOUR COMPANY+>.
 * 
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */

#ifndef INCLUDED_HOWTO_HOWTO_DETECT_FF_IMPL_H
#define INCLUDED_HOWTO_HOWTO_DETECT_FF_IMPL_H

#include <howto/howto_detect_ff.h>

namespace gr {
  namespace howto {

    class howto_detect_ff_impl;
     typedef boost::shared_ptr<howto_detect_ff_impl> howto_detect_ff_impl_sptr;
    howto_detect_ff_impl_sptr howto_make_detect_ff_impl (float pfa, int L, int samples);
    class howto_detect_ff_impl : public howto_detect_ff
    {
     private:
      // Nothing to declare in this block.
     friend howto_detect_ff_impl_sptr howto_make_detect_ff_impl (float pfa, int L, int samples);
     howto_detect_ff_impl (float pfa, int L, int samples);
     float d_pfa; int d_L; int d_samples;
     public:
      howto_detect_ff_impl();
      ~howto_detect_ff_impl();

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

      void set_pfa(float input_a) { d_pfa = input_a; }
      int get_pfa() { return d_pfa; }
      void set_L(int input_b) { d_L = input_b; }
      int get_L() { return d_L; }
      void set_samples(int input_c) { d_samples = input_c; }
      int get_samples() { return d_samples; }


      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 howto
} // namespace gr

#endif /* INCLUDED_HOWTO_HOWTO_DETECT_FF_IMPL_H */

/* -*- c++ -*- */
/* 
 * Copyright 2015 <+YOU OR YOUR COMPANY+>.
 * 
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */


#ifndef INCLUDED_HOWTO_HOWTO_DETECT_FF_H
#define INCLUDED_HOWTO_HOWTO_DETECT_FF_H

#include <howto/api.h>
#include <gnuradio/block.h>

namespace gr {
  namespace howto {

    /*!
     * \brief <+description of block+>
     * \ingroup howto
     *
     */
    class HOWTO_API howto_detect_ff : virtual public gr::block
    {
     public:
      typedef boost::shared_ptr<howto_detect_ff> sptr;

      /*!
       * \brief Return a shared_ptr to a new instance of howto::howto_detect_ff.
       *
       * To avoid accidental use of raw pointers, howto::howto_detect_ff's
       * constructor is in a private implementation
       * class. howto::howto_detect_ff::make is the public interface for
       * creating new instances.
       */
      static sptr make();
    };

  } // namespace howto
} // namespace gr

#endif /* INCLUDED_HOWTO_HOWTO_DETECT_FF_H */

Attachment: howto_swig.i
Description: howto_swig.i

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

Reply via email to