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
graph.
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 C., AE6HO
Corgan Enterprises LLC
[email protected]