# Attribute/control stream question

**URL:** <https://www.ruby-forum.com/t/attribute-control-stream-question/106639>\
**Category:** GNU Radio\
**Created:** [June 12, 2007, 5:51pm UTC](https://www.ruby-forum.com/t/attribute-control-stream-question/106639 "2007-06-12T17:51:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_ASCottrell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/898d66/32.png) [@Eric\_ASCottrell](https://www.ruby-forum.com/u/Eric_ASCottrell)\
**Post date:** [June 12, 2007, 5:51pm UTC](https://www.ruby-forum.com/t/attribute-control-stream-question/106639/1 "2007-06-12T17:51:04Z")

</div>

Hello,

The processing of pulses into data requires me to keep track of valid  
pulses (following samples are above threshold) and leading edges (sample  
is 6 dB or more than previous sample and following sample is 6 dB or  
less than current sample). I also want to indicate preamble start and  
pass timestamps along. I have thought of three methods to do this but  
do not know which would be the best one.

The first method is to have two streams through the blocks, one a float  
stream containing the sample values and the other a short or int stream  
containing the attributes and control. The float data makes it easier  
to do processing as some of the blocks use 3 dB multiplication of the  
samples (1.414 and 0.707). Being an old programmer I still have the  
float equals slow performance mindset.

The second method is to have the two streams as shorts. I have to deal  
with an integer multiplication and division (sample \* 707 / 1000). I  
have no handle if integers would be faster than floats other than  
integer division tends to be expensive.

The third method is to use one integer stream and have the upper 16 bits  
be the attributes/control and the lower 16 bits be the value. This  
method has an additional minor disadvantage over the second method of  
needing to mask off the upper 16 bits when using the value but I do not  
have to deal with two streams.

73 Eric

---

<div class="post-metadata">

**Author:** ![Eric\_ASCottrell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/898d66/32.png) [@Eric\_ASCottrell](https://www.ruby-forum.com/u/Eric_ASCottrell)\
**Post date:** [June 13, 2007, 6:06am UTC](https://www.ruby-forum.com/t/attribute-control-stream-question/106639/2 "2007-06-13T06:06:13Z")

</div>

Eric A. Cottrell wrote:

> Hello,
> 
> The processing of pulses into data requires me to keep track of valid  
> pulses (following samples are above threshold) and leading edges (sample  
> is 6 dB or more than previous sample and following sample is 6 dB or  
> less than current sample). I also want to indicate preamble start and  
> pass timestamps along. I have thought of three methods to do this but  
> do not know which would be the best one.

You can do this, or you may be able to break things up into chunks of  
samples and process them as vectors. See the ofdm\_sync code for an  
example of how we do that.

> integer division tends to be expensive.

Float multiplication is 1 cycle. Integer multiplication can actually be  
slower these days.

> The third method is to use one integer stream and have the upper 16 bits  
> be the attributes/control and the lower 16 bits be the value. This  
> method has an additional minor disadvantage over the second method of  
> needing to mask off the upper 16 bits when using the value but I do not  
> have to deal with two streams.

I would use separate streams so you don’t need to play with bit fields.  
There are a number of places in the OFDM code where we use chars in  
parallel with vectors of floats, and it works well for us.

Matt

---

<div class="post-metadata">

**Author:** ![Eric\_ASCottrell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/898d66/32.png) [@Eric\_ASCottrell](https://www.ruby-forum.com/u/Eric_ASCottrell)\
**Post date:** [June 13, 2007, 10:04pm UTC](https://www.ruby-forum.com/t/attribute-control-stream-question/106639/3 "2007-06-13T22:04:27Z")

</div>

Matt E. wrote:

> > 
> 
> You can do this, or you may be able to break things up into chunks of  
> samples and process them as vectors. See the ofdm\_sync code for an  
> example of how we do that.

Also, off the top of my head, you might find the peak\_detector and  
sample\_and\_hold blocks useful for what you’re doing. If these won’t do  
what you need, that at least the S/H block illustrates the use of  
different streams where input stream 0 is some data type (float,  
gr\_complex, bytes, ints) and input stream 1 is a byte stream  
(sizeof\_char) as the control line.

Tom

---

<div class="post-metadata">

**Author:** ![Eric\_ASCottrell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/898d66/32.png) [@Eric\_ASCottrell](https://www.ruby-forum.com/u/Eric_ASCottrell)\
**Post date:** [October 30, 2011, 6:02am UTC](https://www.ruby-forum.com/t/attribute-control-stream-question/106639/4 "2011-10-30T06:02:57Z")

</div>

Pleasde Help me!!!  
grc

(grc:1774): Gtk-WARNING \*\*: Unable to locate theme engine in  
module\_path: “pixmap”,

(grc:1774): Gtk-WARNING \*\*: Unable to locate theme engine in  
module\_path: “pixmap”,

(grc:1774): Gtk-WARNING \*\*: Unable to locate theme engine in  
module\_path: “pixmap”,

(grc:1774): Gtk-WARNING \*\*: Unable to locate theme engine in  
module\_path: “pixmap”,  
\<\<\< Welcome to GNU Radio Companion 3.2.2 \>\>\>  
Error: ‘options’

> > > Failue  
> > > Traceback (most recent call last):  
> > > File  
> > > “/usr/lib/python2.7/dist-packages/gnuradio/grc/gui/MainWindow.py”, line  
> > > 174, in new\_page  
> > > flow\_graph = self.\_platform.get\_new\_flow\_graph()  
> > > File “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/Platform.py”,  
> > > line 149, in get\_new\_flow\_graph  
> > > def get\_new\_flow\_graph(self): return self.FlowGraph(self)  
> > > File “”, line 4, in **init**  
> > > File  
> > > “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/FlowGraph.py”, line  
> > > 37, in **init**  
> > > self.import\_data()  
> > > File  
> > > “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/FlowGraph.py”, line  
> > > 192, in import\_data  
> > > self.\_options\_block = self.get\_parent().get\_new\_block(self,  
> > > ‘options’)  
> > > File “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/Platform.py”,  
> > > line 159, in get\_new\_block  
> > > def get\_new\_block(self, flow\_graph, key): return  
> > > self.Block(flow\_graph, n=self.\_blocks\_n[key])  
> > > File “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/odict.py”,  
> > > line 34, in **getitem**  
> > > return self.\_data[key]  
> > > KeyError: ‘options’  
> > > Error: ‘options’
> 
> > > Failue  
> > > Traceback (most recent call last):  
> > > File  
> > > “/usr/lib/python2.7/dist-packages/gnuradio/grc/gui/MainWindow.py”, line  
> > > 174, in new\_page  
> > > flow\_graph = self.\_platform.get\_new\_flow\_graph()  
> > > File “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/Platform.py”,  
> > > line 149, in get\_new\_flow\_graph  
> > > def get\_new\_flow\_graph(self): return self.FlowGraph(self)  
> > > File “”, line 4, in **init**  
> > > File  
> > > “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/FlowGraph.py”, line  
> > > 37, in **init**  
> > > self.import\_data()  
> > > File  
> > > “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/FlowGraph.py”, line  
> > > 192, in import\_data  
> > > self.\_options\_block = self.get\_parent().get\_new\_block(self,  
> > > ‘options’)  
> > > File “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/Platform.py”,  
> > > line 159, in get\_new\_block  
> > > def get\_new\_block(self, flow\_graph, key): return  
> > > self.Block(flow\_graph, n=self.\_blocks\_n[key])  
> > > File “/usr/lib/python2.7/dist-packages/gnuradio/grc/base/odict.py”,  
> > > line 34, in **getitem**  
> > > return self.\_data[key]  
> > > KeyError: ‘options’  
> > > Traceback (most recent call last):  
> > > File “/usr/bin/grc”, line 53, in   
> > > ActionHandler(args, Platform())  
> > > File  
> > > “/usr/lib/python2.7/dist-packages/gnuradio/grc/gui/ActionHandler.py”,  
> > > line 70, in **init**  
> > > self.handle\_states(Actions.APPLICATION\_INITIALIZE)  
> > > File  
> > > “/usr/lib/python2.7/dist-packages/gnuradio/grc/gui/ActionHandler.py”,  
> > > line 332, in handle\_states  
> > > Actions.get\_action\_from\_name(Actions.ELEMENT\_DELETE).set\_sensitive(bool(self.get\_flow\_graph().get\_selected\_elements()))  
> > > File  
> > > “/usr/lib/python2.7/dist-packages/gnuradio/grc/gui/MainWindow.py”, line  
> > > 281, in get\_flow\_graph  
> > > return self.get\_page().get\_flow\_graph()  
> > > AttributeError: ‘NoneType’ object has no attribute ‘get\_flow\_graph’

---

<div class="post-metadata">

**Author:** ![Eric\_ASCottrell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/898d66/32.png) [@Eric\_ASCottrell](https://www.ruby-forum.com/u/Eric_ASCottrell)\
**Post date:** [June 14, 2007, 3:54am UTC](https://www.ruby-forum.com/t/attribute-control-stream-question/106639/5 "2007-06-14T03:54:12Z")

</div>

Tom R. wrote:

> > > do not know which would be the best one.  
> > > different streams where input stream 0 is some data type (float,  
> > > gr\_complex, bytes, ints) and input stream 1 is a byte stream  
> > > (sizeof\_char) as the control line.
> 
> Tom  
> Hello,

Thanks for the suggestions and observations. I will look at the OFDM  
code and other blocks.

This is getting to be a big project. PPM is so simple but there are  
some interesting enhanced receiving techniques to squeeze the last drop  
of performance. I took a text description and turned it into code so no  
doubt there are other functions I can use to optimize the current code.  
I want to add capability to time stamp the frames and get signal levels  
so I am modifying the code again. I also want to comment it so others  
can figure out what is going on. Sorry it is taking some time to get  
the code ready but I want the code structure to be set before check-in.

I am still figuring out GNURadio and Python so I looked at the cfile  
example and used it to improve my log program. I noticed that I may be  
able to use a higher sample rate if I go with the 4rx0tx USRP file. A  
future enhancement may be to put the AM detector in the USRP and just  
send shorts over the USB bus. I want to try 10 or 16 MSPS rate to see  
if performance improves.

I want to try the OFDM code anyway and see if I get any data off the  
BPSK carriers of IBOC AM stations used for station information.

73 Eric
