GNU Radio 3.7.1 C++ API
|
Default header formatter for digital packet transmission. More...
#include <packet_header_default.h>
Public Types | |
typedef boost::shared_ptr < packet_header_default > | sptr |
Public Member Functions | |
packet_header_default (long header_len, const std::string &len_tag_key="packet_len", const std::string &num_tag_key="packet_num", int bits_per_byte=1) | |
~packet_header_default () | |
sptr | base () |
sptr | formatter () |
void | set_header_num (unsigned header_num) |
long | header_len () |
pmt::pmt_t | len_tag_key () |
virtual bool | header_formatter (long packet_len, unsigned char *out, const std::vector< tag_t > &tags=std::vector< tag_t >()) |
Encodes the header information in the given tags into bits and places them into out . | |
virtual bool | header_parser (const unsigned char *header, std::vector< tag_t > &tags) |
Inverse function to header_formatter(). | |
Static Public Member Functions | |
static sptr | make (long header_len, const std::string &len_tag_key="packet_len", const std::string &num_tag_key="packet_num", int bits_per_byte=1) |
Protected Attributes | |
long | d_header_len |
pmt::pmt_t | d_len_tag_key |
pmt::pmt_t | d_num_tag_key |
int | d_bits_per_byte |
unsigned | d_header_number |
unsigned | d_mask |
Default header formatter for digital packet transmission.
For bursty/packetized digital transmission, packets are usually prepended with a packet header, containing the number of bytes etc. This class is not a block, but a tool to create these packet header.
This is a default packet header (see header_formatter()) for a description on the header format). To create other header, derive packet header creator classes from this function.
gr::digital::packet_headergenerator_bb uses header generators derived from this class to create packet headers from data streams.
Reimplemented in gr::digital::packet_header_ofdm.
gr::digital::packet_header_default::packet_header_default | ( | long | header_len, |
const std::string & | len_tag_key = "packet_len" , |
||
const std::string & | num_tag_key = "packet_num" , |
||
int | bits_per_byte = 1 |
||
) |
sptr gr::digital::packet_header_default::base | ( | ) | [inline] |
sptr gr::digital::packet_header_default::formatter | ( | ) | [inline] |
virtual bool gr::digital::packet_header_default::header_formatter | ( | long | packet_len, |
unsigned char * | out, | ||
const std::vector< tag_t > & | tags = std::vector< tag_t >() |
||
) | [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-27: The header number (counts up everytime this function is called) Bit 28: Even parity bit All other bits: Are set to zero
If the header length is smaller than 29, bits are simply left out. For this reason, they always start with the LSB.
long gr::digital::packet_header_default::header_len | ( | ) | [inline] |
virtual bool gr::digital::packet_header_default::header_parser | ( | const unsigned char * | header, |
std::vector< tag_t > & | tags | ||
) | [virtual] |
Inverse function to header_formatter().
Reads the bit stream in header
and writes a corresponding tag into tags
.
Reimplemented in gr::digital::packet_header_ofdm.
static sptr gr::digital::packet_header_default::make | ( | long | header_len, |
const std::string & | len_tag_key = "packet_len" , |
||
const std::string & | num_tag_key = "packet_num" , |
||
int | bits_per_byte = 1 |
||
) | [static] |
void gr::digital::packet_header_default::set_header_num | ( | unsigned | header_num | ) | [inline] |
int gr::digital::packet_header_default::d_bits_per_byte [protected] |
long gr::digital::packet_header_default::d_header_len [protected] |
unsigned gr::digital::packet_header_default::d_header_number [protected] |
unsigned gr::digital::packet_header_default::d_mask [protected] |