GNU Radio C++ API Reference: gr::digital::header_format_crc Class Reference

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
gr::digital::header_format_crc Class Reference
GNU Radio C++ Signal Processing Blocks » Packet/Frame Operators

Header formatter that includes the payload length, packet number, and a CRC check on the header. More...

`#include <gnuradio/digital/header_format_crc.h>`

## Public Types
typedef std::shared_ptr< header_format_crc > | sptr
Public Types inherited from gr::digital::header_format_base
typedef std::shared_ptr< header_format_base > | sptr

## Public Member Functions
| header_format_crc (const std::string &len_key_name="packet_len", const std::string &num_key_name="packet_num")
| ~header_format_crc () override
void | set_header_num (unsigned header_num)
bool | format (int nbytes_in, const unsigned char *input, pmt::pmt_t &output, pmt::pmt_t &info) override
| Encodes the header information in the given tags into bits and places them into `out`.
bool | parse (int nbits_in, const unsigned char *input, std::vector< pmt::pmt_t > &info, int &nbits_processed) override
size_t | header_nbits () const override
Public Member Functions inherited from gr::digital::header_format_base
| header_format_base ()
virtual | ~header_format_base ()
sptr | base ()
sptr | formatter ()
size_t | header_nbytes () const

## Static Public Member Functions
static sptr | make (const std::string &len_key_name="packet_len", const std::string &num_key_name="packet_num")

## Protected Member Functions
bool | header_ok () override
| Verify that the header is valid.
int | header_payload () override
Protected Member Functions inherited from gr::digital::header_format_base
virtual void | enter_search ()
| Enter Search state of the state machine to find the access code.
virtual void | enter_have_sync ()
| Access code found, start getting the header.
virtual void | enter_have_header (int payload_len)
| Header found, setup for pulling in the hard decision bits.

## Protected Attributes
uint16_t | d_header_number
pmt::pmt_t | d_len_key_name
pmt::pmt_t | d_num_key_name
crc | d_crc_impl
Protected Attributes inherited from gr::digital::header_format_base
state_t | d_state
| state of the state machine
header_buffer | d_hdr_reg
| header_buffer object to hold header bits
pmt::pmt_t | d_info
| info captured from the header
gr::logger_ptr | d_logger
gr::logger_ptr | d_debug_logger

## Additional Inherited Members
Protected Types inherited from gr::digital::header_format_base
enum | state_t { STATE_SYNC_SEARCH , STATE_HAVE_SYNC }

## Detailed Description

Header formatter that includes the payload length, packet number, and a CRC check on the header.

Child class of header_format_base. This version's header format looks like:

- length (12 bits): length of the payload
- number (12 bits): packet number
- CRC8 (8 bits): A CRC8 check on the header contents

Instead of duplicating the payload length, we only add it once and use the CRC8 to make sure it's correctly received.

      |  0 -- 11 | 12 -- 23 | 24 -- 31 |
      |    len   | pkt len  |   CRC8   |

Reimplements packet_header_default in the style of the header_format_base.

## Member Typedef Documentation

## ◆ sptr

typedef std::shared_ptr<header_format_crc> gr::digital::header_format_crc::sptr

## Constructor & Destructor Documentation

## ◆ header_format_crc()

gr::digital::header_format_crc::header_format_crc | ( | const std::string & | len_key_name = "packet_len",
|  | const std::string & | num_key_name = "packet_num" )

## ◆ ~header_format_crc()

gr::digital::header_format_crc::~header_format_crc | ( |  | ) |
| override

## Member Function Documentation

## ◆ format()

bool gr::digital::header_format_crc::format | ( | int | nbytes_in,
|  | const unsigned char * | input,
|  | pmt::pmt_t & | output,
|  | pmt::pmt_t & | info )
| overridevirtual

Encodes the header information in the given tags into bits and places them into `out`.

Uses the following header format:

- Bits 0-11: The packet length (what was stored in the tag with key `len_tag_key`)
- Bits 12-23: The header number (counts up every time this function is called)
- Bit 24-31: 8-Bit CRC

Implements gr::digital::header_format_base.

Reimplemented in gr::digital::header_format_ofdm.

## ◆ header_nbits()

size_t gr::digital::header_format_crc::header_nbits | ( |  | ) | const
| overridevirtual

Returns the length of the formatted header in bits.

Implements gr::digital::header_format_base.

Reimplemented in gr::digital::header_format_ofdm.

## ◆ header_ok()

bool gr::digital::header_format_crc::header_ok | ( |  | ) |
| overrideprotectedvirtual

Verify that the header is valid.

Implements gr::digital::header_format_base.

## ◆ header_payload()

int gr::digital::header_format_crc::header_payload | ( |  | ) |
| overrideprotectedvirtual

Get info from the header; return payload length and package rest of data in d_info dictionary.

Implements gr::digital::header_format_base.

Reimplemented in gr::digital::header_format_ofdm.

## ◆ make()

sptr gr::digital::header_format_crc::make | ( | const std::string & | len_key_name = "packet_len",
|  | const std::string & | num_key_name = "packet_num" )
| static

Factory to create an async packet header formatter; returns an sptr to the object.

## ◆ parse()

bool gr::digital::header_format_crc::parse | ( | int | nbits_in,
|  | const unsigned char * | input,
|  | std::vector< pmt::pmt_t > & | info,
|  | int & | nbits_processed )
| overridevirtual

Parses a header. This function is overloaded in the child class, which knows how to convert the incoming hard bits (0's and 1's) back into a packet header.

Parameters

  nbits_in | The number of bits in the input array.
  input | The input as hard decision bits.
  info | A vector of pmt::dicts to hold any meta data or info about the PDU. When parsing the header, the formatter can add info from the header into this dict. Each packet has a single PMT dictionary of info, so the vector length is the number of packets received extracted during one call to this parser function.
  nbits_processed | Number of input bits actually processed; If all goes well, this is nbits_in. A premature return after a bad header could be less than this.

MUST be overloaded.

Implements gr::digital::header_format_base.

Reimplemented in gr::digital::header_format_ofdm.

## ◆ set_header_num()

void gr::digital::header_format_crc::set_header_num | ( | unsigned | header_num | ) |
| inline

References d_header_number.

## Member Data Documentation

## ◆ d_crc_impl

crc gr::digital::header_format_crc::d_crc_impl
| protected

## ◆ d_header_number

uint16_t gr::digital::header_format_crc::d_header_number
| protected

Referenced by set_header_num().

## ◆ d_len_key_name

pmt::pmt_t gr::digital::header_format_crc::d_len_key_name
| protected

## ◆ d_num_key_name

pmt::pmt_t gr::digital::header_format_crc::d_num_key_name
| protected

The documentation for this class was generated from the following file:

- header_format_crc.h