How to write vector to a file

Hello everyone,

I am here to ask a question. As I am very new with gnuradio, I would
really
be happy if someone get me a solution.

I want to write vectors, which comes from stream, to a file.
Here is what I wanna do.

self.connect(self.u, s2v, “class”)

s2v transforms the stream to vector. I want the vector to be written in
a
file.
I know about the gr.file_sink() but it writes the stream to file, not
the
vector.


View this message in context:
http://old.nabble.com/How-to-write-vector-to-a-file-tp32823759p32823759.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On 11/10/2011 10:07 PM, hasanimam wrote:

I assume self.u is a USRP with multiple channels. Otherwise, you should
not need streams to vector. The conversion would be superfluous.

s2v transforms the stream to vector. I want the vector to be written in a
file.
I know about the gr.file_sink() but it writes the stream to file, not the
vector.

The file sink will for you. Any IO size is fine, because file sink only
understands bytes.

-Josh

Thanks Josh,

You got it right, self.u is USRP2. I am converting the stream which
comes
from self.u into vector by using the s2v (stream to vector) function.
And
now I want to capture the IQ data.

gr.file_sink() writes only streams into a file I guess, so I was
looking
for any other gnuradio class which can write vectors too into a file. Do
you think that gr.file_sink() can do the same thing?

Also, When I use gr.file_sink(), the sensing does not automatically and
I
have to stop it manually(ctrl+z) after a while. I am wondering if there
is
any other way so that the usrp2 can sense a certain frequency band for a
certain period and can switch to another frequency then.
And one more thing, using gr,file_sink() and storing the raw complex
data,
I found that many data are giving 0 value. I think regardless of the
frequency band, the raw data should contain some value, it might be very
small but not zero. Do you any reason for that?

Thank you;

Also, When I use gr.file_sink(), the sensing does not automatically
and I have to stop it manually(ctrl+z) after a while. I am wondering
if there is any other way so that the usrp2 can sense a certain
frequency band for a certain period and can switch to another
frequency then.
And one more thing, using gr,file_sink() and storing the raw complex
data, I found that many data are giving 0 value. I think regardless of
the frequency band, the raw data should contain some value, it might
be very small but not zero. Do you any reason for that?

Thank you;
Not sure why you want the vector format. A vector in Gnu Radio is just
a fixed-sized “slab” of samples, and since you’re just recording them
to disk, there’s no reason to treat them in a vector format inside
the flow-graph. Certain transforms, like the FFT, require their inputs
to
be fixed-sized “vectors”, but a simple stream-record-to-disk has no
such requirement.

You haven’t discussed your hardware setup in detail. What
daughtercards? What frequency are you tuning to? Have you set the RF
gain controls appropriately?

The I/Q data are voltage-samples of a quasi-sinusoidal phenomenon–why
would you not expect such a phenomenon to regularly and
frequently pass-through the zero point?

If you’re programming in raw Python, can I suggest you look into Gnu
Radio companion? It makes things easier in many ways.

Also, if you want to “sample for a little while then stop”, you can
create a separate thread that simply goes to sleep for awhile, and when
it
wakes up, it calls tb.stop(), where “tb” is whatever you’ve named
your top flow-graph block.


Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs