GNU Radio C++ API Reference: gr::digital::header_format_counter 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_counter Class Reference
GNU Radio C++ Signal Processing Blocks » Packet/Frame Operators

Header formatter that adds the payload bits/symbol format and a packet number counter. More...

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

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

## Public Member Functions
| header_format_counter (const std::string &access_code, int threshold, int bps)
| ~header_format_counter () override
bool | format (int nbytes_in, const unsigned char *input, pmt::pmt_t &output, pmt::pmt_t &info) override
size_t | header_nbits () const override
Public Member Functions inherited from gr::digital::header_format_default
| header_format_default (const std::string &access_code, int threshold, int bps)
| ~header_format_default () override
bool | format (int nbytes_in, const unsigned char *input, pmt::pmt_t &output, pmt::pmt_t &info) override
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
bool | set_access_code (const std::string &access_code)
unsigned long long | access_code () const
void | set_threshold (unsigned int thresh=0)
unsigned int | threshold () const
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 &access_code, int threshold, int bps)
Static Public Member Functions inherited from gr::digital::header_format_default
static sptr | make (const std::string &access_code, int threshold, int bps=1)

## 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_default
void | enter_have_sync () override
| Access code found, start getting the header.
void | enter_have_header (int payload_len) override
| Header found, setup for pulling in the hard decision bits.
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.

## Protected Attributes
uint16_t | d_counter
| keeps track of the number of packets transmitted
Protected Attributes inherited from gr::digital::header_format_default
uint64_t | d_access_code
| register to hold the access code
size_t | d_access_code_len
| length in bits of the access code
uint16_t | d_bps
| bits/sec of payload modulation
unsigned long long | d_data_reg
| used to look for access_code
unsigned long long | d_mask
unsigned int | d_threshold
| how many bits may be wrong in sync vector
int | d_pkt_len
| Length of the packet to put into the output buffer.
int | d_pkt_count
| Number of bytes bits already received.
int | d_nbits
| num bits processed since reset
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 adds the payload bits/symbol format and a packet number counter.

Child class of header_format_default. This version adds two fields to the header:

- bps (16 bits): bits/symbol used when modulating the payload.
- count (16 bits): a counter for the packet number.

Like the default packet formatter, the length is encoded as a 16-bit value repeated twice. The full packet looks like:

      | access code | hdr | payload |

Where the access code is <= 64 bits and hdr is:

      |  0 -- 15 | 16 -- 31 |
      | pkt len  | pkt len  |
      | bits/sym | counter  |

The access code and header are formatted for network byte order.

See also
  header_format_default

## Member Typedef Documentation

## ◆ sptr

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

## Constructor & Destructor Documentation

## ◆ header_format_counter()

gr::digital::header_format_counter::header_format_counter | ( | const std::string & | access_code,
|  | int | threshold,
|  | int | bps )

References gr::digital::header_format_default::access_code(), and gr::digital::header_format_default::threshold().

## ◆ ~header_format_counter()

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

## Member Function Documentation

## ◆ format()

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

Creates a header from the access code and packet length to build an output packet in the form:

      | access code | pkt len | pkt len | bps | counter |

Parameters

  nbytes_in | The length (in bytes) of the `input` payload
  input | An array of unsigned chars of the packet payload
  output | A pmt::u8vector with the new header prepended onto the input data.
  info | A pmt::dict containing meta data and info about the PDU (generally from the metadata portion of the input PDU). Data can be extracted from this for the header formatting or inserted.

Implements gr::digital::header_format_base.

## ◆ header_nbits()

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

Returns the length of the formatted header in bits.

Implements gr::digital::header_format_base.

## ◆ header_ok()

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

Verify that the header is valid.

Implements gr::digital::header_format_base.

## ◆ header_payload()

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

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

Extracts the header of the form:

      | access code | pkt len | pkt len | bps | counter | payload |

Implements gr::digital::header_format_base.

## ◆ make()

sptr gr::digital::header_format_counter::make | ( | const std::string & | access_code,
|  | int | threshold,
|  | int | bps )
| static

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

Parameters

  access_code | An access code that is used to find and synchronize the start of a packet. Used in the parser and in other blocks like a corr_est block that helps trigger the receiver. Can be up to 64-bits long.
  threshold | How many bits can be wrong in the access code and still count as correct.
  bps | The number of bits/second used in the payload's modulator.

References gr::digital::header_format_default::access_code(), and gr::digital::header_format_default::threshold().

## Member Data Documentation

## ◆ d_counter

uint16_t gr::digital::header_format_counter::d_counter
| protected

keeps track of the number of packets transmitted

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

- header_format_counter.h