Embedded Python Block: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[[Category:Block Docs]]
[[Category:Block Docs]]
Allows you to create a new (custom) block, in Python, without needing to make and install an Out of Tree Module (OOT).  The example block simply takes the input stream and multiplies it by a constant.   
Allows you to create a new (custom) block, in Python, without needing to make and install an Out of Tree Module (OOT).  The example block (pre-populated code when you add the block to your flowgraph) simply takes the input stream and multiplies it by a constant.  Note that the structure of this Python block matches the structure of an Out of Tree Module (OOT) Python block, it's essentially a Python OOT block built into a grc flowgraph.


For some platforms the open with Default Text Editor button may do nothing, in which case you have to manually choose the text editor.
For some platforms the open with Default Text Editor button may do nothing, in which case you have to manually choose the text editor.


When you update the Python code, as long as there are no errors the block will automatically update.  If you are adding new code and it seems like nothing is changing, there is probably an error in your code.
When you update the Python code, as long as there are no errors the block will automatically update.  If you are adding new code and it seems like nothing is changing, there is probably an error in your code.
Note that every parameter needs a default argument, due to the way your code gets parsed, and if you have a vector length equal to a variable, the default value must be "hardcoded". 


== Parameters ==
== Parameters ==

Revision as of 18:17, 16 September 2019

Allows you to create a new (custom) block, in Python, without needing to make and install an Out of Tree Module (OOT). The example block (pre-populated code when you add the block to your flowgraph) simply takes the input stream and multiplies it by a constant. Note that the structure of this Python block matches the structure of an Out of Tree Module (OOT) Python block, it's essentially a Python OOT block built into a grc flowgraph.

For some platforms the open with Default Text Editor button may do nothing, in which case you have to manually choose the text editor.

When you update the Python code, as long as there are no errors the block will automatically update. If you are adding new code and it seems like nothing is changing, there is probably an error in your code.

Note that every parameter needs a default argument, due to the way your code gets parsed, and if you have a vector length equal to a variable, the default value must be "hardcoded".

Parameters

You decide the parameters of your custom block =)

Example Flowgraph

Insert description of flowgraph here, then show a screenshot of the flowgraph and the output if there is an interesting GUI. Currently we have no standard method of uploading the actual flowgraph to the wiki or git repo, unfortunately. The plan is to have an example flowgraph showing how the block might be used, for every block, and the flowgraphs will live in the git repo.