[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Read/Write stream tags in Python
From: |
Josh Blum |
Subject: |
Re: [Discuss-gnuradio] Read/Write stream tags in Python |
Date: |
Fri, 13 Jul 2012 09:52:53 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 |
On 07/13/2012 08:51 AM, Anisha Gorur wrote:
> Hello all,
> I've been trying to work with stream tags in python, mainly using the
> grextras blocks coding guide
> here:https://github.com/guruofquality/grextras/wiki/Blo...
> <https://github.com/guruofquality/grextras/wiki/Blocks-Coding-Guide#wiki-the-work-function>.
>
> I've set up a very simple flow graph, just a vector source, throttle and
> file sink, and I would like to place a tag on the first element of the
> vector that contains time metadata. I'm using this code:
>
> def work(self, input_items, output_items):
> item_index = ? #which output item gets the tag?
set item_index to x so the tag gets associated with outputs_items[0][x]
> offset = self.nitems_written(0) + item_index
> key = pmt.pmt_string_to_symbol("example_key")
> value = pmt.pmt_string_to_symbol("example_value")
>
> #write at tag to output port 0 with given absolute item offset
> self.add_item_tag(0, offset, key, value)
>
> I think the problem has something to do with not implementing the
> correct modules. My question is, what are the appropriate modules to
> import to read and write stream tags in python?
>
You might want to look more that that coding guide, at lot of the
snippets are just work functions, but many contain full class
definitions with import statements. For example:
from gnuradio import gr
import gnuradio.extras
class my_sync_block(gr.block):
def __init__(self, args):
gr.block.__init__(self, name="my block", in_sig=[numpy.int32],
out_sig=[numpy.int32])
def work(self, input_items, output_items):
#work stuff...
return len(output_items[0])
-josh
- [Discuss-gnuradio] Read/Write stream tags in Python, Anisha Gorur, 2012/07/13
- Re: [Discuss-gnuradio] Read/Write stream tags in Python,
Josh Blum <=
- Re: [Discuss-gnuradio] Read/Write stream tags in Python, Anisha Gorur, 2012/07/13
- Re: [Discuss-gnuradio] Read/Write stream tags in Python, Josh Blum, 2012/07/13
- Re: [Discuss-gnuradio] Read/Write stream tags in Python, Anisha Gorur, 2012/07/13
- Re: [Discuss-gnuradio] Read/Write stream tags in Python, Josh Blum, 2012/07/13
- Re: [Discuss-gnuradio] Read/Write stream tags in Python, Anisha Gorur, 2012/07/13
- Re: [Discuss-gnuradio] Read/Write stream tags in Python, Anisha Gorur, 2012/07/13
- Re: [Discuss-gnuradio] Read/Write stream tags in Python, Josh Blum, 2012/07/13
- Re: [Discuss-gnuradio] Read/Write stream tags in Python, Anisha Gorur, 2012/07/16