Relative Path to Files in GNU Radio Companion

1.4k views Asked by At

When I try to use a relative path within GNU Radio (e.g. for a sink or source block), it errors out with "can't open file".

The assumption is that the path is relative to the location of the .grc file location.

When a python file is generated by GRC, running that file on the command line produces the desired result. It just doesn't work through the GNU Radio Companion interface.

1

There are 1 answers

0
Aaron Swan On BEST ANSWER

GNU Radio Companion (GRC) paths are relative to where GRC is started.

If the script is intended to be run from its containing directory, a "Python Module" block can be added to GRC with the contents:

import os

script_path = os.path.dirname(os.path.realpath(__file__))
os.chdir(script_path)