GNU Radio 3.5.1 C++ API
pager_flex_sync.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006 Free Software Foundation, Inc.
00003  * 
00004  * This file is part of GNU Radio
00005  * 
00006  * GNU Radio is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 3, or (at your option)
00009  * any later version.
00010  * 
00011  * GNU Radio is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with GNU Radio; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street,
00019  * Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #ifndef INCLUDED_PAGER_FLEX_SYNC_H
00023 #define INCLUDED_PAGER_FLEX_SYNC_H
00024 
00025 #include <pager_api.h>
00026 #include <gr_block.h>
00027 
00028 class pager_flex_sync;
00029 typedef boost::shared_ptr<pager_flex_sync> pager_flex_sync_sptr;
00030 typedef std::vector<gr_int64> gr_int64_vector;
00031 
00032 PAGER_API pager_flex_sync_sptr pager_make_flex_sync();
00033 
00034 /*!
00035  * \brief flex sync description
00036  * \ingroup pager_blk
00037  */
00038 
00039 class PAGER_API pager_flex_sync : public gr_block
00040 {
00041 private:
00042     // Constructors
00043     friend PAGER_API pager_flex_sync_sptr pager_make_flex_sync();
00044     pager_flex_sync();
00045    
00046     // State machine transitions
00047     void enter_idle();
00048     void enter_syncing();
00049     void enter_sync1();
00050     void enter_sync2();
00051     void enter_data();
00052 
00053     int index_avg(int start, int end);
00054     bool test_sync(unsigned char sym);
00055     void parse_fiw();
00056     int output_symbol(unsigned char sym);    
00057     
00058     // Simple state machine
00059     enum state_t { ST_IDLE, ST_SYNCING, ST_SYNC1, ST_SYNC2, ST_DATA };
00060     state_t d_state;     
00061 
00062     int d_index;    // Index into current baud
00063     int d_start;    // Start of good sync 
00064     int d_center;   // Center of bit
00065     int d_end;      // End of good sync
00066     int d_count;    // Bit counter
00067 
00068     int d_mode;     // Current packet mode
00069     int d_baudrate; // Current decoding baud rate
00070     int d_levels;   // Current decoding levels
00071     int d_spb;      // Current samples per baud
00072     bool d_hibit;   // Alternating bit indicator for 3200 bps
00073     
00074     gr_int32 d_fiw; // Frame information word
00075     int d_frame;    // Current FLEX frame
00076     int d_cycle;    // Current FLEX cycle
00077     int d_unknown1;
00078     int d_unknown2;
00079 
00080     unsigned char d_bit_a;
00081     unsigned char d_bit_b;
00082     unsigned char d_bit_c;
00083     unsigned char d_bit_d;
00084     
00085     unsigned char *d_phase_a;  
00086     unsigned char *d_phase_b;
00087     unsigned char *d_phase_c;
00088     unsigned char *d_phase_d;
00089     
00090     gr_int64_vector d_sync; // Trial synchronizers
00091 
00092 public:
00093     void forecast(int noutput_items, gr_vector_int &inputs_required);
00094 
00095     int general_work(int noutput_items,
00096                      gr_vector_int &ninput_items,
00097                      gr_vector_const_void_star &input_items, 
00098                      gr_vector_void_star &output_items);
00099 };
00100 
00101 #endif /* INCLUDED_PAGER_FLEX_SYNC_H */