make_parser¶
- baseband.base.header.make_parser(word_index, bit_index, bit_length, default=None)[source] [edit on github]¶
Construct a function that converts specific bits from a header.
The function acts on a tuple/array of 32-bit words, extracting given bits from a specific word and convert them to bool (for single bit) or integer.
The parameters are those that define header keywords, and all parsers do
(words[word_index] >> bit_index) & ((1 << bit_length) - 1)
, except that that they have been optimized for the specific cases of single bits, full words, and items starting at bit 0. As a special case, bit_length=64 allows one to extract two words as a single (long) integer.- Parameters:
- word_indexint
Index into the tuple of words passed to the function.
- bit_indexint
Index to the starting bit of the part to be extracted.
- bit_lengthint
Number of bits to be extracted.
- Returns:
- parserfunction
To be used as
parser(words)
.