Professional Documents
Culture Documents
Stream Tags
Tom Rondeau
void
gr_block::add_item_tag( unsigned int which_output,
uint64_t offset,
const pmt::pmt_t &key,
const pmt::pmt_t &value,
const pmt::pmt_t &srcid )
Add Tags to Stream
Which output stream should the tag be sent to?
→ which_output,
What sample number is the tag associated with?
→ offset
What is a unique identifier for the tag?
→ key
What data, metedata, information, etc, is being sent?
→ value
What block created this tag?
→ srcid
Get Tags in Range
void
gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v,
unsigned int which_output,
uint64_t start,
uint64_t stop )
Get Tags in Range by Key
void
gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v,
unsigned int which_output,
uint64_t start,
uint64_t stop,
const pmt::pmt_t &key )
Propagation Policies
● Tags are put on a specific output stream but are
propagated downstream based on a policy
● TPP_ALL_TO_ALL (default)
● Tags on all inputs are copied to all outputs
● TPP_ONE_TO_ONE
● Tags on input i are copied only to output i
● Block must have num. inputs == num. Outputs
● TPP_DONT
● Don't copy tags; tag propagation stops
● Block may implement its own policy in work()
Propagation: All-to-All
Propagation: One-to-One
Tags Through Rate Changes
● All blocks have a relative_rate()
● gr_sync_block: 1.0
● gr_sync_decimator: 1.0/decim
● gr_sync_interpolator: (float)interp
● gr_block: must be set (defaults to 1.0)
Tags Through Rate Changes
● During tag propagation, tag offsets are updated
by rrate = relative_rate():
uint64_t newcount =
pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0));
pmt::pmt_t newtup =
pmt::mp(pmt::pmt_from_uint64(newcount * rrate),
pmt::pmt_tuple_ref(*t, 1),
pmt::pmt_tuple_ref(*t, 2),
pmt::pmt_tuple_ref(*t, 3));
Example: Burst Detector
● Found in gnuradio-examples/python/tags/
Options:
-h, --help show this help message and exit
-a , --address select address of the device
[default=addr=192.168.10.2]
-f, --freq set frequency to FREQ
-g, --gain set gain in dB [default=0]
-R, --samp-rate set USRP sample rate [default=200000]
-t, --threshold Set the detection power threshold (dBm)
[default=-60]
-T, --trigger Use internal trigger instead of detector
[default=False]
Example: Burst Detector
● Reads a stream from a UHD device
● Waits for a burst of energy over a specified
threshold (-60 dBm default)
● Saves burst to file
● When signal falls below threshold, stop saving
● When the threshold is crossed, a tag is
generated either to start or stop recording
● File sink reads tags for when to start
● Files are timestamped based on tag info
Burst Detector: Tag Structure
● Key: pmt::pmt_string_to_symbol(“burst”)
● Srcid: pmt::pmt_string_to_symbol(
strcat(name(), unique_id())
● Value:
● pmt::PMT_T (true) if start of tag
● Pmt::PMT_F (false) if end of tag
● Offset: sample number of start or end event
Burst Detector: Diagram