Forum: GNU Radio Transmitting the contents of a file.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B84410c26465ab9f9e79a99374fb3f0c?d=identicon&s=25 Bahn William L Civ USAFA/DFCS (Guest)
on 2007-01-17 17:23
(Received via mailing list)
Perhaps my prior posts have included too much information to get a
response, so I'll try trimming it way down.

I have a file of waveform data that I want to send to the DAC on the
USRP. Can it be done? How do I do it? What format does the data in the
file need to be in?

Any response would be appreciated.
Cec0a4bf0e0575f3a3171892e6097e59?d=identicon&s=25 Johnathan Corgan (Guest)
on 2007-01-17 17:51
(Received via mailing list)
On Wed, 2007-01-17 at 09:22 -0700, Bahn William L Civ USAFA/DFCS wrote:

> I have a file of waveform data that I want to send to the DAC on the
> USRP. Can it be done? How do I do it? What format does the data in the
> file need to be in?

You can use the gr.file_source block to turn a binary file into a stream
of values that can be connected to further blocks.  This could be raw
input to the USRP, or could be preprocessed by other blocks in a flow

The gr.file_source block takes three parameters in it's constructor:

itemsize - the length in bytes for an individual data item in the file
filename - pathname of the file to open
repeat   - if true, loop to beginning of file when EOF
           if false, end when the file read is complete

Other than the itemsize value, the actual format of the data in the file
must correspond to the binary format of the data type expected by the
block(s) that will be connected to the file_source.  So if you have a
sequence of short integers (16 bit), you can follow the file_source
block with any block that takes shorts as an input (typically their name
would have _s at the end.)  Shorts are stored 'native-endian', that is,
the file must have the low byte/high byte order the same as the native
format of the machine reading the file.  For x86 machines, this is
little-endian, or low byte first.

You can use GNU radio blocks to create files in the proper format by
implementing a flow graph that ends in a gr.file_sink, and then use the
output files later as input to something else.  It's a very common
testing technique.

By the way, there is no notion of sample rate stored with the file; GNU
radio will process the samples as fast as can be read from disk.  So if
you need to emulate a particular real-time data rate, you should follow
your gr.file_source with a gr.throttle block.  This won't be necessary
if you have some other rate-limiting block in your flow graph, such as
the USRP itself.

There are several examples of gr.file_source use in the examples
directory under python/usrp (you can grep for file_source to see them).

Conceivably, if your waveform data is already in the right format, you
could just use a gr.file_source and a usrp.sink_c to do what you were
originally asking above.

Johnathan Corgan, AE6HO
Corgan Enterprises LLC
This topic is locked and can not be replied to.