我尝试打开流图,将.bin文件(通过RTL捕获的数据)转换到.cfile进行分析。我从链接http://sdr.osmocom.org/trac/attachment/wiki/rtl-sd下载了这个文件..。
但是,我无法让它在GRC 3.7.2.1上工作。当我试图打开文件时,我会得到一长串错误消息(如下所示)。
我正在使用Ubuntu v14.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:发布于 2014-09-04 01:25:52
您所看到的错误的原因是您的链接是错误的-它被截断并指向HTML页面,而不是GRC文件。这些错误来自于GRC试图将HTML解释为GRC XML。下载的正确链接是:http://sdr.osmocom.org/trac/raw-attachment/wiki/rtl-sdr/rtl2832-cfile.grc
但是,请注意,该流程图是为GNU Radio 3.6构建的,由于许多块在内部重命名,因此无法在GNU Radio 3.7中工作。我建议使用提供的图片从头开始重建它。

因为这个流图中没有变量,所以您可以简单地拖动这些块并设置参数,如下所示。这样做也将是一个很好的练习,让你自己熟悉GNU无线电公司的用户界面。
发布于 2014-10-14 08:29:45
如果您查看上面@Kevin发布的流程图,您可以看到它接受输入数据,减去127,乘以0.008,并将对转换为复数。
缺少的是确切的类型。它在GNU无线电常见问题里。从这里我们了解到,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_sdr文件格式到gqrx样例输入文件格式的转换,它似乎在内存中可以很好地工作。
但请注意,此脚本仅适用于输入和输出文件都可以存储在内存中的数据。如果输入文件大于系统内存的1/5,sdr记录很容易超过该文件,最好一次读取一个字节。
我们可以通过使用循环一次读取数据1字节来避免占用内存,就像下面在gnu C中的程序一样,这不是最干净的代码,我可能应该添加fclose和check ferror,但它的工作方式是出于业余爱好。
#include <complex.h>
#include <stdio.h>
#include <stdlib.h>
// rtlsdr-to-gqrx Copyright 2014 Paul Brewer KI6CQ
// License: CC BY-SA 3.0 or GNU GPL 3.0
// IQ file converter
// from rtl_sdr recording format -- interleaved unsigned char
// to gqrx/gnuradio .cfile playback format -- complex64
void main(int argc, char *argv[])
{
int byte1, byte2; // int -- not unsigned char -- see fgetc man page
float _Complex fc;
const size_t fc_size = sizeof(fc);
FILE *infile,*outfile;
const float scale = 1.0/128.0;
const char *infilename = argv[1];
const char *outfilename = argv[2];
if (argc<3){
printf("usage: rtlsdr-to-gqrx infile outfile\n");
exit(1);
}
// printf("in= %s out= %s \n", infilename, outfilename);
infile=fopen(infilename,"rb");
outfile=fopen(outfilename,"wb");
if ((infile==NULL) || (outfile==NULL)){
printf("Error opening files\n");
exit(1);
}
while ((byte1=fgetc(infile)) != EOF){
if ((byte2=fgetc(infile)) == EOF){
exit(0);
}
fc = scale*(byte1-127) + I*scale*(byte2-127);
fwrite(&fc,fc_size,1,outfile);
}
}https://stackoverflow.com/questions/25587959
复制相似问题