GNU Radio 3.7.1 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2005,2012 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_GR_PACKET_SINK_H 00024 #define INCLUDED_GR_PACKET_SINK_H 00025 00026 #include <gnuradio/digital/api.h> 00027 #include <gnuradio/sync_block.h> 00028 #include <gnuradio/msg_queue.h> 00029 00030 namespace gr { 00031 namespace digital { 00032 00033 /*! 00034 * \brief process received bits looking for packet sync, header, 00035 * and process bits into packet 00036 * \ingroup packet_operators_blk 00037 * 00038 * \details 00039 * input: stream of symbols to be sliced. 00040 * 00041 * output: none. Pushes assembled packet into target queue 00042 * 00043 * The packet sink takes in a stream of binary symbols that are 00044 * sliced around 0. The bits are then checked for the \p 00045 * sync_vector to determine find and decode the packet. It then 00046 * expects a fixed length header of 2 16-bit shorts containing the 00047 * payload length, followed by the payload. If the 2 16-bit shorts 00048 * are not identical, this packet is ignored. Better algs are 00049 * welcome. 00050 * 00051 * This block is not very useful anymore as it only works with 00052 * 2-level modulations such as BPSK or GMSK. The block can 00053 * generally be replaced with a correlate access code and frame 00054 * sink blocks. 00055 */ 00056 class DIGITAL_API packet_sink : virtual public sync_block 00057 { 00058 public: 00059 // gr::digital::packet_sink::sptr 00060 typedef boost::shared_ptr<packet_sink> sptr; 00061 00062 /*! 00063 * Make a packet_sink block. 00064 * 00065 * \param sync_vector The synchronization vector as a vector of 1's and 0's. 00066 * \param target_queue The message queue that packets are sent to. 00067 * \param threshold Number of bits that can be incorrect in the \p sync_vector. 00068 */ 00069 static sptr make(const std::vector<unsigned char>& sync_vector, 00070 msg_queue::sptr target_queue, 00071 int threshold=-1); 00072 00073 //! return true if we detect carrier 00074 virtual bool carrier_sensed() const = 0; 00075 }; 00076 00077 } /* namespace digital */ 00078 } /* namespace gr */ 00079 00080 #endif /* INCLUDED_GR_PACKET_SINK_H */