GNU Radio Manual and C++ API Reference  3.7.13.4
The Free & Open Software Radio Ecosystem
gr::digital::header_format_crc Class Reference

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 Member Functions

 header_format_crc (const std::string &len_key_name="packet_len", const std::string &num_key_name="packet_num")
 
virtual ~header_format_crc ()
 
void set_header_num (unsigned header_num)
 
virtual bool format (int nbytes_in, const unsigned char *input, pmt::pmt_t &output, pmt::pmt_t &info)
 Encodes the header information in the given tags into bits and places them into out. More...
 
virtual bool parse (int nbits_in, const unsigned char *input, std::vector< pmt::pmt_t > &info, int &nbits_processed)
 
virtual size_t header_nbits () 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 &len_key_name="packet_len", const std::string &num_key_name="packet_num")
 

Protected Member Functions

virtual bool header_ok ()
 Verify that the header is valid. More...
 
virtual int header_payload ()
 
- 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. More...
 
virtual void enter_have_sync ()
 Access code found, start getting the header. More...
 
virtual void enter_have_header (int payload_len)
 Header found, setup for pulling in the hard decision bits. More...
 

Protected Attributes

uint16_t d_header_number
 
pmt::pmt_t d_len_key_name
 
pmt::pmt_t d_num_key_name
 
boost::crc_optimal< 8, 0x07, 0xFF, 0x00, false, false > d_crc_impl
 
- Protected Attributes inherited from gr::digital::header_format_base
state_t d_state
 state of the state machine More...
 
header_buffer d_hdr_reg
 header_buffer object to hold header bits More...
 
pmt::pmt_t d_info
 info captured from the header More...
 
gr::logger_ptr d_logger
 
gr::logger_ptr d_debug_logger
 

Additional Inherited Members

- Public Types inherited from gr::digital::header_format_base
typedef boost::shared_ptr< header_format_basesptr
 
- 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.

Constructor & Destructor Documentation

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

Member Function Documentation

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

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 everytime this function is called)
  • Bit 24-31: 8-Bit CRC

Implements gr::digital::header_format_base.

Reimplemented in gr::digital::header_format_ofdm.

virtual size_t gr::digital::header_format_crc::header_nbits ( ) const
virtual

Returns the length of the formatted header in bits.

Implements gr::digital::header_format_base.

Reimplemented in gr::digital::header_format_ofdm.

virtual bool gr::digital::header_format_crc::header_ok ( )
protectedvirtual

Verify that the header is valid.

Implements gr::digital::header_format_base.

virtual int gr::digital::header_format_crc::header_payload ( )
protectedvirtual

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.

static 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.

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

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_inThe number of bits in the input array.
inputThe input as hard decision bits.
infoA 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_processedNumber 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.

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

Member Data Documentation

boost::crc_optimal<8, 0x07, 0xFF, 0x00, false, false> gr::digital::header_format_crc::d_crc_impl
protected
uint16_t gr::digital::header_format_crc::d_header_number
protected
pmt::pmt_t gr::digital::header_format_crc::d_len_key_name
protected
pmt::pmt_t gr::digital::header_format_crc::d_num_key_name
protected

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