GRC 3.7.2.1的.bin到.cfile流程图

2024-05-29 04:54:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试打开流图来隐藏.bin文件(数据 通过RTL-SDR捕获到.cfile进行分析。我从 链接http://sdr.osmocom.org/trac/attachment/wiki/rtl-sd。。。在

但是,我无法让它在grc3.7.2.1上运行。当我试图打开文件时,我会得到一长串错误消息(如下所示)。在

我使用的是ubuntuv14.04.1。在

如果有人帮我解决这个问题,或者用其他方法把.bin文件转换成.cfile(python源代码?)在

=======================================================
 <<< Welcome to GNU Radio Companion 3.7.2.1 >>>

Showing: ""

Loading: "/home/zorro/Downloads/rtl2832-cfile.grc"
Error:
/home/zorro/Downloads/rtl2832-cfile.grc:2:0:ERROR:VALID:DTD_UNKNOWN_ELEM:
No declaration for element html
/home/zorro/Downloads/rtl2832-cfile.grc:2:0:ERROR:VALID:DTD_UNKNOWN_ATTRIBUTE:
No declaration for attribute xmlns of element html
/home/zorro/Downloads/rtl2832-cfile.grc:9:0:ERROR:VALID:DTD_UNKNOWN_ELEM:
No declaration for element head
/home/zorro/Downloads/rtl2832-cfile.grc:10:0:ERROR:VALID:DTD_UNKNOWN_ELEM:

Tags: 文件nohomefordownloadserrorunknowndtd
2条回答

您看到的错误的原因是您的链接不正确-它被截断并指向HTML页面,而不是GRC文件。错误来自GRC试图将HTML解释为grcxml。下载的正确链接是:http://sdr.osmocom.org/trac/raw-attachment/wiki/rtl-sdr/rtl2832-cfile.grc

但是,请注意,该流程图是为GNU Radio 3.6构建的,由于许多块在内部被重命名,因此它在GNU Radio 3.7中不起作用。我建议使用提供的图片从头开始重建它。在

由于此流图中没有变量,您可以简单地拖出块并设置参数,如图所示。这样做对于熟悉GNU Radio Companion用户界面也是一个很好的练习。在

如果你看看上面@Kevin Reid发布的流程图,你可以看到它接受输入数据,减去127,乘以0.008,并将对转换为复数。在

缺少的是准确的类型。它在the GNU Radio FAQ中。从那里我们了解到uchar是一个无符号字符(8位),复杂数据类型是python中的“complex64”。在

如果在numpy中执行,作为内存操作,它看起来如下:

import numpy as np
import sys

(scriptName, inFileName, outFileName) = sys.argv;

ubytes = np.fromfile(inFileName, dtype='uint8', count=-1)

# we need an even number of bytes
# discard last byte if the count is odd

if len(ubytes)%2==1:
    ubytes = ubytes[0:-1]

print "read "+str(len(ubytes))+" bytes from "+inFileName

# scale the unsigned byte data to become a float in the interval 0.0 to 1.0

ufloats = 0.008*(ubytes.astype(float)-127.0)

ufloats.shape = (len(ubytes)/2, 2)

# turn the pairs of floats into complex numbers, needed by gqrx and other gnuradio software

IQ_data = (ufloats[:,0]+1j*ufloats[:,1]).astype('complex64')

IQ_data.tofile(outFileName)

我已经测试了从rtl\u sdr文件格式到gqrx IQ示例输入文件格式的转换,它似乎在内存中可以很好地工作。在

但请注意,此脚本只适用于输入和输出文件都可以放入内存的数据。对于大于系统内存1/5的输入文件(sdr记录很容易超过这个值),最好一次读取一个字节。在

我们可以通过循环一次读取1个字节的数据来避免内存占用,就像下面gnu C中的程序一样。这不是最干净的代码,我可能应该添加fclose并检查ferror,但出于爱好,它的工作原理是一样的。在

^{pr2}$

相关问题 更多 >

    热门问题