YAML Config

From GNU Radio
Revision as of 13:44, 20 June 2023 by Duggabe (talk | contribs) (revise flowgraph and example yml file)
Jump to navigation Jump to search

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