Vector Source: Difference between revisions
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
: We can create tags as Python lists (or tuples) using the list structure [int offset, pmt key, pmt value, pmt srcid]. It is important to define the list/tuple with the values in the correct order and with the correct data type. A python dictionary can also be used using the keys: "offset", "key", "value", and "srcid" with the same data types as for the lists. | : We can create tags as Python lists (or tuples) using the list structure [int offset, pmt key, pmt value, pmt srcid]. It is important to define the list/tuple with the values in the correct order and with the correct data type. A python dictionary can also be used using the keys: "offset", "key", "value", and "srcid" with the same data types as for the lists. | ||
: When given a list of tags, the vector source will emit the tags repeatedly by updating the offset relative to the vector stream length. That is, if the vector has 500 items and a tag has an offset of 0, that tag will be placed on item 0, 500, 1000, 1500, etc. | : When given a list of tags, the vector source will emit the tags repeatedly by updating the offset relative to the vector stream length. That is, if the vector has 500 items and a tag has an offset of 0, that tag will be placed on item 0, 500, 1000, 1500, etc. | ||
In GnuRadio-Companion, make sure to define a "Tag Object" block. Your input to the "Tags" parameter will be a list of block ids, like seen below in the screenshots. | |||
; Repeat | ; Repeat | ||
Line 23: | Line 24: | ||
== Example Flowgraph == | == Example Flowgraph == | ||
In the following example, I (perhaps misguidedly) was using a 0 and a 1 output in a stream to control another block. | |||
[[File:Vector_source_with_tags.png]] | |||
[[File:Tag_object_block_properties_box.png]][[File:Vector_source_with_tags_properties_box.png]] | |||
== Source Files == | == Source Files == |
Revision as of 19:33, 8 June 2020
Source that streams items based on the input vector. This block produces a stream of samples based on an input vector. In C++, this is a std::vector<T>, and in Python, this is either a list or tuple. The data can repeat infinitely until the flowgraph is terminated by some other event or, the default, run the data once and stop.
The vector source can also produce stream tags with the data. Pass in a vector of gr::tag_t objects and they will be emitted based on the specified offset of the tag.
GNU Radio provides a utility Python module in gr.tag_utils to convert between tags and Python objects: gr.tag_utils.python_to_tag.
Parameters
(R): Run-time adjustable
- Vector (R)
- Vector to be generated
- Tags (R)
- We can create tags as Python lists (or tuples) using the list structure [int offset, pmt key, pmt value, pmt srcid]. It is important to define the list/tuple with the values in the correct order and with the correct data type. A python dictionary can also be used using the keys: "offset", "key", "value", and "srcid" with the same data types as for the lists.
- When given a list of tags, the vector source will emit the tags repeatedly by updating the offset relative to the vector stream length. That is, if the vector has 500 items and a tag has an offset of 0, that tag will be placed on item 0, 500, 1000, 1500, etc.
In GnuRadio-Companion, make sure to define a "Tag Object" block. Your input to the "Tags" parameter will be a list of block ids, like seen below in the screenshots.
- Repeat
- Whether or not to repeat the vector when it's done
- Vec Length
- Length of the output vector, i.e. if set to 1 then it will output just a normal stream.
Example Flowgraph
In the following example, I (perhaps misguidedly) was using a 0 and a 1 output in a stream to control another block.
Source Files
- C++ files
- TODO
- Header files
- TODO
- Public header files
- TODO
- Block definition
- TODO