# Vector sink data

**URL:** <https://www.ruby-forum.com/t/vector-sink-data/222047>\
**Category:** GNU Radio\
**Created:** [August 9, 2012, 10:54pm UTC](https://www.ruby-forum.com/t/vector-sink-data/222047 "2012-08-09T22:54:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 9, 2012, 10:54pm UTC](https://www.ruby-forum.com/t/vector-sink-data/222047/1 "2012-08-09T22:54:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![abdullah\_unutmaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/65b543/32.png) [@abdullah\_unutmaz](https://www.ruby-forum.com/u/abdullah_unutmaz)\
**Post date:** [August 10, 2012, 12:30am UTC](https://www.ruby-forum.com/t/vector-sink-data/222047/2 "2012-08-10T00:30:31Z")

</div>

On Thu, Aug 9, 2012 at 1:53 PM, abdullah unutmaz  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> vector\_source → throttle  
> parser = OptionParser(option\_class=eng\_option, usage=“%prog: [options]”)  
> same length as the predefined vector, then applying the cross-correlation to
> 
> * * *
> 
> Discuss-gnuradio mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](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

---

<div class="post-metadata">

**Author:** ![abdullah\_unutmaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/65b543/32.png) [@abdullah\_unutmaz](https://www.ruby-forum.com/u/abdullah_unutmaz)\
**Post date:** [August 10, 2012, 1:06pm UTC](https://www.ruby-forum.com/t/vector-sink-data/222047/3 "2012-08-10T13:06:41Z")

</div>

@Ben, first of all thanks for replying.

I tried both of the solutions, the output I get is a vector containing  
only zeros,

data: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

When I use probe\_signal

data: 0.0

But I was sending a vector composed of eleven elements of a combination  
of ones and zeros.It seems extra-ordinary, when I open the file to see  
the data I keep, I see two different symbols, ascii-codes, sequenced  
periodically after skipping an amount of the first stored data.

What may be the problem, any idea?

- Abdullah

* * *

From: Ben R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: abdullah unutmaz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid); discuss-gnuradio  
Discussion Group [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> vector\_source → throttle  
> parser = OptionParser(option\_class=eng\_option, usage=“%prog: [options]”)  
> same length as the predefined vector, then applying the cross-correlation to
> 
> * * *
> 
> Discuss-gnuradio mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](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

---

<div class="post-metadata">

**Author:** ![abdullah\_unutmaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/65b543/32.png) [@abdullah\_unutmaz](https://www.ruby-forum.com/u/abdullah_unutmaz)\
**Post date:** [August 10, 2012, 9:28pm UTC](https://www.ruby-forum.com/t/vector-sink-data/222047/4 "2012-08-10T21:28:07Z")

</div>

Thanks, I realized what I need to do. Next monday I can try it, probably  
it will solve the problem.

* * *

From: Ben R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: abdullah unutmaz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid); discuss-gnuradio  
Discussion Group [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Friday, August 10, 2012 8:37 PM  
Subject: Re: [Discuss-gnuradio] vector sink data

I can’t tell what your problem might be without seeing your entire  
script.

A minimal script doing something like this is:

from gnuradio import gr  
tb = gr.top\_block()  
src = gr.vector\_source\_f([1,2,3,4,5,6])  
snk = gr.vector\_sink\_f()  
tb.connect(src, snk)  
tb.run()  
print(snk.data())

On Fri, Aug 10, 2012 at 4:05 AM, abdullah unutmaz

---

<div class="post-metadata">

**Author:** ![abdullah\_unutmaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/65b543/32.png) [@abdullah\_unutmaz](https://www.ruby-forum.com/u/abdullah_unutmaz)\
**Post date:** [August 10, 2012, 7:38pm UTC](https://www.ruby-forum.com/t/vector-sink-data/222047/5 "2012-08-10T19:38:17Z")

</div>

I can’t tell what your problem might be without seeing your entire  
script.

A minimal script doing something like this is:

from gnuradio import gr  
tb = gr.top\_block()  
src = gr.vector\_source\_f([1,2,3,4,5,6])  
snk = gr.vector\_sink\_f()  
tb.connect(src, snk)  
tb.run()  
print(snk.data())

On Fri, Aug 10, 2012 at 4:05 AM, abdullah unutmaz

---

<div class="post-metadata">

**Author:** ![abdullah\_unutmaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/65b543/32.png) [@abdullah\_unutmaz](https://www.ruby-forum.com/u/abdullah_unutmaz)\
**Post date:** [August 16, 2012, 9:30am UTC](https://www.ruby-forum.com/t/vector-sink-data/222047/6 "2012-08-16T09:30:02Z")

</div>

Greetings,

Could I set up an ordinary paralel output shift register using  
vector\_sink or probe\_signal?  
When I examined both vector\_sink & probe\_signal, process was ended when  
the output was displayed.  
But, I need an ongoing data acquisition, though I can get different  
outputs from both of the blocks,  
I need a flow of samples. If I can set this up, most of the work will be  
done.

In main function, I embed

"

tb.run()  
time.sleep(10)  
my\_data = tb.my\_vec\_snk.data()  
print "data: ",my\_data

"  
into a while(True) loop, but this time everything starts from the  
begining, it takes sometime from the FPGA to settle,  
and data acquisition cuts down.

As an alternative solution, I keep larger amount of samples than actual  
number of samples I need to, and search  
the pattern in the kept sequence. But it is time consuming, this study  
is for a final year project, when I discuss solutions  
with my professor, he decisivelywants the system to be ongoing data  
flow, even though in both of the possible  
solutions the process ends right after the data is acquired :).

Thanks,  
Abdullah

* * *

From: abdullah unutmaz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: Ben R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid); “[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Friday, August 10, 2012 3:25 PM  
Subject: Re: [Discuss-gnuradio] vector sink data

Thanks, I realized what I need to do. Next monday I can try it, probably  
it will solve the problem.

From: Ben R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: abdullah unutmaz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid); discuss-gnuradio  
Discussion Group [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Friday, August 10, 2012 8:37 PM  
Subject: Re: [Discuss-gnuradio] vector sink data

I can’t tell what your problem might be without seeing your entire  
script.

A minimal script doing something like this is:

from gnuradio import gr  
tb = gr.top\_block()  
src = gr.vector\_source\_f([1,2,3,4,5,6])  
snk = gr.vector\_sink\_f()  
tb.connect(src, snk)  
tb.run()  
print(snk.data())

On Fri, Aug 10, 2012 at 4:05 AM, abdullah unutmaz  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But I was sending a vector composed of eleven elements of a combination of  
> ones and zeros. It seems extra-ordinary, when I open the file to see the

data I keep, I see two different symbols, ascii-codes, sequenced

> Sent: Thursday, August 9, 2012 6:29 PM
> 
> >

* * *

> > ##################################################  
> > # 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))

> > parser = OptionParser(option\_class=eng\_option, usage=“%prog:  
> > [options]”)  
> > (options, args) = parser.parse\_args()  
> > tb = top\_block()  
> > tb.Run(True)

* * *

> > 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.  
> > vector\_sink is useful if you’re running for a short time, for example

tb.start()

---

<div class="post-metadata">

**Author:** ![abdullah\_unutmaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/65b543/32.png) [@abdullah\_unutmaz](https://www.ruby-forum.com/u/abdullah_unutmaz)\
**Post date:** [August 17, 2012, 1:13am UTC](https://www.ruby-forum.com/t/vector-sink-data/222047/7 "2012-08-17T01:13:17Z")

</div>

If I am not wrong, I can use “gr.buffer” with “gr.buffer\_reader” to  
design an exact parallel output shift register,  
at least the closest one.

Abdullah

* * *

From: Ben R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: abdullah unutmaz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Cc: discuss-gnuradio Discussion Group [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Thursday, August 16, 2012 9:57 AM  
Subject: Re: [Discuss-gnuradio] vector sink data

tb.start()  
while not\_finished:  
time.sleep(10)  
my\_data = tb.my\_probe\_signal.level()  
print(my\_data)  
tb.stop()

You can use gr.probe\_signal\_vc to grab a vector of data, however  
you’ll only grab data every 10 seconds in the above example.  
This method will only give you occasional snapshots of the data so  
will not allow an exhaustive search.  
If you want to do an exhaustive search then writing a custom signal  
processing block in C++ is the way to go.

Ben

On Thu, Aug 16, 2012 at 12:28 AM, abdullah unutmaz

---

<div class="post-metadata">

**Author:** ![abdullah\_unutmaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/65b543/32.png) [@abdullah\_unutmaz](https://www.ruby-forum.com/u/abdullah_unutmaz)\
**Post date:** [August 16, 2012, 3:58pm UTC](https://www.ruby-forum.com/t/vector-sink-data/222047/8 "2012-08-16T15:58:41Z")

</div>

tb.start()  
while not\_finished:  
time.sleep(10)  
my\_data = tb.my\_probe\_signal.level()  
print(my\_data)  
tb.stop()

You can use gr.probe\_signal\_vc to grab a vector of data, however  
you’ll only grab data every 10 seconds in the above example.  
This method will only give you occasional snapshots of the data so  
will not allow an exhaustive search.  
If you want to do an exhaustive search then writing a custom signal  
processing block in C++ is the way to go.

Ben

On Thu, Aug 16, 2012 at 12:28 AM, abdullah unutmaz

---

<div class="post-metadata">

**Author:** ![Zoebairr](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/zoebairr/32/3284_2.png) [@Zoebairr](https://www.ruby-forum.com/u/Zoebairr)\
**Post date:** [November 6, 2023, 2:20pm UTC](https://www.ruby-forum.com/t/vector-sink-data/222047/9 "2023-11-06T14:20:12Z")

</div>

Hwy, I know its been almost a decade. But I am stuck with some problem as follows, which is somewhat similair to what you had gone though. My questions are:

1. Do we need a vector source as well in order to access vector sink?

2. I am using a USRP (Ettus B210) and my objective is to print the RSSI values in a text file. My setup is two USRP in 3.75 Ghz operating and one USRP sends packets while other receives. My receiving program is USRP source —\> complex to mag2 —\> vector sink.  
where to put the above code (given in docs of vector sink gnuradio)? Does it work?
