Beispiel #1
0
def TestDC():
    """ Parser Options """
    parser = OptionParser (option_class=eng_option)
    RadioRx.add_parser_options (parser)
    (options, args) = parser.parse_args ()
    if len(args)!=0:
        parser.print_help()
        sys.exit(1)

    print "TestRx\n=========="

    tb = gr.top_block()
    rx = gr.vector_sink_c()
    rf = RadioRx(options)
    tb.connect(rf,rx)
    
    stoptime = 20.0
    if options.fake_rf:
        f = FuncThread(send_stoprf, "stop rf", rf, stoptime)
    else:
        f = FuncThread(stop_tb, "stop tb", tb, stoptime)
    f.setDaemon(1)
    f.start()
    
    print "running ..."
    tb.run()
    print "stoppping ..."

    n = numpy.array(rx.data() )
    n = n[len(n)/2:]
    print "noise mean =", n.mean()
    print "noise var  =", n.var()
    print "noise std  =", n.std()
Beispiel #2
0
 def add_parser_options (parser):
     if not parser.has_option("-v"):
         parser.add_option ("-v", "--verbose", type="int", \
                 default=default_phy_setup.d_options['verbose'], \
                 help="set verbose level of output [default=%default]")
     if not parser.has_option("--debug"):
         parser.add_option ("", "--debug", type="int", \
                 default=default_phy_setup.d_options['debug'], \
                 help="set debug level of system [default=%default]")
     if not parser.has_option("-n"):
         parser.add_option ("-n", "--nchannels", type="int", \
                 default=default_phy_setup.d_options['nchannels'], \
                 help="set number of channels (or antennas) on USRP board [default=%default]")
     if not parser.has_option("-G"):
         parser.add_option ("-G", "--rx-gain", type="eng_float", \
                 default=default_phy_setup.d_options['rx_gain'], \
                 help="set usrp receive gain in dB [default=%default]")
     if not parser.has_option("-g"):
         parser.add_option ("-g", "--tx-gain", type="eng_float", \
                 default=default_phy_setup.d_options['tx_gain'], \
                 help="set software transmit gain in dB [default=%default]")
     if not parser.has_option("-u"):
         parser.add_option ("-u", "--upsample", type="int",
                 default=default_phy_setup.d_options['upsample'], \
                 help="set the upsampling factor [default=%default]")
     if not parser.has_option("--inband"):
         parser.add_option("", "--inband", action="store_true", \
                 default=default_phy_setup.d_options['inband'],
                 help="enable inband signalling in RF [default=%default]")
     RadioRx.add_parser_options(parser)
     RadioTx.add_parser_options(parser)
Beispiel #3
0
def TestRx():
    """ Parser Options """
    parser = OptionParser (option_class=eng_option)
    RadioRx.add_parser_options (parser)
    (options, args) = parser.parse_args ()
    if len(args)!=0:
        parser.print_help()
        sys.exit(1)

    print "TestRx\n=========="

    tb = gr.top_block()
    rx = gr.vector_sink_c()
    rf = RadioRx(options)
    tb.connect(rf,rx)
    
    stoptime = 2.0
    if options.fake_rf:
        f = FuncThread(send_stoprf, "stop rf", rf, stoptime)
    else:
        f = FuncThread(stop_tb, "stop tb", tb, stoptime)
    f.setDaemon(1)
    f.start()
    
    print "running ..."
    tb.run()
    print "stoppping ..."

    x = numpy.array(rx.data(), numpy.complex64)
    #start, limit = 200, len(x)
    start, limit = 200, 1000
    L = min(len(x), start+limit)
    xdata = x[start:L]
    plot(range(len(xdata)), xdata.real ) 
    hold(True)
    plot(range(len(xdata)), xdata.imag, 'r')
    #plot(numpy.abs(x[start:L] ) )
    grid()
    print "plotting ..."
    show()
    print "quitting ..."
    fname = "/tmp/uuu"
    FILE = open(fname, "w")
    format = '<'+"ff"*len(x)
    args = tuple(numpy.array((x.real,x.imag)).transpose().flatten() )
    s = struct.pack(format, *args )
    FILE.write(s)
    FILE.close()