YAML GRC: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(Created page with "foo foo foo")
 
(Started writing about the parts of the YAML files)
Line 1: Line 1:
foo foo foo
Starting with release 3.8, XML replaces YAML as the file format for GNU Radio Companion. This is triggered by switching from Cheetah to Mako as the templating engine, since Cheetah does not support Python 3. Specifically, this will impact .grc files, block descriptions and block tree files. This article won’t focus on the .grc files, because they aren’t meant for manual editing.
 
The most notable change is of course the absence of XML’s angle brackets in favour of YAML’s colon-separated keys and values, and the change in file names for blocks. The latter is important for GRC to recognise the file. Namely, the “.xml” ending has been replaced with “.block.yml” for block descriptions and the underscore in block tree files has been replaced with a dot. (For example, “qtgui_tree.xml” becomes “qtgui.tree.yml”)
 
The content of the block descriptions is still the same, although it has been shuffled around a bit. The parts are elaborated below, in the order they should appear in the files.
 
== Block Descriptions ==
 
=== ID ===
 
<syntaxhighlight lang="python" line="line" highlight="1">
id: blocks_multiply_const_vxx
label: Multiply Const
 
parameters:
-  id: type
label: IO Type
(...)
</syntaxhighlight>
 
The ID is unique for each block and is used to identify it.
 
=== Label ===
 
<syntaxhighlight lang="python" line="line" highlight="2">
id: blocks_multiply_const_vxx
label: Multiply Const
 
parameters:
-  id: type
label: IO Type
(...)
</syntaxhighlight>
 
The label is simply the human-readable name of the block, and will be visible from within GRC. It will not appear in the generated code.
 
=== Flags (optional) ===
 
<syntaxhighlight lang="python" line="line" highlight="3">
id: blocks_throttle
label: Throttle
flags: throttle
 
parameters:
-  id: type
label: Type
(...)
</syntaxhighlight>
 
The flags indicate special attributes of the block. The only current example of this is the throttle flag, which is used in the Throttle and hardware blocks. For more information on throttling, see the Guided Tutorial: [https://wiki.gnuradio.org/index.php/Guided_Tutorial_GRC#2.4.3._A_Note_on_the_Throttle_Block]
 
=== Parameters ===
 
=== Inputs ===
 
=== Outputs ===
 
=== Asserts (optional) ===
 
<syntaxhighlight lang="python" line="line" highlight="4-5">
    dtype: ${ type }
    vlen: ${ vlen }
 
asserts:
- ${ vlen > 0 }
 
templates:
    imports: from gnuradio import blocks
make: blocks.throttle(${type.size}*${vlen}, ${samples_per_second},${ignoretag})
</syntaxhighlight>
 
Asserts (previously known as "checks" for the XML blocks) are expressions that ''need'' to be true, otherwise GRC won't let you generate the flowgraph.
 
=== Templates ===
 
==== Imports ====
 
==== Make ====
 
==== Callbacks ====
 
=== File Format ===
 
=== Others ===
 
==== Variable Make ====
 
==== Variable Value ====
 
== Block Tree Files ==

Revision as of 18:05, 23 July 2018

Starting with release 3.8, XML replaces YAML as the file format for GNU Radio Companion. This is triggered by switching from Cheetah to Mako as the templating engine, since Cheetah does not support Python 3. Specifically, this will impact .grc files, block descriptions and block tree files. This article won’t focus on the .grc files, because they aren’t meant for manual editing.

The most notable change is of course the absence of XML’s angle brackets in favour of YAML’s colon-separated keys and values, and the change in file names for blocks. The latter is important for GRC to recognise the file. Namely, the “.xml” ending has been replaced with “.block.yml” for block descriptions and the underscore in block tree files has been replaced with a dot. (For example, “qtgui_tree.xml” becomes “qtgui.tree.yml”)

The content of the block descriptions is still the same, although it has been shuffled around a bit. The parts are elaborated below, in the order they should appear in the files.

Block Descriptions

ID

id: blocks_multiply_const_vxx
label: Multiply Const

parameters:
-   id: type
label: IO Type
(...)

The ID is unique for each block and is used to identify it.

Label

id: blocks_multiply_const_vxx
label: Multiply Const

parameters:
-   id: type
label: IO Type
(...)

The label is simply the human-readable name of the block, and will be visible from within GRC. It will not appear in the generated code.

Flags (optional)

id: blocks_throttle
label: Throttle
flags: throttle

parameters:
-   id: type
label: Type
(...)

The flags indicate special attributes of the block. The only current example of this is the throttle flag, which is used in the Throttle and hardware blocks. For more information on throttling, see the Guided Tutorial: [1]

Parameters

Inputs

Outputs

Asserts (optional)

    dtype: ${ type }
    vlen: ${ vlen }

asserts:
- ${ vlen > 0 }

templates:
    imports: from gnuradio import blocks
make: blocks.throttle(${type.size}*${vlen}, ${samples_per_second},${ignoretag})

Asserts (previously known as "checks" for the XML blocks) are expressions that need to be true, otherwise GRC won't let you generate the flowgraph.

Templates

Imports

Make

Callbacks

File Format

Others

Variable Make

Variable Value

Block Tree Files