root / gr-digital / include / digital_ofdm_frame_sink.h @ 60b3bd32
History | View | Annotate | Download (4.2 kB)
| 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_DIGITAL_OFDM_FRAME_SINK_H
|
| 24 | #define INCLUDED_DIGITAL_OFDM_FRAME_SINK_H
|
| 25 | |
| 26 | #include <gr_sync_block.h> |
| 27 | #include <gr_msg_queue.h> |
| 28 | |
| 29 | class digital_ofdm_frame_sink; |
| 30 | typedef boost::shared_ptr<digital_ofdm_frame_sink> digital_ofdm_frame_sink_sptr;
|
| 31 | |
| 32 | digital_ofdm_frame_sink_sptr |
| 33 | digital_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position,
|
| 34 | const std::vector<unsigned char> &sym_value_out, |
| 35 | gr_msg_queue_sptr target_queue, unsigned int occupied_tones, |
| 36 | float phase_gain=0.25, float freq_gain=0.25*0.25/4.0); |
| 37 | |
| 38 | /*!
|
| 39 | * \brief Takes an OFDM symbol in, demaps it into bits of 0's and 1's, packs |
| 40 | * them into packets, and sends to to a message queue sink. |
| 41 | * \ingroup sink_blk |
| 42 | * \ingroup ofdm_blk |
| 43 | * |
| 44 | * NOTE: The mod input parameter simply chooses a pre-defined demapper/slicer. Eventually, |
| 45 | * we want to be able to pass in a reference to an object to do the demapping and slicing |
| 46 | * for a given modulation type. |
| 47 | */ |
| 48 | class digital_ofdm_frame_sink : public gr_sync_block |
| 49 | {
|
| 50 | friend digital_ofdm_frame_sink_sptr |
| 51 | digital_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position,
|
| 52 | const std::vector<unsigned char> &sym_value_out, |
| 53 | gr_msg_queue_sptr target_queue, unsigned int occupied_tones, |
| 54 | float phase_gain, float freq_gain); |
| 55 | |
| 56 | private:
|
| 57 | enum state_t {STATE_SYNC_SEARCH, STATE_HAVE_SYNC, STATE_HAVE_HEADER};
|
| 58 | |
| 59 | static const int MAX_PKT_LEN = 4096; |
| 60 | static const int HEADERBYTELEN = 4; |
| 61 | |
| 62 | gr_msg_queue_sptr d_target_queue; // where to send the packet when received
|
| 63 | state_t d_state; |
| 64 | unsigned int d_header; // header bits |
| 65 | int d_headerbytelen_cnt; // how many so far |
| 66 | |
| 67 | unsigned char *d_bytes_out; // hold the current bytes produced by the demapper |
| 68 | |
| 69 | unsigned int d_occupied_carriers; |
| 70 | unsigned int d_byte_offset; |
| 71 | unsigned int d_partial_byte; |
| 72 | |
| 73 | unsigned char d_packet[MAX_PKT_LEN]; // assembled payload |
| 74 | int d_packetlen; // length of packet |
| 75 | int d_packet_whitener_offset; // offset into whitener string to use |
| 76 | int d_packetlen_cnt; // how many so far |
| 77 | |
| 78 | gr_complex * d_derotated_output; // Pointer to output stream to send deroated symbols out
|
| 79 | |
| 80 | std::vector<gr_complex> d_sym_position; |
| 81 | std::vector<unsigned char> d_sym_value_out; |
| 82 | std::vector<gr_complex> d_dfe; |
| 83 | unsigned int d_nbits; |
| 84 | |
| 85 | unsigned char d_resid; |
| 86 | unsigned int d_nresid; |
| 87 | float d_phase;
|
| 88 | float d_freq;
|
| 89 | float d_phase_gain;
|
| 90 | float d_freq_gain;
|
| 91 | float d_eq_gain;
|
| 92 | |
| 93 | std::vector<int> d_subcarrier_map;
|
| 94 | |
| 95 | protected:
|
| 96 | digital_ofdm_frame_sink(const std::vector<gr_complex> &sym_position,
|
| 97 | const std::vector<unsigned char> &sym_value_out, |
| 98 | gr_msg_queue_sptr target_queue, unsigned int occupied_tones, |
| 99 | float phase_gain, float freq_gain); |
| 100 | |
| 101 | void enter_search();
|
| 102 | void enter_have_sync();
|
| 103 | void enter_have_header();
|
| 104 | |
| 105 | bool header_ok()
|
| 106 | {
|
| 107 | // confirm that two copies of header info are identical
|
| 108 | return ((d_header >> 16) ^ (d_header & 0xffff)) == 0; |
| 109 | } |
| 110 | |
| 111 | unsigned char slicer(const gr_complex x); |
| 112 | unsigned int demapper(const gr_complex *in, |
| 113 | unsigned char *out); |
| 114 | |
| 115 | bool set_sym_value_out(const std::vector<gr_complex> &sym_position, |
| 116 | const std::vector<unsigned char> &sym_value_out); |
| 117 | |
| 118 | public:
|
| 119 | ~digital_ofdm_frame_sink(); |
| 120 | |
| 121 | int work(int noutput_items, |
| 122 | gr_vector_const_void_star &input_items, |
| 123 | gr_vector_void_star &output_items); |
| 124 | }; |
| 125 | |
| 126 | #endif /* INCLUDED_GR_OFDM_FRAME_SINK_H */ |