From: Ben Reynwar <address@hidden>
To: abdullah unutmaz <address@hidden>; discuss-gnuradio Discussion Group <address@hidden>
Sent:
Thursday, August 9, 2012 6:29 PM
Subject: Re: [Discuss-gnuradio] vector sink data
On Thu, Aug 9, 2012 at 1:53 PM, abdullah unutmaz
<
address@hidden> wrote:
> Greetings,
>
> I would like to ask you how to read the data stored in a vector sink. I
> tried the solutions I found in the discussion list. You can see some part of
> my python code below.
> ------------------------------------------------------------------------------------------------------------------------------------------------------
> ##################################################
> # Connections
> ##################################################
> self.connect((self.my_vec_src, 0), (self.my_thro, 0))
> vector_source -> throttle
>
self.connect((self.my_thro, 0), (self.my_h, 0))
> throttle -> head
> self.connect((self.my_h, 0), (self.my_vec_snk, 0)) head ->
> vector_sink
>
> time.sleep(10)
> my_data=self.my_vec_snk.data()
> print "data: ",my_data
> --------------------------------------------------------------------------------------------------------------------------------------------------------
> if __name__ == '__main__':
> parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
> (options, args) = parser.parse_args()
> tb = top_block()
> tb.Run(True)
>
----------------------------------------------------------------------------------------------------------------------------------------------------------
> Output of the program :
>
> data: ()
>
> I need to read an incoming data to correlate with some predefined data,
> vector. If I am not wrong the best solution is to save data in a vector sink
> same length as the predefined vector, then applying the cross-correlation to
> them. The program above is just a test program to examine what the vector
> sink
> stores, but I am confused why it does not work, because I saw a similar
> working use of a vector sink with USRPs. I already save the data in a file,
> but it does not seem to me as a good solution at least due to possible
> memory waste, though clearing the file is possible in run-time.
>
> Thanks in advance,
> Abdullah
>
>
_______________________________________________
> Discuss-gnuradio mailing list
>
address@hidden>
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio>
vector_sink is useful if you're running for a short time, for example
in a test. You can access that data using snk.data() after tb.run()
has completed.
So something like:
tb.run()
time.sleep(10)
my_data = tb.my_vec_snk.data()
print "data: ",my_data
To extract data from a running flow graph use the probe blocks
(gr.probe_signal_*).
tb.start()
time.sleep(10)
my_data = tb.my_probe_signal.level()
print "data: ",my_data