GNU Radio 3.6.5.1 C++ API
header_payload_demux_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /* Copyright 2012 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_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H
23 #define INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H
24 
26 
27 namespace gr {
28  namespace digital {
29 
31  {
32  private:
33  int d_header_len; //!< Number of bytes per header
34  int d_items_per_symbol; //!< Bytes per symbol
35  int d_gi; //!< Bytes per guard interval
36  pmt::pmt_t d_len_tag_key; //!< Key of length tag
37  pmt::pmt_t d_trigger_tag_key; //!< Key of trigger tag (if used)
38  bool d_output_symbols; //!< If true, output is symbols, not items
39  size_t d_itemsize; //!< Bytes per item
40  bool d_uses_trigger_tag; //!< If a trigger tag is used
41  int d_ninput_items_reqd; //!< Helper for forecast()
42  int d_state; //!< Current read state
43  int d_remaining_symbols; //!< When in payload or header state, the number of symbols still to transmit
44 
45  // Helpers to make the state machine more readable
46 
47  //! Helper function that does the reading from the msg port
48  bool parse_header_data_msg();
49 
50  //! Helper function that returns true if a trigger signal is detected.
51  // Searches input 1 (if active), then the tags. Sets \p pos to the position
52  // of the first tag.
53  bool find_trigger_signal(
54  int &pos,
55  int noutput_items,
56  gr_vector_const_void_star &input_items);
57 
58  //! Helper function, copies one symbol from in to out and updates all pointers and counters
59  void copy_symbol(const unsigned char *&in, unsigned char *&out, int port, int &nread, int &nproduced);
60 
61  public:
62 
64  int header_len,
65  int items_per_symbol,
66  int guard_interval,
67  const std::string &length_tag_key,
68  const std::string &trigger_tag_key,
69  bool output_symbols,
70  size_t itemsize);
72 
73  void forecast (int noutput_items, gr_vector_int &ninput_items_required);
74 
75  int general_work(int noutput_items,
76  gr_vector_int &ninput_items,
77  gr_vector_const_void_star &input_items,
78  gr_vector_void_star &output_items);
79  };
80 
81  } // namespace digital
82 } // namespace gr
83 
84 #endif /* INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H */
85