3 * Copyright 2004 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.
22 #ifndef INCLUDED_GR_CHECK_COUNTING_S_H
23 #define INCLUDED_GR_CHECK_COUNTING_S_H
25 #include <gr_sync_block.h>
27 class gr_check_counting_s;
28 typedef boost::shared_ptr<gr_check_counting_s> gr_check_counting_s_sptr;
30 gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=false);
33 * \brief sink that checks if its input stream consists of a counting sequence.
34 * \param do_32bit expect an interleaved 32 bit counter in stead of 16 bit counter (default false)
37 * This sink is typically used to test the USRP "Counting Mode" or "Counting mode 32 bit".
39 class gr_check_counting_s : public gr_sync_block
41 friend gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit);
44 SEARCHING, // searching for synchronization
49 unsigned int d_history; // bitmask of decisions
50 unsigned short d_current_count;
51 unsigned int d_current_count_32bit;
57 gr_check_counting_s (bool do_32bit);
59 void enter_SEARCHING ();
63 d_history = (d_history << 1) | 0x1;
67 d_history = (d_history << 1) | 0x0;
71 bool right_three_times () { return (d_history & 0x7) == 0x7; }
72 bool wrong_three_times () { return (d_history & 0x7) == 0x0; }
74 void log_error (unsigned short expected, unsigned short actual);
75 void log_error_32bit (unsigned int expected, unsigned int actual);
77 int check_32bit (int noutput_items, unsigned short * in);
78 int check_16bit (int noutput_items, unsigned short * in);
82 int work (int noutput_items,
83 gr_vector_const_void_star &input_items,
84 gr_vector_void_star &output_items);
88 #endif /* INCLUDED_GR_CHECK_COUNTING_S_H */