Editing Stream Tags

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 101: Line 101:
  add_item_tag(which_output, abs_offset, key, value, srcid)
  add_item_tag(which_output, abs_offset, key, value, srcid)


Note that the key and value are both PMTs.  To create a string type PMT you can use pmt.intern("example_key").
Note that the key and value are both PMTs.  To create a string type PMT you can use pmt.intern("example_key")
 
Consider the following flowgraph as an example. We will have an embedded python block insert stream tags at random intervals, and view these tags on the QT GUI Time sink.
 
[[File:Epy_stream_tags_example_flowchart.png|800px]]
 
Add the following code into the embedded python block. This code outputs the same signal as in the input, except with tags on randomly selected input samples:


Here is an example of a Python block that loops through samples and puts tags on random ones, and outputs the same signal:
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
  import numpy as np
  import numpy as np
Line 137: Line 132:
         return len(output_items[0])
         return len(output_items[0])
</syntaxhighlight>
</syntaxhighlight>
You may expect an output similar to the screenshot of the time sink below.
[[File:Epy_stream_tags_example_timesink.png|800px]]


=== Getting tags from a Stream ===
=== Getting tags from a Stream ===

Please note that all contributions to GNU Radio are considered to be released under the Creative Commons Attribution-ShareAlike (see GNU Radio:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)