GNU Radio 3.6.5.1 C++ API
gr_ofdm_frame_sink2.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2007,2011 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
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)
10  * any later version.
11  *
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.
16  *
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.
21  */
22 
23 #ifndef INCLUDED_GR_OFDM_FRAME_SINK2_H
24 #define INCLUDED_GR_OFDM_FRAME_SINK2_H
25 
26 #include <gr_core_api.h>
27 #include <gr_sync_block.h>
28 #include <gr_msg_queue.h>
29 #include <gr_constellation.h>
30 
33 
35 gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell,
36  gr_msg_queue_sptr target_queue, unsigned int occupied_tones,
37  float phase_gain=0.25, float freq_gain=0.25*0.25/4.0);
38 
39 /*!
40  * \brief Takes an OFDM symbol in, demaps it into bits of 0's and 1's, packs
41  * them into packets, and sends to to a message queue sink.
42  *
43  * NOTE: The mod input parameter simply chooses a pre-defined demapper/slicer. Eventually,
44  * we want to be able to pass in a reference to an object to do the demapping and slicing
45  * for a given modulation type.
46  */
48 {
50  gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell,
51  gr_msg_queue_sptr target_queue, unsigned int occupied_tones,
52  float phase_gain, float freq_gain);
53 
54  private:
55  enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER};
56 
57  static const int MAX_PKT_LEN = 4096;
58  static const int HEADERBYTELEN = 4;
59 
60  gr_msg_queue_sptr d_target_queue; // where to send the packet when received
61  state_t d_state;
62  unsigned int d_header; // header bits
63  int d_headerbytelen_cnt; // how many so far
64 
65  unsigned char *d_bytes_out; // hold the current bytes produced by the demapper
66 
67  unsigned int d_occupied_carriers;
68  unsigned int d_byte_offset;
69  unsigned int d_partial_byte;
70 
71  unsigned char d_packet[MAX_PKT_LEN]; // assembled payload
72  int d_packetlen; // length of packet
73  int d_packet_whitener_offset; // offset into whitener string to use
74  int d_packetlen_cnt; // how many so far
75 
76  gr_complex * d_derotated_output; // Pointer to output stream to send deroated symbols out
77 
78  gr_constellation_sptr d_constell;
79  std::vector<gr_complex> d_dfe;
80  unsigned int d_nbits;
81 
82  unsigned char d_resid;
83  unsigned int d_nresid;
84  float d_phase;
85  float d_freq;
86  float d_phase_gain;
87  float d_freq_gain;
88  float d_eq_gain;
89 
90  std::vector<int> d_subcarrier_map;
91 
92  protected:
93  gr_ofdm_frame_sink2(gr_constellation_sptr constell,
94  gr_msg_queue_sptr target_queue, unsigned int occupied_tones,
95  float phase_gain, float freq_gain);
96 
97  void enter_search();
98  void enter_have_sync();
99  void enter_have_header();
100 
101  bool header_ok()
102  {
103  // confirm that two copies of header info are identical
104  return ((d_header >> 16) ^ (d_header & 0xffff)) == 0;
105  }
106 
107  unsigned char slicer(const gr_complex x);
108  unsigned int demapper(const gr_complex *in,
109  unsigned char *out);
110 
111  public:
113 
114  int work(int noutput_items,
115  gr_vector_const_void_star &input_items,
116  gr_vector_void_star &output_items);
117 };
118 
119 #endif /* INCLUDED_GR_OFDM_FRAME_SINK2_H */