3 * Copyright 2002 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.
23 #include <GrAtscBitTimingLoop3.h>
31 static const int NOUTPUTS = 2;
33 GrAtscBitTimingLoop3::GrAtscBitTimingLoop3 (double ratio_of_rx_clock_to_symbol_freq)
34 : VrDecimatingSigProc<float,float> (NOUTPUTS, (int) rint (ratio_of_rx_clock_to_symbol_freq)),
35 d_interp (ratio_of_rx_clock_to_symbol_freq), d_next_input(0),
36 d_rx_clock_to_symbol_freq (ratio_of_rx_clock_to_symbol_freq)
39 assert (ratio_of_rx_clock_to_symbol_freq >= 1.8); // sanity check
41 history = 1500; // spare input samples in case we need them.
45 // We are nominally a 2x decimator, but our actual rate varies slightly
46 // depending on the difference between the transmitter and receiver
47 // sampling clocks. Hence, we need to compute our input ranges
51 GrAtscBitTimingLoop3::forecast(VrSampleRange output,
52 VrSampleRange inputs[]) {
53 assert (numberInputs == 1);
55 /* dec:1 ratio with history */
56 inputs[0].index = d_next_input;
58 ((unsigned long) (output.size * d_rx_clock_to_symbol_freq) + history - 1);
65 GrAtscBitTimingLoop3::work (VrSampleRange output, void *ao[],
66 VrSampleRange inputs[], void *ai[])
68 iType *in = ((iType **)ai)[0];
69 oDataType *out_sample = ((oDataType **)ao)[0];
70 oTagType *out_tag = ((oTagType **) ao)[1];
72 // Force in-order computation of output stream.
73 // This is required because of our slightly variable decimation factor
76 // We are tasked with producing output.size output samples.
77 // We will consume approximately 2 * output.size input samples.
79 int si = 0; // source index
80 unsigned int k; // output index
84 double timing_adjustment = 0;
88 memset (&tag, 0, sizeof (tag));
90 for (k = 0; k < output.size; k++){
92 if (!d_interp.update (in, inputs[0].size, &si, timing_adjustment, &interp_sample)){
93 fprintf (stderr, "GrAtscBitTimingLoop3: ran short on data...\n");
97 d_sssr.update (interp_sample, &seg_locked, &symbol_index, &timing_adjustment);
98 out_sample[k] = interp_sample;
99 tag.valid = seg_locked;
100 tag.symbol_num = symbol_index;
104 d_next_input += si; // update next_input so forecast can get us what we need