GNU Radio 3.7.1 C++ API
header_payload_demux.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /* Copyright 2012 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_DIGITAL_HEADER_PAYLOAD_DEMUX_H
00023 #define INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H
00024 
00025 #include <gnuradio/digital/api.h>
00026 #include <gnuradio/block.h>
00027 
00028 namespace gr {
00029   namespace digital {
00030 
00031     /*!
00032      * \brief Header/Payload demuxer.
00033      * \ingroup packet_operators_blk
00034      *
00035      * \details
00036      * This block is designed to handle packets from a bursty transmission.
00037      * Input 0 takes a continuous transmission of samples.
00038      * If used, input 1 is a trigger signal. In this case, a 1 on input 1
00039      * is a trigger. Otherwise, a tag with the key specified in \p trigger_tag_key
00040      * is used as a trigger (its value is irrelevant).
00041      *
00042      * Until a trigger signal is detected, all samples are dropped onto the floor.
00043      * Once a trigger is detected, a total of \p header_len items are copied to output 0.
00044      * The block then stalls until it receives a message on the message port
00045      * \p header_data. The message must be a PMT dictionary; all key/value pairs are
00046      * copied as tags to the first item of the payload (which is assumed to be the
00047      * first item after the header).
00048      * The value corresponding to the key specified in \p length_tag_key is read
00049      * and taken as the payload length. The payload, together with the header data
00050      * as tags, is then copied to output 1.
00051      *
00052      * If specified, \p guard_interval items are discarded before every symbol.
00053      * This is useful for demuxing bursts of OFDM signals.
00054      *
00055      * Any tags on the input stream are copied to the corresponding output *if* they're
00056      * on an item that is propagated. Note that a tag on the header items is copied to the
00057      * header stream; that means the header-parsing block must handle these tags if they
00058      * should go on the payload.
00059      * A special case are tags on items that make up the guard interval. These are copied
00060      * to the first item of the following symbol.
00061      */
00062     class DIGITAL_API header_payload_demux : virtual public block
00063     {
00064      public:
00065       typedef boost::shared_ptr<header_payload_demux> sptr;
00066 
00067       /*!
00068        * \param header_len Number of symbols per header
00069        * \param items_per_symbol Number of items per symbol
00070        * \param guard_interval Number of items between two consecutive symbols
00071        * \param length_tag_key Key of the frame length tag
00072        * \param trigger_tag_key Key of the trigger tag
00073        * \param output_symbols Output symbols (true) or items (false)?
00074        * \param itemsize Item size (bytes per item)
00075        */
00076       static sptr make(
00077         int header_len,
00078         int items_per_symbol,
00079         int guard_interval=0,
00080         const std::string &length_tag_key="frame_len",
00081         const std::string &trigger_tag_key="",
00082         bool output_symbols=false,
00083         size_t itemsize=sizeof(gr_complex)
00084       );
00085     };
00086 
00087   } // namespace digital
00088 } // namespace gr
00089 
00090 #endif /* INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H */
00091