GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
crc_check.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2022 Daniel Estevez <daniel@destevez.net>
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_DIGITAL_CRC_CHECK_H
12 #define INCLUDED_DIGITAL_CRC_CHECK_H
13 
14 #include <gnuradio/block.h>
15 #include <gnuradio/digital/api.h>
16 
17 #include <stdint.h>
18 
19 namespace gr {
20 namespace digital {
21 
22 /*!
23  * \brief Check the CRC at the end of a PDU
24  * \ingroup packet_operators_blk
25  *
26  * \details
27  * The CRC check block receives a PDU containing a CRC at its end,
28  * and checks whether the CRC is correct. The PDU is sent over the ok
29  * or fail output ports according to the result of this check.
30  * It can support any CRC whose size is a multiple of 8 bits between
31  * 8 and 64 bits.
32  */
33 class DIGITAL_API crc_check : virtual public block
34 {
35 public:
36  typedef std::shared_ptr<crc_check> sptr;
37 
38  /*!
39  * \brief Build the CRC check block.
40  *
41  * \param num_bits CRC size in bits (must be a multiple of 8)
42  * \param poly CRC polynomial, in MSB-first notation
43  * \param initial_value Initial register value
44  * \param final_xor Final XOR value
45  * \param input_reflected true if the input is LSB-first, false if not
46  * \param result_reflected true if the output is LSB-first, false if not
47  * \param swap_endianness true if the CRC is stored as little-endian in the PDU,
48  false if not
49  * \param discard_crc If true, the CRC is removed from the PDU before sending
50  it to the output port. If false, the CRC is preserved in the output PDU.
51  * \param skip_header_bytes gives the number of header byte to skip in the CRC
52  calculation
53  */
54  static sptr make(unsigned num_bits,
55  uint64_t poly,
56  uint64_t initial_value,
57  uint64_t final_xor,
58  bool input_reflected,
59  bool result_reflected,
60  bool swap_endianness,
61  bool discard_crc = false,
62  unsigned skip_header_bytes = 0);
63 };
64 
65 } // namespace digital
66 } // namespace gr
67 
68 #endif /* INCLUDED_DIGITAL_CRC_CHECK_H */
The abstract base class for all 'terminal' processing blocks.
Definition: gnuradio-runtime/include/gnuradio/block.h:63
Check the CRC at the end of a PDU.
Definition: crc_check.h:34
std::shared_ptr< crc_check > sptr
Definition: crc_check.h:36
static sptr make(unsigned num_bits, uint64_t poly, uint64_t initial_value, uint64_t final_xor, bool input_reflected, bool result_reflected, bool swap_endianness, bool discard_crc=false, unsigned skip_header_bytes=0)
Build the CRC check block.
#define DIGITAL_API
Definition: gr-digital/include/gnuradio/digital/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29