1

I get this error when I run GNU Radio Companion. Of course, the multi_rtl_source.block.yml block doesn't work and doesn't show up in the menu:

    ERROR:gnuradio.grc.core.platform:Error while loading /usr/local/share/gnuradio/grc/blocks/multi_rtl_source.block.yml
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/gnuradio/grc/core/platform.py", line 169, in build_library
    data = cache.get_or_load(file_path)
  File "/usr/lib/python3.8/site-packages/gnuradio/grc/core/cache.py", line 66, in get_or_load
    data = yaml.safe_load(fp)
  File "/usr/lib/python3.8/site-packages/yaml/__init__.py", line 162, in safe_load
    return load(stream, SafeLoader)
  File "/usr/lib/python3.8/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 111, in compose_sequence_node
    node.value.append(self.compose_node(node, index))
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/lib/python3.8/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib/python3.8/site-packages/yaml/parser.py", line 428, in parse_block_mapping_key
    if self.check_token(KeyToken):
  File "/usr/lib/python3.8/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/usr/lib/python3.8/site-packages/yaml/scanner.py", line 258, in fetch_more_tokens
    raise ScannerError("while scanning for the next token", None,
yaml.scanner.ScannerError: while scanning for the next token
found character '%' that cannot start any token
  in "/usr/local/share/gnuradio/grc/blocks/multi_rtl_source.block.yml", line 33, column 5
ERROR:gnuradio.grc.core.platform:while scanning for the next token
found character '%' that cannot start any token
  in "/usr/local/share/gnuradio/grc/blocks/multi_rtl_source.block.yml", line 33, column 5
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/gnuradio/grc/core/platform.py", line 169, in build_library
    data = cache.get_or_load(file_path)
  File "/usr/lib/python3.8/site-packages/gnuradio/grc/core/cache.py", line 66, in get_or_load
    data = yaml.safe_load(fp)
  File "/usr/lib/python3.8/site-packages/yaml/__init__.py", line 162, in safe_load
    return load(stream, SafeLoader)
  File "/usr/lib/python3.8/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 111, in compose_sequence_node
    node.value.append(self.compose_node(node, index))
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib/python3.8/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/lib/python3.8/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib/python3.8/site-packages/yaml/parser.py", line 428, in parse_block_mapping_key
    if self.check_token(KeyToken):
  File "/usr/lib/python3.8/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/usr/lib/python3.8/site-packages/yaml/scanner.py", line 258, in fetch_more_tokens
    raise ScannerError("while scanning for the next token", None,
yaml.scanner.ScannerError: while scanning for the next token
found character '%' that cannot start any token
  in "/usr/local/share/gnuradio/grc/blocks/multi_rtl_source.block.yml", line 33, column 5

I also get this:

>>> Check: /usr/local/share/gnuradio/grc/blocks/multi_rtl_source.block.yml
>>> FlowGraph Error: while scanning for the next token
found character '%' that cannot start any token
  in "/usr/local/share/gnuradio/grc/blocks/multi_rtl_source.block.yml", line 33, column 5

There is an YAML directive in line 33, column 5:

-   id: sync_gain0
    label: Ch0: Sync RF Gain (dB)
    category: Synchronization
    dtype: real
    default: 10
    hide: \\
    %if nchan() > n: <== line 33
part
    %else:
all
   %endif

full code of multi_rtl_source.block.yml can be found here

There is an article in the GNU Radio wiki in which it is written that you can place YAML dicrices in GRC blocks. So where this error came from and how to fix it?

yomol777
  • 463
  • 4
  • 16
  • Can you share all your modifications preferably in a github fork of the multi_rtl project? – Vasil Velichkov Apr 09 '20 at 17:33
  • @Vasil Velichkov I uploaded the project to github. I haven't changed anything in README and in the license, but I think I can do that if the project is under the GPL license. https://github.com/antoniprzybylik/multi-rtl – yomol777 Apr 09 '20 at 18:07
  • You should not change the license. Instead of creating a new repository it would be better to [fork](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) the original repository. This way your fork would be linked to the original repository, you can make changes in it and once you are satisfied you can create a [pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) to contribute your changes back. – Vasil Velichkov Apr 10 '20 at 16:21

1 Answers1

1
    hide: \\

In YAML the correct way to have multi-line string is using > or | specifiers (see https://yaml-multiline.info/) and not \\, for example

    hide: |

Alternatively you can write the hide condition on a single line like this

    hide: ${'part' if nchan > 0 else 'all'}

And here is how to fix it in gen_multi_rtl_block.py

@@ -104,57 +100,32 @@ template_p = """\
     category: Synchronization
     dtype: real
     default: 10
-    hide: &
-    ${"%"} if nchan() > n:
-part
-    ${"%"} else:
-all
-    ${"%"} endif
+    hide: ${'$'}{'part' if nchan > ${n} else 'all'}
Vasil Velichkov
  • 1,236
  • 11
  • 17