gr-baz Package
pager_flex_sync.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 Free Software Foundation, Inc.
3  *
4  * This file is part of GNU Radio
5  *
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU Radio is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef INCLUDED_PAGER_FLEX_SYNC_H
23 #define INCLUDED_PAGER_FLEX_SYNC_H
24 
25 #include <pager_api.h>
26 #include <gr_block.h>
27 
28 class pager_flex_sync;
30 typedef std::vector<gr_int64> gr_int64_vector;
31 
33 
34 /*!
35  * \brief flex sync description
36  * \ingroup pager_blk
37  */
38 
40 {
41 private:
42  // Constructors
45 
46  // State machine transitions
47  void enter_idle();
48  void enter_syncing();
49  void enter_sync1();
50  void enter_sync2();
51  void enter_data();
52 
53  int index_avg(int start, int end);
54  bool test_sync(unsigned char sym);
55  void parse_fiw();
56  int output_symbol(unsigned char sym);
57 
58  // Simple state machine
59  enum state_t { ST_IDLE, ST_SYNCING, ST_SYNC1, ST_SYNC2, ST_DATA };
60  state_t d_state;
61 
62  int d_index; // Index into current baud
63  int d_start; // Start of good sync
64  int d_center; // Center of bit
65  int d_end; // End of good sync
66  int d_count; // Bit counter
67 
68  int d_mode; // Current packet mode
69  int d_baudrate; // Current decoding baud rate
70  int d_levels; // Current decoding levels
71  int d_spb; // Current samples per baud
72  bool d_hibit; // Alternating bit indicator for 3200 bps
73 
74  gr_int32 d_fiw; // Frame information word
75  int d_frame; // Current FLEX frame
76  int d_cycle; // Current FLEX cycle
77  int d_unknown1;
78  int d_unknown2;
79 
80  unsigned char d_bit_a;
81  unsigned char d_bit_b;
82  unsigned char d_bit_c;
83  unsigned char d_bit_d;
84 
85  unsigned char *d_phase_a;
86  unsigned char *d_phase_b;
87  unsigned char *d_phase_c;
88  unsigned char *d_phase_d;
89 
90  gr_int64_vector d_sync; // Trial synchronizers
91 
92 public:
93  void forecast(int noutput_items, gr_vector_int &inputs_required);
94 
95  int general_work(int noutput_items,
96  gr_vector_int &ninput_items,
97  gr_vector_const_void_star &input_items,
98  gr_vector_void_star &output_items);
99 };
100 
101 #endif /* INCLUDED_PAGER_FLEX_SYNC_H */