discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Using gr_sync_decimator [was: How to use forecast


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] Using gr_sync_decimator [was: How to use forecast()?]
Date: Fri, 6 Aug 2010 19:36:57 -0700
User-agent: Mutt/1.5.20 (2009-08-17)

On Sat, Aug 07, 2010 at 01:07:20AM +0100, Samy Sammour wrote:
> 
> This is my block's constructor:
> 
> my_package::my_package(int num_input_ports, int L_samples)
> : gr_sync_decimator(
>        "package",
> 
>         gr_make_io_signature(2, 5, sizeof(gr_complex)),
> 
>         gr_make_io_signature(1, 1 , 
> num_input_ports*num_input_ports*sizeof(gr_complexd)),
> 
>         L_samples) {
> 
>  
>     // global variables
>     N=num_input_ports;
> 
>     vect_lengx=N*N;
> 
>     L=L_samples;
> 
>     set_decimation(L);    
> 
> }

This should probably be:

my_package::my_package(int num_input_ports, int L_samples)
  : gr_sync_decimator(
       "package",
        gr_make_io_signature(num_input_ports, num_input_ports, 
sizeof(gr_complex)),
        gr_make_io_signature(1, 1 , 
num_input_ports*num_input_ports*sizeof(gr_complexd)),
        L_samples) {


     // global variables
     N=num_input_ports;
 
     // Is this is the length of the output vector?
     vect_lengx=N*N;
 
     L=L_samples;
 
     // No need to call this.  You passed it to gr_sync_decimator's constructor
     //set_decimation(L);    
}

More below...

> > On Fri, Aug 06, 2010 at 06:32:32AM -0700, Sammour wrote:
> > > 
> > > Hi Eric,
> > > I have a similar issue as the one described above and I have read some of
> > > the examples in the directory provided but they seem to be different from
> > > what I want to implement. I want to collect L samples from N channels and
> > > store them in a buffer, do processing and output a vector of
> > length N.

N or N*N?  I'm assuming it's N*N given what you've said above.

> > > I wrote the following code but it doesn't seem to be working properly. 
> > > Some of
> > > them use loops from i=0 to noutput_items*vlen while others use from 0 to
> > > noutput_items. Also some of them don't use the function memcpy.
> > > 
> > > I am using gr_sync_decimator with set_decimation(L) is written in the 
> > > block
> > > constructor.
> > 


int my_package::work(.....)
{
  gr_complexd *out =(gr_complexd *) output_items[0];

  for (int i = 0; i <noutput_items; i++){
    gr_complex inbuffer[N][L];          // temp buffer for input matrix

    for(unsigned int k=0; k<N; k++)
      memcpy(&inbuffer[k][0],
             ((const gr_complex *)input_items[k])[i*L],
             L*sizeof(gr_complex));     //inbuffer is NxL matrix

    // Call signal processing code,
    // have it write N*N gr_complexd's directly into output buffer
    sig_proc(inbuffer, out);

    out += N*N;
  }

  return noutput_items;
}




reply via email to

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