• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python receive_path.add_options函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中receive_path.receive_path.add_options函数的典型用法代码示例。如果您正苦于以下问题:Python add_options函数的具体用法?Python add_options怎么用?Python add_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了add_options函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main():
    global n_rcvd, n_right

    n_rcvd = 0
    n_right = 0
    
    def rx_callback(ok, payload):
        global n_rcvd, n_right
        (pktno,) = struct.unpack('!H', payload[0:2])
        # Xu: Calculate raw BER
        CalcBER(payload[2:])

        n_rcvd += 1
        if ok:
            n_right += 1

        print "ok = %5s  pktno = %4d  n_rcvd = %4d  n_right = %4d" % (
            ok, pktno, n_rcvd, n_right)

    demods = digital.modulation_utils.type_1_demods()

    # Create Options Parser:
    parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    parser.add_option("-m", "--modulation", type="choice", choices=demods.keys(), 
                      default='psk',
                      help="Select modulation from: %s [default=%%default]"
                            % (', '.join(demods.keys()),))
    parser.add_option("","--from-file", default=None,
                      help="input file of samples to demod")

    receive_path.add_options(parser, expert_grp)
    uhd_receiver.add_options(parser)

    for mod in demods.values():
        mod.add_options(expert_grp)

    (options, args) = parser.parse_args ()

    if len(args) != 0:
        parser.print_help(sys.stderr)
        sys.exit(1)

    if options.from_file is None:
        if options.rx_freq is None:
            sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
            parser.print_help(sys.stderr)
            sys.exit(1)


    # build the graph
    tb = my_top_block(demods[options.modulation], rx_callback, options)

    r = gr.enable_realtime_scheduling()
    if r != gr.RT_OK:
        print "Warning: Failed to enable realtime scheduling."

    tb.start()        # start flow graph
    tb.wait()         # wait for it to finish
开发者ID:chenxugz,项目名称:coop,代码行数:60,代码来源:benchmark_rx.py


示例2: add_options

    def add_options(normal, expert):
        """
        Adds usrp-specific options to the Options Parser
        """
        add_freq_option(normal)
        normal.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
                          help="select USRP Tx side A or B")
        normal.add_option("-v", "--verbose", action="store_true", default=False)

        expert.add_option("", "--tx-freq", type="eng_float", default=None,
                          help="set transmit frequency to FREQ [default=%default]", metavar="FREQ")
        expert.add_option("-i", "--interp", type="intx", default=256,
                          help="set fpga interpolation rate to INTERP [default=%default]")
       
        normal.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
                          help="select USRP Rx side A or B")
        normal.add_option("", "--rx-gain", type="eng_float", default=None, metavar="GAIN",
                          help="set receiver gain in dB [default=midpoint].  See also --show-rx-gain-range")
        normal.add_option("", "--show-rx-gain-range", action="store_true", default=False, 
                          help="print min and max Rx gain available on selected daughterboard")
        normal.add_option("-v", "--verbose", action="store_true", default=False)

        expert.add_option("", "--rx-freq", type="eng_float", default=None,
                          help="set Rx frequency to FREQ [default=%default]", metavar="FREQ")
        expert.add_option("-d", "--decim", type="intx", default=128,
                          help="set fpga decimation rate to DECIM [default=%default]")
        expert.add_option("", "--snr", type="eng_float", default=30,
                          help="set the SNR of the channel in dB [default=%default]")

        #other necessary options
        transmit_path.add_options(normal, expert)
        receive_path.add_options(normal, expert)
        blks2.ofdm_mod.add_options(normal, expert)
        blks2.ofdm_demod.add_options(normal, expert)
        fusb_options.add_options(expert)
开发者ID:jfwang213,项目名称:graduate_demo,代码行数:35,代码来源:transceiver.py


示例3: parse_args

def parse_args():
    # enable real time scheduling
    r = gr.enable_realtime_scheduling()
    if r != gr.RT_OK:
        print "Warning: failed to enable real time scheduling"
        
    # parse parameters
    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    expert_grp.add_option("-c", "--carrier_threshold", type="eng_float", default=meta_data.default_carrier_thredshold,
                      help="set carrier detect threshold (dB) [default=%default]")
    parser.add_option("-i","--id", default=meta_data.default_id,
                      help="id: check out meta_data.py also.")
    
    receive_path.add_options(parser, expert_grp)
    uhd_receiver.add_options(parser)
    digital.ofdm_demod.add_options(parser, expert_grp)
    transmit_path.add_options(parser, expert_grp)
    digital.ofdm_mod.add_options(parser, expert_grp)
    uhd_transmitter.add_options(parser)

    (options, args) = parser.parse_args ()
    if int(options.id) == meta_data.default_id:
        print int(options.id)
        sys.stderr.write("You must specify -i ID or --id ID\n")
        parser.print_help(sys.stderr)
        sys.exit(1)
    else:
        options.rx_freq = meta_data.channels_freq_table[meta_data.init_channel_num] * 1e9
        options.tx_freq = meta_data.channels_freq_table[meta_data.init_channel_num] * 1e9
        options.bandwidth = (meta_data.default_bandwidth * 10000000.0)/4
    return options
开发者ID:xiaov58,项目名称:Coolest_Path,代码行数:32,代码来源:crn_main.py


示例4: main

def main():

    global n_rcvd, n_right
        
    n_rcvd = 0
    n_right = 0

    def rx_callback(ok, payload):
        global n_rcvd, n_right
        n_rcvd += 1
        
        if len(payload) > 2:
            (pktno,) = struct.unpack('!H', payload[0:2])
            if ok:
                n_right += 1
        else:
            pktno = -1
            
        print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right)

        if 0:
            printlst = list()
            for x in payload[2:]:
                t = hex(ord(x)).replace('0x', '')
                if(len(t) == 1):
                    t = '0' + t
                printlst.append(t)
            printable = ''.join(printlst)

            print printable
            print "\n"

    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    parser.add_option("","--discontinuous", action="store_true", default=False,
                      help="enable discontinuous")
    parser.add_option("","--from-file", default=None,
                      help="input file of samples to demod")

    receive_path.add_options(parser, expert_grp)
    uhd_receiver.add_options(parser)
    digital.ofdm_demod.add_options(parser, expert_grp)

    (options, args) = parser.parse_args ()

    if options.from_file is None:
        if options.rx_freq is None:
            sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
            parser.print_help(sys.stderr)
            sys.exit(1)

    # build the graph
    tb = my_top_block(rx_callback, options)

    r = gr.enable_realtime_scheduling()
    if r != gr.RT_OK:
        print "Warning: failed to enable realtime scheduling"

    tb.start()                      # start flow graph
    tb.wait()                       # wait for it to finish
开发者ID:ychang,项目名称:gr-gtlib,代码行数:60,代码来源:benchmark_rx.py


示例5: main

def main():
    parser = OptionParser(conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    rx_top_block.add_options(parser)
    receive_path.add_options(parser, expert_grp)
    uhd_receiver.add_options(parser)
    (options, args) = parser.parse_args()
    if options.cfg is not None:
        (options,args) = parser.parse_args(files=[options.cfg])
        print "Using configuration file %s" % ( options.cfg )

    tb = rx_top_block(options)

    if options.dot_graph:
        # write a dot graph of the flowgraph to file
        dot_str = tb.dot_graph()
        file_str = os.path.expanduser('rx_ofdm.dot')
        dot_file = open(file_str,'w')
        dot_file.write(dot_str)
        dot_file.close()

    try:
        tb.run()
    except [[KeyboardInterrupt]]:
        pass
开发者ID:WindyCitySDR,项目名称:gr-ofdm,代码行数:25,代码来源:rx_mimo.py


示例6: main

def main():
    global n_rcvd, n_right

    n_rcvd = 0
    n_right = 0
    
    def rx_callback(ok, payload):
        global n_rcvd, n_right
        n_rcvd += 1
        if ok:
            n_right += 1

        tb.audio_tx.msgq().insert_tail(gr.message_from_string(payload))
        
        print "ok = %r  n_rcvd = %4d  n_right = %4d" % (
            ok, n_rcvd, n_right)

    demods = digital.modulation_utils.type_1_demods()

    # Create Options Parser:
    parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    parser.add_option("-m", "--modulation", type="choice", choices=demods.keys(), 
                      default='gmsk',
                      help="Select modulation from: %s [default=%%default]"
                            % (', '.join(demods.keys()),))
    parser.add_option("-O", "--audio-output", type="string", default="",
                      help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
    parser.add_option("","--from-file", default=None,
                      help="input file of samples to demod")
    receive_path.add_options(parser, expert_grp)
    uhd_receiver.add_options(parser)

    for mod in demods.values():
        mod.add_options(expert_grp)

    parser.set_defaults(bitrate=50e3)  # override default bitrate default
    (options, args) = parser.parse_args ()

    if len(args) != 0:
        parser.print_help(sys.stderr)
        sys.exit(1)

    if options.from_file is None:
        if options.rx_freq is None:
            sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
            parser.print_help(sys.stderr)
            sys.exit(1)


    # build the graph
    tb = my_top_block(demods[options.modulation], rx_callback, options)

    r = gr.enable_realtime_scheduling()
    if r != gr.RT_OK:
        print "Warning: Failed to enable realtime scheduling."

    tb.run()
开发者ID:manuts,项目名称:stop-and-wait-arq,代码行数:59,代码来源:rx_voice.py


示例7: main

def main():

    source_file = open("sample_audio", 'r')

    def send_pkt(payload='', eof=False):
        (no,) = (struct.unpack('!H', payload[0:2]))
        print "sending packet %4d " % (no)
        return tb.txpath.send_pkt(payload, eof)

    def rx_callback(ok, payload):
        (no,) = (struct.unpack('!H', payload[0:2]))
        print "ok = %5s  pktno = %4d " % (
            ok, no)

    mods = digital.modulation_utils.type_1_mods()
    demods = digital.modulation_utils.type_1_demods()
    
    # Create Options Parser:
    parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(), 
                      default='psk',
                      help="Select modulation from: %s [default=%%default]"
                            % (', '.join(mods.keys()),))
    parser.add_option("-s", "--size", type="eng_float", default=1500,
                      help="set packet size [default=%default]")

    transmit_path.add_options(parser, expert_grp)
    uhd_transmitter.add_options(parser)
    receive_path.add_options(parser, expert_grp)
    uhd_receiver.add_options(parser)
    
    for mod in mods.values():
        mod.add_options(expert_grp)
    for mod in demods.values():
        mod.add_options(expert_grp)

    (options, args) = parser.parse_args ()

    tb = my_top_block(mods[options.modulation], demods[options.modulation], rx_callback, options)

    pkt_size = int(options.size)
    data = source_file.read(pkt_size - 2)
    sequence_no = 0

    tb.start()
    while data != '':
        payload = struct.pack('!H', sequence_no & 0xffff) + data
        send_pkt(payload)
        data = source_file.read(pkt_size - 2)
        sequence_no += 1

    send_pkt(eof=True)
    tb.wait()
开发者ID:manuts,项目名称:stop-and-wait-arq,代码行数:55,代码来源:independent_txrx.py


示例8: main

def main():

    global n_rcvd, n_right
        
    n_rcvd = 0
    n_right = 0

    def rx_callback(ok, payload):
        global n_rcvd, n_right
        n_rcvd += 1
        (pktno,) = struct.unpack('!H', payload[0:2])
        if ok:
            n_right += 1
        print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right)

        if 0:
            printlst = list()
            for x in payload[2:]:
                t = hex(ord(x)).replace('0x', '')
                if(len(t) == 1):
                    t = '0' + t
                printlst.append(t)
            printable = ''.join(printlst)

            print printable
            print "\n"

    usage = "usage: %prog [options] host"
    parser = OptionParser(usage=usage, option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    parser.add_option("","--discontinuous", action="store_true", default=False,
                      help="enable discontinuous")

    my_top_block.add_options(parser, expert_grp)
    receive_path.add_options(parser, expert_grp)
    blks2.ofdm_mod.add_options(parser, expert_grp)
    blks2.ofdm_demod.add_options(parser, expert_grp)

    (options, args) = parser.parse_args ()
    address = args[0]

    # build the graph
    tb = my_top_block(address, rx_callback, options)

    #r = gr.enable_realtime_scheduling()
    #if r != gr.RT_OK:
    #    print "Warning: failed to enable realtime scheduling"

    tb.start()                      # start flow graph
    tb.wait()                       # wait for it to finish
开发者ID:GREO,项目名称:gnuradio-git,代码行数:50,代码来源:benchmark_ofdm_rx.py


示例9: main

def main():
    global file
    
    def rx_callback(ok, payload):
        if ok:
            file.write(payload)

    demods = digital.modulation_utils.type_1_demods()

    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    parser.add_option("-m", "--modulation", type="choice", choices=demods.keys(),
                      default='psk',
                      help="Select modulation from :%s [default=%%default]"
                            % (', '.join(demods.keys()),))

    parser.add_option("-s", "--size", type="eng_float", default=1500,
                      help="set packet size [default=%default]")
    parser.add_option("","--samples-file", default=None,
                      help="Output file for modulated samples")
    parser.add_option("","--to-file", default=None,
                      help="Output file for demodulated contents")

    receive_path.add_options(parser, expert_grp)

    for mod in demods.values():
        mod.add_options(expert_grp)
 
    (options, args) = parser.parse_args()

    if len(args) != 0:
       parser.print_help()
       sys.exit(1)

    if options.to_file is not None:
        file = open(options.to_file, "w+")  
 
    tb = loop_top_block(demods[options.modulation], options, rx_callback)

    # do we need to do this for our test bench?
    r = gr.enable_realtime_scheduling()
    if r != gr.RT_OK:
        print "Warning: failed to enable realtime scheduling"
    
    tb.start()
    tb.wait()
开发者ID:randyp1248,项目名称:darpa,代码行数:47,代码来源:ut_rx.py


示例10: add_options

    def add_options(normal, expert_grp, channel_grp):
        
        mods = digital.modulation_utils.type_1_mods()
        for mod in mods.values():
                mod.add_options(expert_grp)        
                
        usrp_options.add_options(normal,expert_grp)
        uhd_transmitter.add_options(expert_grp)
        uhd_receiver.add_options(expert_grp)
        
        transmit_path.add_options(normal,expert_grp)        
        receive_path.add_options(normal,expert_grp)        
        channel_emulator.add_options(normal,channel_grp)

        expert_grp.add_option("","--use-whitener-offset", action="store_true", default=False,
                          help="make sequential packets use different whitening")

        expert_grp.add_option("","--down-sample-rate", type="intx", default=1,
                          help="Select the software down-sampling rate [default=%default]")
开发者ID:ychang,项目名称:gr-gtlib,代码行数:19,代码来源:cnPHY.py


示例11: __init__

    def __init__(self, midFreq, fft_len, occupied_len, cp_len, dinter, callback = None):
        if midFreq == None or fft_len == None or \
            occupied_len == None or cp_len == None:
            print 'param is not ok!'
            return

        if callback == None:
            callback = self.rx_callback
        args = ['-d', str(dinter), '-R', 'B', '-v']        
        args.append('-f')
        args.append(str(midFreq))
        args.append('--fft-length')
        args.append(str(fft_len))
        args.append('--occupied-tones')
        args.append(str(occupied_len))
        args.append('--cp-length')
        args.append(str(cp_len))
        
        parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
        expert_grp = parser.add_option_group("Expert")

        my_top_block.add_options(parser, expert_grp)
        receive_path.add_options(parser, expert_grp)
        blks2.ofdm_mod.add_options(parser, expert_grp)
        blks2.ofdm_demod.add_options(parser, expert_grp)
        fusb_options.add_options(expert_grp)

        (options, args) = parser.parse_args (args)
        
        self.tb = my_top_block(callback, options)

        r = gr.enable_realtime_scheduling()
        if r != gr.RT_OK:
            print 'Warning: failed to enable realtime scheduling'

        self.n_rcvd = 0
        self.n_right = 0
        
        print 'rx init ok!'
开发者ID:jfwang213,项目名称:graduate_demo,代码行数:39,代码来源:ofdm_rx.py


示例12: main

def main():

    global n_rcvd, n_right
        
    n_rcvd = 0
    n_right = 0

    def rx_callback(ok, payload):
        global n_rcvd, n_right
        n_rcvd += 1
        (pktno,) = struct.unpack('!H', payload[0:2])
        if ok:
            n_right += 1
        print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right)



    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    receive_path.add_options(parser, expert_grp)
    uhd_receiver.add_options(parser)
    digital.ofdm_demod.add_options(parser, expert_grp)

    (options, args) = parser.parse_args ()


    # build the graph
    tb = my_top_block(rx_callback, options)

    r = gr.enable_realtime_scheduling()
    if r != gr.RT_OK:
        print "Warning: failed to enable realtime scheduling"

    tb.start()                      # start flow graph
    tb.wait()                       # wait for it to finish
开发者ID:xiaov58,项目名称:Coolest_Path,代码行数:36,代码来源:benchmark_rx.py


示例13: main

def main():
    mods = digital.modulation_utils.type_1_mods()
    demods = digital.modulation_utils.type_1_demods()
    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(),
                      default='bpsk',
                      help="Select modulation from: %s [default=%%default]"
                            % (', '.join(mods.keys()),))

    parser.add_option("-s", "--size", type="eng_float", default=100,
                      help="set packet size [default=%default]")
    parser.add_option("-M", "--megabytes", type="eng_float", default=1.0,
                      help="set megabytes to transmit [default=%default]")
    parser.add_option("","--discontinuous", action="store_true", default=False,
                      help="enable discontinous transmission (bursts of 5 packets)")
    parser.add_option("","--from-file", default=None,
                      help="use intput file for packet contents")
    parser.add_option("","--to-file", default=None,
                      help="Output file for modulated samples")
    parser.add_option("", "--mac", default=None , help = "MAC addres")
    parser.add_option("", "--version", default='6' , help = "gnuradio version, default 6 (3.6)")
    parser.add_option("", "--mac_dst", default=None , help = "Destination MAC addres")
     
    tp36.add_options(parser, expert_grp)
    tp37.add_options(parser, expert_grp)

    uhd_transmitter.add_options(parser)
  
    rp36.add_options(parser, expert_grp)
    rp37.add_options(parser, expert_grp)
    uhd_receiver.add_options(parser)

    for mod in demods.values():
        mod.add_options(expert_grp)
    for mod in mods.values():
        mod.add_options(expert_grp)
    (options, args) = parser.parse_args ()
    if len(args) != 0:
        parser.print_help()
        sys.exit(1)           
    if options.from_file is not None:
        source_file = open(options.from_file, 'r')
    r = gr.enable_realtime_scheduling()
    if r != gr.RT_OK:
        print "Warning: failed to enable realtime scheduling"
    q_tx =Queue.Queue(10)
    q_rx =Queue.Queue(10) 
    l1=StartL1(q_rx,q_tx,options,mods[options.modulation],demods[options.modulation])
    l1.start()
    schL1_L2= StartSchedL1_L2(q_rx,q_tx,options.mac)
    schL1_L2.start()
# POR AHORA NO USO CAPA MAC
#    l2Mgmt=StartL2Mgmt(schL1_L2.mgmt_q1,schL1_L2.tx_ev_q,options.mac,"256","Red IIE")
#    l2Mgmt.start()

    l3= schedLayer3.Layer3(schL1_L2.tx_ev_q,schL1_L2.data_q,'/dev/net/tun',options.mac,options.mac_dst)

    c = raw_input('Press #z to end, or #w to test commands :')        
    while c != "#z":
       c = raw_input('Press #z to end, or #w to test commands :')        
           
    print "Program ends"
    l3.stop()
    schL1_L2.stop()
    l1.stop()
    #POR AHORA NO ESTOY USANDO CAPA 2
#    l2.stop()
    exit(0)
开发者ID:git-artes,项目名称:GNUnetwork,代码行数:70,代码来源:run_nodeL3.py


示例14: main

def main():

    global n_right
    n_right = 0 

    start_time = time.time()

    parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    parser.add_option("-m", "--modulation", type="choice", choices=['bpsk', 'qpsk'],
                      default='bpsk',
                      help="Select modulation from: bpsk, qpsk [default=%%default]")
    expert_grp.add_option("-c", "--carrier-threshold", type="eng_float", default=40,
                      help="set carrier detect threshold (dB) [default=%default]")

    parser.add_option("-v","--verbose", action="store_true", default=False)

    # linklab, add option to indicate sender or receiver
    parser.add_option("-s","--sender", action="store_true", default=False)
    parser.add_option("-r","--receiver", action="store_true", default=False)


    usrp_graph.add_options(parser, expert_grp)
    transmit_path.add_options(parser, expert_grp)
    receive_path.add_options(parser, expert_grp)
    blks2.ofdm_mod.add_options(parser, expert_grp)
    blks2.ofdm_demod.add_options(parser, expert_grp)

    fusb_options.add_options(expert_grp)

    (options, args) = parser.parse_args ()
    options.carrier_map = SYNC_MAP
    
    if len(args) != 0:
        parser.print_help(sys.stderr)
        sys.exit(1)

    if options.rx_freq is None or options.tx_freq is None:
        sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
        parser.print_help(sys.stderr)
        sys.exit(1)
    
	# linklab, check if the current node is either a sender or a receiver
    if options.sender and options.receiver:
        sys.stderr.write("You cannot specify both sender and receiver\n")
        sys.exit(1)
    if (not options.sender) and (not options.receiver):
        sys.stderr.write("You must specify either sender or receiver\n")
        sys.exit(1)
    #

    # Attempt to enable realtime scheduling
    r = gr.enable_realtime_scheduling()
    if r == gr.RT_OK:
        realtime = True
    else:
        realtime = False
        print "Note: failed to enable realtime scheduling"


    # If the user hasn't set the fusb_* parameters on the command line,
    # pick some values that will reduce latency.

    if options.fusb_block_size == 0 and options.fusb_nblocks == 0:
        if realtime:                        # be more aggressive
            options.fusb_block_size = gr.prefs().get_long('fusb', 'rt_block_size', 1024)
            options.fusb_nblocks    = gr.prefs().get_long('fusb', 'rt_nblocks', 16)
        else:
            options.fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 4096)
            options.fusb_nblocks    = gr.prefs().get_long('fusb', 'nblocks', 16)
    
    #print "fusb_block_size =", options.fusb_block_size
    #print "fusb_nblocks    =", options.fusb_nblocks

    # instantiate the MAC
    # linklab, use ssma instead of csma
	mac = ss_mac(options.sender, start_time, verbose=True)

    # update freq_offset
    options.rx_freq += get_freq_offset()
    options.tx_freq += get_freq_offset()
    print "RX frequency", options.rx_freq
    print "TX frequency", options.tx_freq

    # build the graph (PHY)
    tb = usrp_graph(mac.ReceivePacket, options)

    mac.set_flow_graph(tb)    # give the MAC a handle for the PHY

    #if fg.txpath.bitrate() != fg.rxpath.bitrate():
    #    print "WARNING: Transmit bitrate = %sb/sec, Receive bitrate = %sb/sec" % (
    #        eng_notation.num_to_str(fg.txpath.bitrate()),
    #        eng_notation.num_to_str(fg.rxpath.bitrate()))
             
    print "modulation:     %s"   % (options.modulation,)
    print "freq:           %s"      % (eng_notation.num_to_str(options.tx_freq))
    # print "bitrate:        %sb/sec" % (eng_notation.num_to_str(tb.txpath.bitrate()),)
    # print "samples/symbol: %3d" % (tb.txpath.samples_per_symbol(),)
    # print "interp:         %3d" % (tb.txpath.interp(),)
#.........这里部分代码省略.........
开发者ID:tyc85,项目名称:nwsdr-3.6.3-dsc,代码行数:101,代码来源:ssma.py


示例15: main

def main():
    global pkts_rcvd
    global EOF_rcvd
    global num_acks
    
    
    ###########################
    #set up options
    ###########################
    parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    parser.add_option("-m", "--modulation", type="choice", choices=['bpsk', 'qpsk'],
                      default='bpsk',
                      help="Select modulation from: bpsk, qpsk [default=%%default]")
    parser.add_option("-v","--verbose", action="store_true", default=False)
    parser.add_option("-p","--packets", type="int", default = 3000, 
                      help="set number of packets to send [default=%default]")
    parser.add_option("", "--address", type="string", default = None,
                      help="set the address of the node (addresses are a single char) [default=%default]")
    expert_grp.add_option("-c", "--carrier-threshold", type="eng_float", default=-20,
                      help="set carrier detect threshold (dB) [default=%default]")
    parser.add_option("", "--pkt-gen-time", type="eng_float", default=.05,
                      help="set the time between sending each packet (s) [default=%default]")
    parser.add_option("", "--pkt-padding", type="int", default=1000,
                      help="pad packet with pkt-padding number of extra chars [default=%default]")
    parser.add_option("","--autoselect-freq", action="store_true", default=False)
    parser.add_option("", "--test-time", type="int", default=500,
                      help="number of seconds to run the test for [default=%default]")

                      
    usrp_graph.add_options(parser, expert_grp)
    transmit_path.add_options(parser, expert_grp)
    receive_path.add_options(parser, expert_grp)
    blks2.ofdm_mod.add_options(parser, expert_grp)
    blks2.ofdm_demod.add_options(parser, expert_grp)
    cs_mac.add_options(parser, expert_grp)
    sense_path.add_options(parser, expert_grp)

    (options, args) = parser.parse_args ()
    if len(args) != 0:
        parser.print_help(sys.stderr)
        sys.exit(1)

    #if options.rx_freq is None or options.tx_freq is None:
    #    sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
    #    parser.print_help(sys.stderr)
    #    sys.exit(1)
    if options.address is None:
    	sys.stderr.write("You must specify a node address\n")
    	parser.print_help(sys.stderr)
    	sys.exit(1)


    
    ###########################
    #set PHY and MAC
    ###########################
    # Attempt to enable realtime scheduling
    r = gr.enable_realtime_scheduling()
    if r == gr.RT_OK:
        realtime = True
    else:
        realtime = False
        print "Note: failed to enable realtime scheduling"

    pkts_sent = 0
    # instantiate the MAC
    mac = cs_mac(options, rx_callback)


    # build the graph (PHY)
    tx_failures = []
    tb = usrp_graph(mac.phy_rx_callback, options)

    mac.set_flow_graph(tb)    # give the MAC a handle for the PHY
    mac.set_error_array(tx_failures)
 
 
    ###########################
    #manage packet generation and data gathering
    ###########################
    print
    print "address:        %s"   % (options.address)
    print
    print "modulation:     %s"   % (options.modulation,)
    #print "freq:           %s"   % (eng_notation.num_to_str(options.tx_freq))

    tb.rxpath.set_carrier_threshold(options.carrier_threshold)
    print "Carrier sense threshold:", options.carrier_threshold, "dB"

    tb.start()    # Start executing the flow graph (runs in separate threads)

    if options.autoselect_freq:
        new_freq = mac.find_best_freq()
        raw_input("Press Enter to begin transmitting") 

    #n = 0
    #while n < 50:
    #    os.system("clear")
    #    new_freq = mac.find_best_freq()
#.........这里部分代码省略.........
开发者ID:SanabriaRusso,项目名称:uhd_ofdm,代码行数:101,代码来源:qpcsmaca_test.py


示例16: main

def main():

    mods = modulation_utils.type_1_mods()
    demods = modulation_utils.type_1_demods()

    parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(),
                      default='gmsk',
                      help="Select modulation from: %s [default=%%default]"
                            % (', '.join(mods.keys()),))

    parser.add_option("-v","--verbose", action="store_true", default=False)
    parser.add_option("-n", "--nodeid", type="int", default=None,
                              help="specify node ID")
    expert_grp.add_option("-c", "--carrier-threshold", type="eng_float", default=30,
                          help="set carrier detect threshold (dB) [default=%default]")
    expert_grp.add_option("","--tun-device-filename", default="/dev/net/tun",
                          help="path to tun device file [default=%default]")

    transmit_path.add_options(parser, expert_grp)
    receive_path.add_options(parser, expert_grp)

    for mod in mods.values():
        mod.add_options(expert_grp)

    for demod in demods.values():
        demod.add_options(expert_grp)

    fusb_options.add_options(expert_grp)

    (options, args) = parser.parse_args ()
    if len(args) != 0:
        parser.print_help(sys.stderr)
        sys.exit(1)

    if options.rx_freq is None or options.tx_freq is None:
        sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
        parser.print_help(sys.stderr)
        sys.exit(1)

    # open the TUN/TAP interface
    #(tun_fd, tun_ifname) = open_tun_interface(options.tun_device_filename)

    # Attempt to enable realtime scheduling
    r = gr.enable_realtime_scheduling()
    if r == gr.RT_OK:
        realtime = True
    else:
        realtime = False
        print "Note: failed to enable realtime scheduling"


    # If the user hasn't set the fusb_* parameters on the command line,
    # pick some values that will reduce latency.

    if options.fusb_block_size == 0 and options.fusb_nblocks == 0:
        if realtime:                        # be more aggressive
            options.fusb_block_size = gr.prefs().get_long('fusb', 'rt_block_size', 1024)
            options.fusb_nblocks    = gr.prefs().get_long('fusb', 'rt_nblocks', 16)
        else:
            options.fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 4096)
            options.fusb_nblocks    = gr.prefs().get_long('fusb', 'nblocks', 16)
    
    #print "fusb_block_size =", options.fusb_block_size
    #print "fusb_nblocks    =", options.fusb_nblocks

    # instantiate the MAC
    mac = cs_mac(verbose=False)

    # build the graph (PHY)
    tb = my_top_block(mods[options.modulation],
                      demods[options.modulation],
                      mac.phy_rx_callback,
                      options)

    mac.set_top_block(tb)    # give the MAC a handle for the PHY

    if tb.txpath.bitrate() != tb.rxpath.bitrate():
        print "WARNING: Transmit bitrate = %sb/sec, Receive bitrate = %sb/sec" % (
            eng_notation.num_to_str(tb.txpath.bitrate()),
            eng_notation.num_to_str(tb.rxpath.bitrate()))
             
    print "modulation:     %s"   % (options.modulation,)
    print "freq:           %s"      % (eng_notation.num_to_str(options.tx_freq))
    print "bitrate:        %sb/sec" % (eng_notation.num_to_str(tb.txpath.bitrate()),)
    print "samples/symbol: %3d" % (tb.txpath.samples_per_symbol(),)
    #print "interp:         %3d" % (tb.txpath.interp(),)
    #print "decim:          %3d" % (tb.rxpath.decim(),)

    tb.rxpath.set_carrier_threshold(options.carrier_threshold)


    tb.start()    # Start executing the flow graph (runs in separate threads)
开发者ID:nesl,项目名称:uant,代码行数:95,代码来源:usrp_tos.py


示例17: main

def main():
    global n_rcvd, n_right, per_wait, last_n_rcvd, freq_offset

    per_wait = 0.2
    freq_offset = 625000

    n_rcvd = 0
    n_right = 0
    
    def rx_callback(ok, payload):
        global n_rcvd, n_right
        (pktno,) = struct.unpack('!H', payload[0:2])
        n_rcvd += 1
        if ok:
            n_right += 1

        print "ok = %5s  pktno = %4d  n_rcvd = %4d  n_right = %4d" % (
            ok, pktno, n_rcvd, n_right)

    demods = digital.modulation_utils.type_1_demods()

    # Create Options Parser:
    parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    parser.add_option("-m", "--modulation", type="choice", choices=demods.keys(), 
                      default='dqpsk',
                      help="Select modulation from: %s [default=%%default]"
                            % (', '.join(demods.keys()),))
    parser.add_option("","--from-file", default=None,
                      help="input file of samples to demod")

    receive_path.add_options(parser, expert_grp)
    uhd_receiver.add_options(parser)

    for mod in demods.values():
        mod.add_options(expert_grp)

    (options, args) = parser.parse_args ()

    if len(args) != 0:
        parser.print_help(sys.stderr)
        sys.exit(1)

    if options.from_file is None:
        if options.rx_freq is None:
            sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
            parser.print_help(sys.stderr)
            sys.exit(1)


    # build the graph
    tb = my_top_block(demods[options.modulation], rx_callback, options)

    r = gr.enable_realtime_scheduling()
    if r != gr.RT_OK:
        print "Warning: Failed to enable realtime scheduling."

    tb.start()        # start flow graph

    last_n_rcvd = n_rcvd
    cur_freq_offset = freq_offset
    tb.source.set_freq(options.rx_freq+cur_freq_offset)
    
    while 1:
        global n_rcvd, n_right, per_wait, last_n_rcvd, freq_offset
        
        time.sleep(per_wait)
        if last_n_rcvd == n_rcvd:
            if cur_freq_offset > 0:
                cur_freq_offset = 0-freq_offset
            else:
                cur_freq_offset = freq_offset

            print "Switching frequency to %d\n" % (options.rx_freq+cur_freq_offset)
            tb.source.set_freq(options.rx_freq+cur_freq_offset)

        else:
            print "Not switching frequencies since we are still receiving\n"
            last_n_rcvd = n_rcvd

    tb.wait()         # wait for it to finish
开发者ID:randyp1248,项目名称:darpa,代码行数:82,代码来源:benchmark_rx.py


示例18: main

def main():

    mods = digital.modulation_utils.type_1_mods()
    demods = digital.modulation_utils.type_1_demods()

    parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(),
                      default='gmsk',
                      help="Select modulation from: %s [default=%%default]"
                            % (', '.join(mods.keys()),))

    parser.add_option("-s", "--size", type="eng_float", default=1500,
                      help="set packet size [default=%default]")
    parser.add_option("-v","--verbose", action="store_true", default=False)
    expert_grp.add_option("-c", "--carrier-threshold", type="eng_float", default=30,
                          help=" 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python receiver.Receiver类代码示例发布时间:2022-05-26
下一篇:
Python receive_path.receive_path函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap