File format question

I have a few questions, but they mostly come down to: What is the data
file format when using a file as a signal source?

====================================================================

From http://www.nd.edu/~jnl/sdr/docs/tutorials/9.html#tth_sEc3.3

2.5 File sources
Block: gr.file_source
Usage:
gr.file_source ( size_t itemsize,
const char * filename,
bool repeat )

Notes: gr.file_source reads the data stream from a file. The name of the
file is specified by filename. The first argument itemsize determines
the data type of the stream, such as gr_complex, float, unsigned char.
The argument repeat decides whether the data in the file is sent
repeatedly. As an example, we can use the block in this way in Python:
src = gr.file_source (gr.sizeof_char, “/home/dshen/payload.dat”, TRUE)

Question #1: What is the syntax for the itemsize argument?

Since the example doesn’t use one of the data types mentioned, it is
hard to tell what the syntax is supposed to be. For instance, if I want
to use gr_complex, do I specify gr.sizeof_gr_complex? If I want to use
unsigned char, is it “gr_sizeof_unsigned_char” so as to eliminate the
space?

Question #2: What are all of the options for the itemsize argument?

It lists “gr_complex”, “float”, and “unsigned char” yet the example uses
one that is not in the list. Are there others?

Question #3: Does the data file format for transmitting match the data
file format when receiving?

Can I take a file that is recorded, say using receive_file_c.py (may not
have the file name exactly correct) and use that as a source without
modification? If so, what does it mean to use IQ pairs as input data?
What does the USRP do with them?

If I use a data size of “gr_sizeof_float” does that mean that my data
file should consist of a list of floating point values stored as IEEE
single precision values where each value represents a time-sampled
baseband data point?

Thanks.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bahn William L Civ USAFA/DFCS wrote:

I have a few questions, but they mostly come down to: What is the data file format when using a file as a signal source?

These file_sink and file_source are direct wrappers for the C functions
fwrite and fread and behave exactly as they do. A file is therefore
simply a binary containing {chars,shorts,ints,floats,etc} in
local-endianness.

Question #1: What is the syntax for the itemsize argument?

Since the example doesn’t use one of the data types mentioned, it is hard to tell what the syntax is supposed to be. For instance, if I want to use gr_complex, do I specify gr.sizeof_gr_complex? If I want to use unsigned char, is it “gr_sizeof_unsigned_char” so as to eliminate the space?

Question #2: What are all of the options for the itemsize argument?

It lists “gr_complex”, “float”, and “unsigned char” yet the example uses one that is not in the list. Are there others?

Itemsize is the size, in bytes, of the object to be written. Valid
useful values are 1 (char), 2 (short), 4 (int/float), 8 (complex);
although I suspect you could put anything fwrite/fread accepted in there
and it would work.

Question #3: Does the data file format for transmitting match the data file format when receiving?

Can I take a file that is recorded, say using receive_file_c.py (may not have the file name exactly correct) and use that as a source without modification? If so, what does it mean to use IQ pairs as input data? What does the USRP do with them?

Yes. When I’m working on building a receiver for a certain modulation
scheme, for example, I transmit some data and run usrp_rx_cfile.py on
the receiver, then use a gr.file_source block as input to my receiver
blocks to allow for reproducible testing without polluting the airwaves.

Similarly, you could if you wanted generate a file to transmit by using
a file_sink instead of a usrp_sink and then send it across the USRP with
a file_source → usrp_sink.

The I/Q pairs are processed by the USRP from files the same way they are
from a normal GNU Radio block such as e.g. the DBPSK modulator (see
dbpsk.py, tunnel.py).

  • -Dan
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGwhxHy9GYuuMoUJ4RAstQAKC+k5g89aTnmXZsjU9ctb6sqjtCoACgjuCz
18oDQYVVTNeDL4Tx+SV+VQk=
=HBOu
-----END PGP SIGNATURE-----

Thanks, that helps some.

I figured that I could put in the literal size of the data, in bytes,
but that only helps if it actually matches how the GR blocks are going
to process those bytes.

When possible, I would prefer to use the constants that have been set up
so that the code is (1) more readable, and (2) more maintainable. So
instead of using “8” for complex, I would like to use
gr.sizeof_“whatever”. But I don’t know what “whatever” needs to be.
Where do I find this?

I’ll look at dbpsk.py and tunnel.py when I get my Linux box set back up.
Is there a module that takes time domain data and converts it to IQ
pairs, or am I responsible for doing that when I generate the file? If
so, what LO frequency would I need to use?

It would be so much simpler if I could just use the generated time
domain data directly.

Thanks!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bahn William L Civ USAFA/DFCS wrote:

Thanks!
From
/usr/local/lib/python2.5/site-packages/gnuradio/gr/gnuradio_swig_py_runtime.py:

sizeof_char = _gnuradio_swig_py_runtime.sizeof_char
sizeof_short = _gnuradio_swig_py_runtime.sizeof_short
sizeof_int = _gnuradio_swig_py_runtime.sizeof_int
sizeof_float = _gnuradio_swig_py_runtime.sizeof_float
sizeof_double = _gnuradio_swig_py_runtime.sizeof_double
sizeof_gr_complex = _gnuradio_swig_py_runtime.sizeof_gr_complex

Those are the constants you want.

When you say generated time domain data, are you talking about (time,
voltage) pairs off of a scope? IIRC scope data is just the I component,
and you can get the Q component from I using standard signal processing
techniques assuming your sampling rate is sufficiently high.

  • -Dan
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.6 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGw4oAy9GYuuMoUJ4RAl6xAJ44btFqFjVOvdVvACG0e/0XUQEN7QCeMFBD
ftSTrvnSYrU2sPjn6hC7PeM=
=dMQB
-----END PGP SIGNATURE-----

Bahn William L Civ USAFA/DFCS schrieb:

I would prefer to use the constants that have been set up so that the
code is (1) more readable, and (2) more maintainable. So instead of
using “8” for complex, I would like to use gr.sizeof_“whatever”. But I
don’t know what “whatever” needs to be. Where do I find this?

Python has nice reflection/inspection capabilities, so you’re able to
list the content of a package. Doing this “by hand” is somewhat
cumbersome, have a look at the module inspect[0].

I would recommend to use pyalamode from the wxPython project (should be
packaged in a decent distribution, like python-wxtools in Debian[1])
pyalamode allows you to browse packages and does autocompletion, so you
type “gr.sizeof_” and get a list of all available sizeof_s.

Patrick asdf

[0] http://www.python.org/doc/2.4.4/lib/module-inspect.html
[1]
Debian -- Package Contents Search Results -- pyalamode

Engineers motto: cheap, good, fast: choose any two
Patrick S.
Student of Telematik, Techn. University Graz, Austria

When possible, I would prefer to use the constants that have been set up
so that the code is (1) more readable, and (2) more maintainable. So
instead of using “8” for complex, I would like to use
gr.sizeof_“whatever”. But I don’t know what “whatever” needs to be. Where
do I find this?

Those are the constants you want.

Thank you very much. I certainly would have never thought to look in
that file in that directory.

It would be so much simpler if I could just use the generated time
domain data directly.

Thanks!

When you say generated time domain data, are you talking about (time,
voltage) pairs off of a scope? IIRC scope data is just the I component,
and you can get the Q component from I using standard signal processing
techniques assuming your sampling rate is sufficiently high.

No, I’m talking about instantaneous baseband waveform amplitudes
generated by an external program and written to a file with a single
amplitude value per sample.

Also, what is the peak-peak signal values for floating point data
sources? -1.0 to +1.0?