Obtain data before FFT

Hi, all
I want to plot a figure with the samples from usrp, but I have some
questions. Here is the flowgraph:
usrp.source_c --> gr.streams_to_vector(gr.sizeof_gr_complex1, 1) -->
gr.complex_to_mag(1)
–> gr.message_sink(gr.sizeof_float
1, self.msg_sink_msgq_out, True)
Here, self.msg_sink_msgq_out = gr.msg_queue(2)
In main function, I did this:
msg = tb.msg_sink_msgq_out.delete_head()
a = int(msg.arg1())
b = int(msg.arg2())
s = msg.to_string()
float_data = numpy.fromstring(s, numpy.float32)
for bin in float_data:
print bin
Questions are sa follows:
(1) Is my code correct? If it isn’t, how should I modify it?
(2) What is the return value of gr.msg_queue(2)? I mean what’s the
meaning of “a”,“b”,“s” in this code?
(3) Is what stored in “s” the amplitude of the samples? If I plot the
figure with s, can I get the envelop of the signal? (4) How to calculate
the time interval between each sample? Can I set the collecting time for
USRP? For example, I want to collect the signal for 1 second.
Thank you! Any help will be appreciated!

2010/12/5 lishan_wh [email protected]:

Hi, all
I want to plot a figure with the samples from usrp, but I have some
questions. Here is the flowgraph:
usrp.source_c → gr.streams_to_vector(gr.sizeof_gr_complex1, 1) →
gr.complex_to_mag(1)
→ gr.message_sink(gr.sizeof_float
1, self.msg_sink_msgq_out, True)

Why are you using streams_to_vector that way? It looks like you’re
creating vectors with a single element in it.

(1) Is my code correct? If it isn’t, how should I modify it?
(2) What is the return value of gr.msg_queue(2)? I mean what’s the meaning
of “a”,“b”,“s” in this code?
(3) Is what stored in “s” the amplitude of the samples? If I plot the figure
with s, can I get the envelop of the signal? (4) How to calculate the time
interval between each sample? Can I set the collecting time for USRP? For
example, I want to collect the signal for 1 second.
Thank you! Any help will be appreciated!

Why are you using a message sink? If you want to plot, why not use
either the WX or QT plotting tools? Use the gnuradio-companion and
drop down a graphical sink.

If you just want to run some data through the graph and plot it
afterwards, store it to a vector or a file_sink and then plot it
later.

Tom