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 Boyer On Fri, Mar 27, 2009 at 2:06 AM, Costantini, Andrea <costant...@ftw.at>wrote: > 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/discuss-gnuradio@gnu.org/9944619.html > > - http://sdrblog.wordpress.com/2009/03/12/port-usrp1-code-to-usrp2/ > > > 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 <module> > 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 :-( > > 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 > > > > > > _______________________________________________ > Discuss-gnuradio mailing list > Discuss-gnuradio@gnu.org > http://lists.gnu.org/mailman/listinfo/discuss-gnuradio >
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnuradio