[Douglas Geiger BBN 802.11b] Porting code on USRP2 problems

Dear all,

I’m trying to port the Douglas BBN 802.11b code on the USRP2 working
with the last version of GNU-Radio (3.2SVN)

The last version of Douglas bbn 802.11b already work with hier_blok2 but
not with USRP2, so,

in order to do this porting I followed the recommendations below :

http://www.opensubscriber.com/message/[email protected]/9944619.html

I just have modified the files “bbn_80211b_tx.py” and
“bbn_80211b_transmit_path.py” because

it should be by means of these ones that we can access to USRP2.

I obtain the following error:

Traceback (most recent call last):
File “bbn_80211b_tx.py”, line 108, in
main()
File “bbn_80211b_tx.py”, line 72, in main
tb = my_block(options.interp, options.spb, options.barker)
File “bbn_80211b_tx.py”, line 22, in init
self.txpath = bbn_80211b_transmit_path(interp_rate, spb, use_barker)
File
“/home/usrptest1/bbn_80211_doug/src/examples/bbn_80211b_transmit_path.py”,
line 44, in init
self.packet_transmitter = bbn_80211b_mod_pkts(tb, spb=spb,
NameError: global name ‘tb’ is not defined

I am not able to solve this error and debug the new code :frowning:

Any suggestion about this porting will be welcome

Best regards Andrea

Here below there are my two modified codes:

##################################################

bbn_802.11b_tx.py

##################################################
from gnuradio import gr, gru, blks2
from gnuradio import usrp2
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import random
import time
import struct
import sys
# from current dir
from bbn_80211b_transmit_path import bbn_80211b_transmit_path
class my_block(gr.top_block):

       def __init__(self, interp_rate, spb, use_barker):
        gr.top_block.__init__(self)
        self.txpath = bbn_80211b_transmit_path(interp_rate, spb,

use_barker)
#def init(self, tx_subdev_spec,
interp_rate, spb, use_barker):
# gr.flow_graph.init(self)
# self.txpath = bbn_80211b_transmit_path(tx_subdev_spec,
#interp_rate, spb,
use_barker)
#
/////////////////////////////////////////////////////////////////////////////

#                                   main

/////////////////////////////////////////////////////////////////////////////

def main():
def send_pkt(payload=‘’, eof=False):
return tb.txpath.send_pkt(payload, eof)
def rx_callback(ok, payload):
print “ok = %r, payload = ‘%s’” % (ok, payload)
parser = OptionParser (option_class=eng_option)
#parser.add_option(“-T”, “–tx-subdev-spec”, type=“subdev”,
default=None,
# help=“select USRP Tx side A or B”)
parser.add_option(“-f”, “–freq”, type=“eng_float”,
default=2.4e9,
help=
“set Tx and Rx frequency to FREQ
[default=%default]”,
metavar=“FREQ”)
parser.add_option(“-S”, “–spb”, type=“int”, default=8,
help=“set samples/baud [default=%default]”)
parser.add_option(“-i”, “–interp”, type=“int”, default=32,
help=
“set fpga interpolation rate to INTERP
[default=%default]”)
parser.add_option(“-r”, “–reps”, type=“int”, default=20,
help=
“Number of packets to send
[default=%default]”)
parser.add_option(“-b”, “–barker”, action=“store_true”,
default=False,
help=“Use Barker Spreading
[default=%default]”)
(options, args) = parser.parse_args ()
if len(args) != 0:
parser.print_help()
sys.exit(1)
if options.freq < 1e6:
options.freq *= 1e6
# build the graph
tb = my_block(options.interp, options.spb, options.barker)
#print “bitrate: %sb/sec” %
(eng_notation.num_to_str(tb.txpath.bitrate()),)
print “spb: %3d” % (tb.txpath.spb(),)
print “interp: %3d” % (tb.txpath.interp(),)
ok = tb.txpath.set_freq(options.freq)
if not ok:
print “Failed to set Tx frequency to %s” %
(eng_notation.num_to_str(options.freq),)
raise SystemExit
tb.start() # start flow graph
# generate and send packets
n = 0
fp = open(‘getty.txt’)
lines = fp.readlines()
payload = “”
i = 0;
while i < len(lines):
payload = payload + lines[i]
i = i + 1
while n < options.reps:
send_pkt(payload, False);
n = n + 1
time.sleep(1)
send_pkt(eof=True)
tb.wait() # wait for it to finish
if name == ‘main’:
try:
main()
except KeyboardInterrupt:
pass

##################################################

bbn_802.11b_trasmit_path.py

################################################## from gnuradio import
gr, gru, blks2
from gnuradio import usrp2
from bbn_80211b_pkt import *
#
/////////////////////////////////////////////////////////////////////////////

#                              transmit path
#

/////////////////////////////////////////////////////////////////////////////

class bbn_80211b_transmit_path(gr.hier_block2):
def init(self, interp, spb, use_barker): #def
init(self, subdev_spec, interp, spb, use_barker):
self.normal_gain = 28000

           self.u = usrp2.sink_32fc()       #self.u = usrp.sink_c()
        dac_rate = self.u.dac_rate();
           self._spb = spb
        self._interp=int(interp)
        self.u.set_interp(self._interp)   #

self.u.set_interp_rate(self._interp)
# determine the daughterboard subdevice we’re using
#if subdev_spec is None:
#subdev_spec = usrp.pick_tx_subdevice(self.u)
#self.u.set_mux(usrp.determine_tx_mux_value(self.u,
subdev_spec))
#self.subdev = usrp.selected_subdev(self.u, subdev_spec)
#print “Using TX d’board %s” %
(self.subdev.side_and_name(),)

transmitter******

        """self.packet_transmitter = bbn_80211b_mod_pkts(fg, 

spb=spb,
alpha=0.5,

gain=self.normal_gain,

use_barker=use_barker)
fg.connect(self.packet_transmitter, self.u)
gr.hier_block.init(self, fg, None, None)
self.set_gain(self.subdev.gain_range()[1]) # set max Tx
gain
self.set_auto_tr(True) # enable Auto Transmit/Receive
switching"“”

           self.packet_transmitter = bbn_80211b_mod_pkts(tb, 

spb=spb,
alpha=0.5,

gain=self.normal_gain,

use_barker=use_barker)
tb.connect(self.packet_transmitter, self.u)
gr.hier_block.init(self, tb, None, None)
self.set_gain(self.usrp2.gain_range()[1])
self.set_auto_tr(True)


    def set_freq(self, target_freq):
        """
        Set the center frequency we're interested in.
           @param target_freq: frequency in Hz
        @rypte: bool
           Tuning is a two step process.  First we ask the front-end 

to
tune as close to the desired frequency as it can. Then we
use
the result of that operation and our target_frequency to
determine the value for the digital up converter. Finally,
we feed
any residual_freq to the s/w freq translater.
“”"
r = self.u.set_center_freq(target_freq) # r =
self.u.tune(self.subdev.which(), self.subdev, target_freq)
if r:
# Could use residual_freq in s/w freq translator
return True
return False
def set_gain(self, gain):
self.gain = gain
self.usrp2.set_gain(gain) #self.subdev.set_gain(gain)
#def set_auto_tr(self, enable):
#return self.subdev.set_auto_tr(enable)
def send_pkt(self, payload=‘’, eof=False):
return self.packet_transmitter.send_pkt(payload, eof)
def spb(self):
return self._spb
def interp(self):
return self._interp

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Costantini, Andrea wrote:

File

If you’re referring to my developer branch on CGRAN of the bbn_80211b
code, I do not believe the transmit code currently works with GNURadio
3.2. I have gotten the receive code working, and am working on a version
that talks to the USRP2, but I have not touched the transmit code at
all. It likely still needs to be converted to the new hier_block2 API.
Doug


Doug G.
Research Assistant
Communications and Signal Processing Lab
Oklahoma State University
http://cspl.okstate.edu
[email protected]
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJzP0ugfOzzR5bXIgRAvw5AJsFsrmRYoJ8+5h8kvVge4NIxWyfkgCdHRi7
l6IzEovyQ3dEvvYMZKlCm5s=
=52+W
-----END PGP SIGNATURE-----

Hi Colby,

I am glad that I am not the only one trying to port the code.
I guess you are in a more advanced state. I wasn’t even able to run the
test.py. :wink:

Would you like to share your modified code (even if it is not finished)?
so that I try to understand your modifications.

Best Regards,
Andrea

P.S. For the USRP2 api, I usually compare the USRP2 and USRP swig code
(e.g. usrp2.py and usrp_swig.py).

Hi Andrea,

I am also working to port the 802.11b code to the USRP2. I have finished
converting the code to hier_block2, and the bbn_80211b_test.py script
works
correctly and it can send packets in simulation. I am currently working
on
modifying the rx, and tx files to connect to the USRP2, but been
struggling
to make progress. I have not had much luck finding any documentation for
the
USRP2 function calls, so I am sorta lost on what to change in rx, tx and
tx
transmit path files. Does anyone have any links to the usrp2 api?

I would be more than happy to share the modifications I made (built
largly
upon Douglas’s work) with rest of the GNU radio community.

Regards,
Colby B.

Hi Douglas!

Yes, I was referring to your branch (thank you for that).
This comment on the CGRAN made me thinking that also the tx path was
changed:

“bbn_80211b_tx.py - douggeiger: Works with hier_block2 - with some help
from code found …”

Have you uploaded some work-in-progress on the rx path with USRP2?
I would really like to look at it, so that I could use it as starting
point for working on the tx path.

Thanks,
Best Regards,
Andrea

On Fri, Apr 03, 2009 at 10:45:18AM -0300, Tiago Rogério Mück wrote:

I fixed the problem. The top_block on bbn_80211b_tx_port was not being
properly initialized.

It seems to be working now, but when I use 8 samples per data bit instead of
4 I randomly got the following error:

usrp2::tx_raw: FIXME: short packet: 7 items (56 bytes)

Does anyone know what this mean?
I’m sending the working code.

Can you update from the trunk and try this again.
We added what we believe is a work around for this problem on 3/26 in
r10689 on the trunk.

Eric

Great to hear. I will be able to start testing with two USRPs soon. I am
waiting on some hardware. I will let the list know what I find out.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Costantini, Andrea wrote:

Andrea

P.S. For the USRP2 api, I usually compare the USRP2 and USRP swig code
(e.g. usrp2.py and usrp_swig.py).

I had started working on getting the receive-side code working with the
USRP2 (i.e. modifying the bbn_80211b_rx.py) - although I’ve had to put
it aside to deal with some other matters recently.
There’s a good summary of the function calls that need to be changed
at:

I had made similar modifications to the tunnel.py from the
gnuradio-examples before - and it is roughly the same.
I may be returning to that code soon, and would then be able to share
it. If you get things working in the meantime, I’d be happy to include
in my CGRAN branch (or you can get a CGRAN account and start your own -
I’d love to have help!).
Doug


Doug G.
Research Assistant
Communications and Signal Processing Lab
Oklahoma State University
http://cspl.okstate.edu
[email protected]
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJ0ODZgfOzzR5bXIgRAt/6AKChymI2931pPft/TtV0ivkQrCCGoQCgpjfA
hS9ZYkm1Kvz3TaRI+0zbsb0=
=oRfS
-----END PGP SIGNATURE-----

Updated from the trunk and I’m not getting that msg anymore.

Everything seems to be ok now.

2009/4/3 Eric B. [email protected]

Hi Colby B.,

I try to make the branche, usrp2_version, and I meet a problem that
bbn_plcp80211_bb.cc and bbn_tap.cc lost include string.h header file.

So the usrp2_version can work certainly?

Shih-Shen
Colby B. wrote:

Great to hear. I will be able to start testing with two USRPs soon. I am
waiting on some hardware. I will let the list know what I find out.

On Mon, Apr 06, 2009 at 04:29:20PM -0300, Tiago Rogério Mück wrote:

Updated from the trunk and I’m not getting that msg anymore.

Everything seems to be ok now.

Glad to hear it! Thanks for letting us know.

Eric