GNU Radio Companion 中文件的相对路径

Relative Path to Files in GNU Radio Companion

当我尝试在 GNU Radio 中使用相对路径时(例如,对于接收器或源块),它会出错 "can't open file"。

假设路径是相对于 .grc 文件位置的位置。

当 GRC 生成 python 文件时,运行 该文件在命令行上生成所需的结果。它只是不能通过 GNU Radio Companion 界面工作。

GNU Radio Companion (GRC) 路径相对于 GRC 的启动位置。

如果脚本是 运行 来自其包含目录,可以将 "Python Module" 块添加到 GRC,内容为:

import os

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