GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
packet_sink.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2005,2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef INCLUDED_GR_PACKET_SINK_H
12 #define INCLUDED_GR_PACKET_SINK_H
13 
14 #include <gnuradio/digital/api.h>
15 #include <gnuradio/msg_queue.h>
16 #include <gnuradio/sync_block.h>
17 
18 namespace gr {
19 namespace digital {
20 
21 /*!
22  * \brief process received bits looking for packet sync, header,
23  * and process bits into packet
24  * \ingroup packet_operators_blk
25  *
26  * \details
27  * input: stream of symbols to be sliced.
28  *
29  * output: none. Pushes assembled packet into target queue
30  *
31  * The packet sink takes in a stream of binary symbols that are
32  * sliced around 0. The bits are then checked for the \p
33  * sync_vector to determine find and decode the packet. It then
34  * expects a fixed length header of 2 16-bit shorts containing the
35  * payload length, followed by the payload. If the 2 16-bit shorts
36  * are not identical, this packet is ignored. Better algs are
37  * welcome.
38  *
39  * This block is not very useful anymore as it only works with
40  * 2-level modulations such as BPSK or GMSK. The block can
41  * generally be replaced with a correlate access code and frame
42  * sink blocks.
43  */
44 class DIGITAL_API packet_sink : virtual public sync_block
45 {
46 public:
47  // gr::digital::packet_sink::sptr
48  typedef std::shared_ptr<packet_sink> sptr;
49 
50  /*!
51  * Make a packet_sink block.
52  *
53  * \param sync_vector The synchronization vector as a vector of 1's and 0's.
54  * \param target_queue The message queue that packets are sent to.
55  * \param threshold Number of bits that can be incorrect in the \p sync_vector.
56  */
57  static sptr make(const std::vector<unsigned char>& sync_vector,
58  msg_queue::sptr target_queue,
59  int threshold = -1);
60 
61  //! return true if we detect carrier
62  virtual bool carrier_sensed() const = 0;
63 };
64 
65 } /* namespace digital */
66 } /* namespace gr */
67 
68 #endif /* INCLUDED_GR_PACKET_SINK_H */
process received bits looking for packet sync, header, and process bits into packet
Definition: packet_sink.h:45
virtual bool carrier_sensed() const =0
return true if we detect carrier
std::shared_ptr< packet_sink > sptr
Definition: packet_sink.h:48
static sptr make(const std::vector< unsigned char > &sync_vector, msg_queue::sptr target_queue, int threshold=-1)
std::shared_ptr< msg_queue > sptr
Definition: msg_queue.h:35
synchronous 1:1 input to output with history
Definition: sync_block.h:26
#define DIGITAL_API
Definition: gr-digital/include/gnuradio/digital/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29