YAML Config: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(revise flowgraph and example yml file)
(revise yml file)
Line 38: Line 38:
The <code>fsk_params.yml</code> file contains:
The <code>fsk_params.yml</code> file contains:
<pre>
<pre>
{
samp_rate: 48000
  "samp_rate": 48000,
baud: 1200
  "baud": 1200,
mark: 1200
  "mark": 1200,
space: 2200
  "space": 2200,
reverse: -1
  "reverse": -1,
thresh: 0
  "thresh": 0
}
</pre>
</pre>



Revision as of 14:00, 20 June 2023

This block represents a yaml config file that is read in as a dictionary.

The values can be used directly when instantiating blocks. For example,

   Sample Rate: yaml_config["samp_rate"]

Optionally, a JSON schema can be specified to validate the configuration. It may sound odd to use a json schema for a yaml file, but it works and jsonschema is a rich specification.

For example, you could have a YAML file that contains:

{
  "samp_rate": 1e6,
}

And a schema that contains

{
  "type": "object",
  "properties": {
    "samp_rate": {"type": "number", "exclusiveMinimum": 0}
   }
}

If the id of this block is yaml_config_0, then you can access the samp rate in other blocks as yaml_config_0["samp_rate"].

Parameters

Config File
File name of the YAML config file
Config Schema
(Optional) File name of the JSON schema file

Example Flowgraph

The fsk_params.yml file contains:

samp_rate: 48000
baud: 1200
mark: 1200
space: 2200
reverse: -1
thresh: 0

Yaml test fg.png

Source Files

Block definition
yaml_config.block.yml