我在 GNU Radio 中的流程图出现了一些问题。我构建了一个自定义块作为延迟块,因为本机块在我的应用程序中效果不佳。在我的自定义块之前有一个 UHD 源。它以 4M 的采样率工作。但是,当我开始模拟时,它会产生溢出(“O”)。我认为这很奇怪,因为当我将 UHD 源的输出保存在文件中,然后在“离线”模式下再次播放模拟时,不会出现溢出错误。换句话说,当我在“在线”模式下工作时,我遇到了问题。仅当我使用 UHD Source 而不是 UHD Source 之前保存的文件时。
Delay_amostra_sync 块代码:
导入 numpy
从 gnuradio 导入 gr
class Delay_amostra_sync(gr.sync_block): """ 块 Delay_amostra_sync 的文档字符串 """ def init (self, var): gr.sync_block。init (self, name="Delay_amostra_sync", in_sig=[numpy.complex64], out_sig=[numpy.complex64]) self.var = var self.cont = 0
self.buffer = numpy.array([])
self.c = 1
def work(self, input_items, output_items):
in0 = input_items[0]
out = output_items[0]
self.dados = numpy.array(input_items[0], copy=True)
self.buffer = numpy.append(self.buffer, self.dados)
if self.cont >= self.var:
out[:] = self.buffer[range(0,len(out))]
self.buffer = numpy.delete(self.buffer, range(0,len(out)), 0)
self.cont = self.cont + 1