当前位置: 首页>>代码示例>>Python>>正文


Python uhd_receiver.add_options函数代码示例

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


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

示例1: 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

示例2: 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

示例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: get_options

def get_options(demods):
    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    parser.add_option("","--from-file", default=None,
                      help="input file of samples to demod")
    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("-r", "--bitrate", type="eng_float", default=250e3,
                      help="Select modulation bit rate (default=%default)")
    parser.add_option("-S", "--samples-per-symbol", type="float", default=2,
                      help="set samples/symbol [default=%default]")
    if not parser.has_option("--verbose"):
        parser.add_option("-v", "--verbose", action="store_true", default=False)
    if not parser.has_option("--log"):
        parser.add_option("", "--log", action="store_true", default=False,
                      help="Log all parts of flow graph to files (CAUTION: lots of data)")

    uhd_receiver.add_options(parser)

    demods = digital.modulation_utils.type_1_demods()
    for mod in demods.values():
        mod.add_options(parser)
		      
    (options, args) = parser.parse_args()
    if len(args) != 0:
        parser.print_help()
        sys.exit(1)
	
    return (options, args)
开发者ID:0x7678,项目名称:gnuradio-wg-grc,代码行数:30,代码来源:digital_bert_rx.py

示例6: add_options

def add_options(parser, expert):
	add_freq_option(parser)
	uhd_receiver.add_options(parser)
	receive_path.receive_path.add_options(parser, expert)
	expert.add_option("", "--rx-freq", type="eng_float", default=None,
					help="set Rx frequency to FREQ [default=%default]", metavar="FREQ")
	parser.add_option("-v", "--verbose", action="store_true", default=False)
开发者ID:nagsrk,项目名称:ofdm_uhd,代码行数:7,代码来源:usrp_receive_path_original.py

示例7: 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

示例8: 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

示例9: add_options

    def add_options(normal, expert):
        """
        Adds usrp-specific options to the Options Parser
        """
        uhd_receiver.add_options(normal)

        add_freq_option(normal)
        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)
        # linklab,  add options to specify which USRP to sue
        normal.add_option(
            "-w",
            "--which",
            type="int",
            default=0,
            help="select which USRP (0, 1, ...) default is %default",
            metavar="NUM",
        )

        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]"
        )
开发者ID:jbruno,项目名称:gr_papyrus,代码行数:48,代码来源:benchmark_ofdm_rx.py

示例10: add_options

 def add_options(normal, expert):
     """
     Adds usrp-specific options to the Options Parser
     """
     normal.add_option("", "--infile", type="string",
                       help="select input file to TX from")
     normal.add_option ("-c", "--channel", type="eng_float", default=17,
                       help="Set 802.15.4 Channel to listen on channel %default", metavar="FREQ")
     normal.add_option("-v", "--verbose", action="store_true", default=False)
     normal.add_option("-W", "--bandwidth", type="eng_float",
                       default=4000e3,
                       help="set symbol bandwidth [default=%default]")
     normal.add_option ("-t", "--threshold", type="int", default=-1)
     expert.add_option("", "--log", action="store_true", default=False,
                       help="Log all parts of flow graph to files (CAUTION: lots of data)")
     uhd_receiver.add_options(normal)
开发者ID:UpYou,项目名称:gr-ieee802-15-4,代码行数:16,代码来源:cc2420_rxtest_uhd.py

示例11: main

def main():
    global n_rcvd, n_right, start_time, stop_rcv
    
    TIMEOUT = 60 # 60sec for hurdle 2
    n_rcvd = 0
    n_right = 0
    #start_time = 0
    mstr_cnt = 0
    #stop_rcv = 0   

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

    parser.add_option("-s", "--server", type="string", default='idb2',
                      help="server hosting the packet server/sink")
    parser.add_option("-o", "--port", type="int", default='5125',
                      help="packet sink tcp port")
    parser.add_option("-i", "--timeout", type="int", default='300',help='receive timeout(sec)')
    parser.add_option("","--from-file", default=None,
                      help="input file of samples to demod")

    uhd_receiver.add_options(parser)

    (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(options)

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

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

示例12: 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

示例13: main

def main():

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

    uhd_transmitter.add_options(parser)
    uhd_receiver.add_options(parser)

    (options, args) = parser.parse_args()

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

    # build the graph
    tb = my_top_block(options)

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

    tb.run()
开发者ID:randyp1248,项目名称:darpa,代码行数:22,代码来源:tx.py

示例14: add_options

 def add_options(normal, expert):
   normal.add_option("", "--infile", type="string",
                     help="select input file")
   normal.add_option("", "--outfile", type="string",
                     help="select output file (raw)")
   normal.add_option("", "--txdata", type="string",
                     help="source data file")
   normal.add_option("", "--rxdata", type="string",
                     help="data file (demodulated)")
   normal.add_option("", "--char", type="eng_float", default=0, metavar="CAMPL",
                     help="output is char data that should be scaled by CAMPL/128: [default=%default]")
   normal.add_option("", "--snrdata", type="string",
                     help="per packet snr data file (- print out, . scope out)")
   normal.add_option("", "--snrmode", type="int", default=0,
                     help="0 - per symbol, 1 - per packet, 2 - per bin [default=%default]")
   normal.add_option("-v", "--verbose", action="store_true", default=False)
   normal.add_option("-W", "--bandwidth", type="eng_float",
                         default=500e3,
                         help="set symbol bandwidth [default=%default]")
   expert.add_option("", "--log", action="store_true", default=False,
                     help="Log all parts of flow graph to files (CAUTION: lots of data)")
   uhd_receiver.add_options(normal)
   #usrp2.add_options(normal)
   ofdm_rxtx.RX.add_options(normal, expert)
开发者ID:UpYou,项目名称:ofdm,代码行数:24,代码来源:ofdm_rx.py

示例15: 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


注:本文中的uhd_interface.uhd_receiver.add_options函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。