3 * Copyright 2007 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
27 #include <gr_ofdm_sampler.h>
28 #include <gr_io_signature.h>
32 gr_make_ofdm_sampler (unsigned int fft_length,
33 unsigned int symbol_length)
35 return gr_ofdm_sampler_sptr (new gr_ofdm_sampler (fft_length, symbol_length));
38 gr_ofdm_sampler::gr_ofdm_sampler (unsigned int fft_length,
39 unsigned int symbol_length)
40 : gr_block ("ofdm_sampler",
41 gr_make_io_signature2 (2, 2, sizeof (gr_complex), sizeof(char)),
42 gr_make_io_signature (1, 1, sizeof (gr_complex)*fft_length)),
43 d_fft_length(fft_length), d_symbol_length(symbol_length)
48 gr_ofdm_sampler::forecast (int noutput_items, gr_vector_int &ninput_items_required)
50 // FIXME do we need more
51 int nreqd = (noutput_items-1) * d_symbol_length + d_fft_length;
52 unsigned ninputs = ninput_items_required.size ();
53 for (unsigned i = 0; i < ninputs; i++)
54 ninput_items_required[i] = nreqd;
58 gr_ofdm_sampler::general_work (int noutput_items,
59 gr_vector_int &ninput_items,
60 gr_vector_const_void_star &input_items,
61 gr_vector_void_star &output_items)
63 gr_complex *iptr = (gr_complex *) input_items[0];
64 char *trigger = (char *) input_items[1];
66 gr_complex *optr = (gr_complex *) output_items[0];
72 while(!found && i<std::min(ninput_items[0],ninput_items[1]) )
79 assert(i-d_fft_length+1 >= 0);
80 for(int j=i-d_fft_length+1;j<=i;j++)
82 consume_each(i-d_fft_length+2);
83 //printf("OFDM Sampler found: ninput_items: %d/%d noutput_items: %d consumed: %d found: %d\n",
84 // ninput_items[0], ninput_items[1], noutput_items, (i-d_fft_length+2), found);
87 consume_each(i-d_fft_length+1);
88 //printf("OFDM Sampler not found: ninput_items: %d/%d noutput_items: %d consumed: %d found: %d\n",
89 // ninput_items[0], ninput_items[1], noutput_items, (i-d_fft_length+1), found);