我正在尝试从添加 MPSK SNR Estimator 块的流标签中提取数据。该标签包含一个键和一个值。在代码中,尝试通过键过滤标签:'snr'。
我将自己的块添加到,但它不能正常工作。
我希望将我的 SNR 数据(SNR 值)写入文件(type->float32),但这并没有发生。相反,它以复杂的形式显示在控制台中。
,出于某种原因显示数据的地方。
import numpy as np
from gnuradio import gr
import pmt
class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block
"""Embedded Python Block example - a simple multiply const"""
def __init__(self): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.sync_block.__init__(
self,
name='Tag_Snr',
in_sig=[np.complex64],
out_sig=[np.float32]
# out_sig=None
)
# if an attribute with the same name as a parameter is found,
# a callback is registered (properties work, too).
def work(self, input_items, output_items):
tags = self.get_tags_in_window(0, 0, len(input(input_items[0])))
for tag in tags:
if tag.key == 'snr':
value = pmt.to_python(tag.value)
# print("value:", value, type(value))
output_items[0] = value
return len(output_items[0])