阻止 GNU Radio Python 块阻止

问题描述

我正在 GNU Radio Companion 中创建一个基本的 Python 块,它以所需的速率发送指定数量的 PDU 消息。我将使用这个块来测试我正在构建的流程图。

该块运行良好,但在发送完所有消息之前会阻塞/挂起。我想实现一些代码来在 GRC 流图停止时使块停止。

我已经实现了一些代码来在收到信号时停止发送线程,效果很好(我通过手动将 self.stop_thread 设置为 True 进行了测试。但是我无法弄清楚使用 GRC / GR 发送这个信号。

我的代码结构如下所示。如何在 GRC / GR 中触发 stop() 函数

class SendMessages(threading.Thread):

    def __init__(self,num_messages,send_msg_cb,msg_per_second,stop_thread):
        # Inherit all the parameters passed to __init__
        super().__init__()
        ...
        self.stop_thread = stop_thread

    def run(self):
        print(f'Sending {self.num_messages} messages')
        
        if self.stop_thread():
            print(f'Stopping thread')
            break
        ...

class blk(gr.basic_block): 
    def __init__(......):
        ...
        # start SendMessages thread and send self.stop_thread to the new thread with a value of False

    # This function never gets called :(
    def stop(self):
        print(f'Stopping block')
        self.stop_thread = True
        return True

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...