如何编辑由Gnu Radio的文件接收器生成的文件? [英] How to edit the file generated by file sink of Gnu Radio?

查看:2239
本文介绍了如何编辑由Gnu Radio的文件接收器生成的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现由文件接收器块生成的文件是二进制格式,
,它不能由gedit在linux下编辑或者其他的东西,
所以我怎么编辑这个文件?



我发送一个包含hello world的dat文件,并且我想接收一个包含hello world的文件

解决方案

这经常被问到。所以这里有一个链接到FAQ 和摘录:


所有文件都是纯二进制格式。只是位。而已。一个浮点数据流被一个接一个地保存为32位。一个复杂的信号有32位的实部和32位的虚部。读回复数意味着读取32位数据,将其保存到复杂数据结构的实数部分,然后读取下一个32位作为数据结构的虚数部分。阅读数据。



查看 gr-utils 中的Octave和Python文件在数据中使用Octave和Python的Scipy模块。

格式的例外是使用元数据文件格式。这些文件由File Meta Sink生成: http://gnuradio.org/doc/doxygen/ classgr_1_1blocks_1_1file__meta__sink.html 块并由文件元源块读取。有关如何处理这些文件的更多信息,请参阅元数据文件格式的手册页。

用于将整个文件读入numpy数组的单行Python命令是:

  f = scipy.fromfile(open(filename),dtype = scipy.uint8)

将dtype替换为scipy.int16,scipy.int32,scipy.float32,scipy.complex64或您正在使用的任何类型。


所以你的问题我该如何编辑这个?归结为了解这是原始数据。你当然可以在字节级上修改它(例如,使用hexeditor),但是通常你可以(或者写)一些程序来将数据加载到程序中(例如一个复数的数组)看看那个。



你问这个问题的方式表明你并没有真正意识到你在看什么(因为你甚至不提到你如何传输该字符串)。也许你的数据有点误差由于噪声的符号错误?很可能,没有同步完成,所以你收到的位不是最终的相同的字节顺序,因为你的意思是他们发送等。

我想这可能是这是一个非常好的地方,可以指向 GNU无线电指导教程


I find that the file generated by file sink block is binary format, which can not edit by gedit under linux or something else, So how can i edit the file?

I send a dat file contains "hello world" and I want to recieve a file contains "hello world"

解决方案

This is asked very often. So here's a link to the FAQ and the excerpt:

All files are in pure binary format. Just bits. That’s it. A floating point data stream is saved as 32 bits in the file, one after the other. A complex signal has 32 bits for the real part and 32 bits for the imaginary part. Reading back a complex number means reading in 32 bits, saving that to the real part of a complex data structure, and then reading in the next 32 bits as the imaginary part of the data structure. And just keep reading the data.

Take a look at the Octave and Python files in gr-utils for reading in data using Octave and Python’s Scipy module.

The exception to the format is when using the metadata file format. These files are produced by the File Meta Sink: http://gnuradio.org/doc/doxygen/classgr_1_1blocks_1_1file__meta__sink.html block and read by the File Meta Source block. See the manual page on the metadata file format for more information about how to deal with these files.

A one-line Python command to read the entire file into a numpy array is:

f = scipy.fromfile(open("filename"), dtype=scipy.uint8)

Replace the dtype with scipy.int16, scipy.int32, scipy.float32, scipy.complex64 or whatever type you were using.

So your question "How do I edit this?" boils down to understanding that this is raw data. You can of course just modify this on a byte level (e.g. using a hexeditor), but usually, you'd have (or write) some program that loads the data into an in-program represenation (e.g. an array of complex numbers) and look at that.

The way you're asking this suggests you're not really aware of what you're looking at (because you don't even mention how you transmit that string). Maybe your data has bit errors due to symbol errors due to noise? Quite possibly, there's no synchronization done, so your received bits did not end up on the same byte order as you meant them to be sent etc.

I think this might be a very good place to point you to the GNU Radio Guided Tutorials.

这篇关于如何编辑由Gnu Radio的文件接收器生成的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆