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

Python uhd_transmitter.add_options函数代码示例

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

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



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

示例1: main

def main():

    def send_pkt(payload='', eof=False):
        return tb.txpath.send_pkt(payload, eof)
    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    parser.add_option("-s", "--size", type="eng_float", default=400,
                      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 discontinuous mode")
    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")

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

    # 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()                       # start flow graph
    
    # generate and send packets
    nbytes = int(1e6 * options.megabytes)
    n = 0
    pktno = 0
    pkt_size = int(options.size)

    while n < nbytes:
        if options.from_file is None:
#            data = (pkt_size - 2) * (pktno & 0xff) 
             data = (pkt_size - 2) * 'a' 
        else:
            data = source_file.read(pkt_size - 2)
            if data == '':
                break;

        payload = struct.pack('!H', pktno & 0xffff) + data
        
        send_pkt(payload)
        n += len(payload)
#        sys.stderr.write('.')
        if options.discontinuous and pktno % 5 == 4:
            time.sleep(1)
        pktno += 1
#        print pktno, ' '
        print('payload = ', payload)
        
    send_pkt(eof=True)
    tb.wait()                       # wait for it to finish
开发者ID:cloudygoose,项目名称:gnuradio,代码行数:60,代码来源:benchmark_tx_test.py


示例2: main

def main():

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

    parser.add_option("-b", "--burst-length", type="int", default=50, 
                      help="Number of packets in each burst")
    parser.add_option("-t", "--sleep-time", type="int", default=100, 
                      help="sleep time (msec) between the bursts")
    parser.add_option("-s", "--server", type="string", default='idb2',
                      help="server hosting the packet server/sink")
    parser.add_option("-o", "--port", type="int", default='5123',
                      help="tcp port on the packet server/sink serving packets")
    parser.add_option("","--to-file", default=None,
                      help="Output file for modulated samples")

    uhd_transmitter.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.start()                       # start flow graph
        
    tb.wait()                       # wait for it to finish
开发者ID:randyp1248,项目名称:darpa,代码行数:35,代码来源:bot1_tx.py


示例3: main

def main():
    parser = OptionParser(conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    tx_top_block.add_options(parser)
    transmit_path.add_options(parser, expert_grp)
    uhd_transmitter.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 = tx_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('tx_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,代码来源:tx.py


示例4: add_options

def add_options(parser, expert):
	add_freq_option(parser)	
	transmit_path.transmit_path.add_options(parser, expert)
	expert.add_option("", "--tx-freq", type="eng_float", default=None, help="set transmit frequency to FREQ [default=%default]", metavar="FREQ")
	parser.add_option("-v", "--verbose", action="store_true", default=False)
	uhd_transmitter.add_options(parser)
	parser.add_option("", "--log", action="store_true", default=False,help="Log all parts of flow graph to file (CAUTION: lots of data)")
开发者ID:nagsrk,项目名称:ofdm_uhd,代码行数:7,代码来源:usrp_transmit_path.py


示例5: get_options

def get_options(mods):
    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    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("", "--amplitude", type="eng_float", default=0.2,
                      help="set Tx amplitude (0-1) (default=%default)")
    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]")
    parser.add_option("","--to-file", default=None,
                      help="Output file for modulated samples")
    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)

    uhd_transmitter.add_options(parser)

    for mod in mods.values():
        mod.add_options(parser)
		      
    (options, args) = parser.parse_args()
    if len(args) != 0:
        parser.print_help()
        sys.exit(1)
	
    return (options, args)
开发者ID:Jhr-Ronyo,项目名称:gnuradio-1,代码行数:30,代码来源:digital_bert_tx.py


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


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

    def send_pkt(payload='', eof=False, timeValid=False, timestamp=0):
        if eof:
            msg = gr.message(1)
        else:
            msg = gr.message_from_string(payload)
            if timeValid:
                secs = long(timestamp)
                frac_secs = timestamp - long(timestamp)
                msg.set_timestamp(secs, frac_secs)
        return tb.txpath.msgq().insert_tail(msg)    

    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    parser.add_option("-n", "--num", type="eng_float", default=1,
                      help="set number of packets [default=%default]")
    parser.add_option("","--data-file", default=None,
                      help="use complex input file for transmission")
    parser.add_option("","--to-file", default=None,
                      help="Output file for modulated samples")
    parser.add_option("-W", "--bandwidth", type="eng_float",
                      default=4e6,
                      help="set symbol bandwidth [default=%default]")
    parser.add_option("", "--amp", type="eng_float", default=1, 
                      help="set gain factor for complex baseband floats [default=%default]")

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

    # 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()                       # start flow graph
    
    ###########################################################################
    if options.data_file is None:
        sys.stderr.write("You must specify data file\n")
        parser.print_help(sys.stderr)
        sys.exit(1)

    print "End of Tx ..."
    time.sleep(1)
    ###########################################################################
    
    tb.wait()                       # wait for it to finish
开发者ID:UpYou,项目名称:gnuradio-tools,代码行数:52,代码来源:raw_filetx.py


示例9: add_options

 def add_options(normal, expert):
     """
     Adds usrp-specific options to the Options Parser
     """
     normal.add_option("", "--outfile", type="string",
                       help="select output file to modulate to")
     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("", "--amp", type="eng_float", default=1, metavar="AMPL",
                       help="set transmitter digital amplifier: [default=%default]")
     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]")
     expert.add_option("", "--log", action="store_true", default=False,
                       help="Log all parts of flow graph to files (CAUTION: lots of data)")
     uhd_transmitter.add_options(normal)
开发者ID:UpYou,项目名称:gr-ieee802-15-4,代码行数:17,代码来源:cc2420_txtest_uhd.py


示例10: add_options

    def add_options(normal, expert):
        """
        Adds usrp-specific options to the Options Parser
        """
        uhd_transmitter.add_options(normal)
    
        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)
        # 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("", "--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]")
开发者ID:jbruno,项目名称:gr_papyrus,代码行数:18,代码来源:benchmark_ofdm_tx.py


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


示例12: main

def main():

    def send_pkt(payload='', eof=False):
        return tb.txpath.send_pkt(payload, eof)

    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    parser.add_option("-s", "--size", type="eng_float", default=400,
                      help="set packet size [default=%default]")

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

    # 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()                       # start flow graph
    
    # generate and send packets
    pktno = 0
    pkt_size = int(options.size)

    while pktno < 200:
        pktno += 1
        data = (pkt_size - 2) * chr(pktno & 0xff) 
        payload = struct.pack('!H', pktno & 0xffff) + data
        send_pkt(payload)
        sys.stderr.write('.')
        
        
    time.sleep(1)
    send_pkt(eof=True)
    tb.wait()                       # wait for it to finish
开发者ID:xiaov58,项目名称:Coolest_Path,代码行数:40,代码来源:benchmark_tx.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: main

def main():

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

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

    (options, args) = parser.parse_args ()

    if len(args) != 0:
        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()        # start flow graph
    tb.wait()         # wait for it to finish
开发者ID:randyp1248,项目名称:darpa,代码行数:24,代码来源:rx_pingpong.py


示例15: 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("", "--outfile", type="string",
                     help="select output file to modulate to")
   normal.add_option("", "--txdata", type="string",
                     help="select data file")
   normal.add_option("", "--char", type="eng_float", default=0, metavar="CAMPL",
                     help="input is char file that should be scaled by CAMPL/128: [default=%default]")
   normal.add_option("", "--amp", type="eng_float", default=1, metavar="AMPL",
                     help="set transmitter digital amplifier: [default=%default]")
   normal.add_option("-v", "--verbose", action="store_true", default=False)
   normal.add_option("", "--repeat", 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_transmitter.add_options(normal)
   ofdm_rxtx.TX.add_options(normal, expert)
   ofdm_rxtx.sender_thread.add_options(normal)
开发者ID:UpYou,项目名称:ofdm,代码行数:24,代码来源:ofdm_tx.py


示例16: main

def main():

    def send_pkt(payload='', eof=False):
        return tb.txpath.send_pkt(payload, eof)

    mods = digital.modulation_utils.type_1_mods()

    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='dqpsk',
                      help="Select modulation from: %s [default=%%default]"
                            % (', '.join(mods.keys()),))

 #    parser.add_option("-s", "--size", type="eng_float", default=1442,
 #                     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")

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

    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')

    # build the graph
    tb = my_top_block(mods[options.modulation], options)
    ftb = filter_top_block(options)

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

    tb.start()                       # start flow graph
    ftb.start()
        
    # log parameter to OML
    cmd1 = "/root/OML/omlcli --out h2_benchmark --line \""
    cmd1 = cmd1 + " tx-freq=" + str(options.tx_freq)
    cmd1 = cmd1 + " modulation=" + str(options.modulation)
    cmd1 = cmd1 + " tx-gain=" + str(options.tx_gain)
    cmd1 = cmd1 + " bitrate=" + str(options.bitrate)
    cmd1 = cmd1 + " sps=" + str(options.samples_per_symbol)
    cmd1 = cmd1 + "\""

    from subprocess import os
    os.system(cmd1)


    # Fetch packets from server

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(10)
    TCP_IP='10.10.0.51'
    TCP_PORT=5123    
    try:
       s.connect((TCP_IP, TCP_PORT))
    except socket.timeout: 
       print"Connection timed out, try again later"
       return
    except socket.error:
       print"Connection error"
       return

    print "Setting frequency to %d\n" % (options.tx_freq+625000)
    tb.sink.set_freq(options.tx_freq+625000)
   
    n = 0
    pktno = 0
    pkt_size = int(1442)
    MESSAGE = struct.pack('!l',pkt_size-2)

    while 1: #n < nbytes:
        if options.from_file is None:
            try:
               s.send(MESSAGE)
               data=s.recv(pkt_size-2)
            except socket.timeout: 
               print"Connection timed out, try again later"
               return
            except socket.error:
               print"Connection closed"
               return
            if data.__len__() < 8:
#.........这里部分代码省略.........
开发者ID:randyp1248,项目名称:darpa,代码行数:101,代码来源:benchmark_tx3.py


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


示例18: main

def main():
    # Send packet function
    def send_pkt(payload='', eof=False):
        return tb.txpath.send_pkt(payload, eof)

    # Modulation initialization
    mods = digital.modulation_utils.type_1_mods()

    # Get user inputs
    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]")
    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")

    # Send options selected by user to transmit_path file
    transmit_path.add_options(parser, expert_grp)
    uhd_transmitter.add_options(parser)

    # Pass options selected to all modulator file (dbpsk, d8psk, dqpsk, gmsk...)
    for mod in mods.values():
        mod.add_options(expert_grp)

    # Parse command-line for errors
    (options, args) = parser.parse_args ()

    # Print errors and exit
    if len(args) != 0:
        parser.print_help()
        sys.exit(1)

    # Open the file which user wants to transmit       
    if options.from_file is not None:
        source_file = open(options.from_file, 'r')

    # build the graph
    # Constructing transmission flowgraph and pass pointer to variable called "tb"
    tb = my_top_block(mods[options.modulation], options)#--> got to def my_top_block

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

    # Start construction of flowgraph
    tb.start()                       # start flow graph
        
    # generate and send packets
    nbytes = int(1e6 * options.megabytes) # Total byte to send, From command-line
    n = 0        # 
    pktno = 0    # First packet number
    pkt_size = int(options.size) #Size of packet

    # send packets/file
    while n < nbytes:
	print "Sending: "+str(n)+"| bytes: "+str(nbytes)+ " | Packet Size: "+str(pkt_size)
        if options.from_file is None:# Generate packet (if raw data transmission chosen)
            data = (pkt_size - 2) * chr(pktno & 0xff) 
        else:  # Generate packet (if data from file is chosen)
            data = source_file.read(pkt_size - 2)
            if data == '':
                break;

        payload = struct.pack('!H', pktno & 0xffff) + data # Construct packet, the easy way
        send_pkt(payload)  # Send packet through send_pkt function --> see def send_pkt()
        n += len(payload) 
        sys.stderr.write('.')
	# If discontinues is selected then after a 4 byte send pause 1 second (Conjestion problem hack)
        if options.discontinuous and pktno % 5 == 4:
            time.sleep(1)
        pktno += 1

    # Tell send function that we are done sending        
    send_pkt(eof=True)

    # Keep running flowgraph until user kills it
    tb.wait()                       # wait for it to finish
开发者ID:travisfcollins,项目名称:Thesis,代码行数:90,代码来源:benchmark_tfc_tx.py


示例19: main

def main():

  

    def send_pkt(payload='', eof=False):
        return tb.txpath.send_pkt(payload, eof)

    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])
        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)
	
			

    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='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]")
    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")

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


    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')

    # build the graph
    tb = my_top_block(mods[options.modulation], 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
    #t = threading.Thread(target=dowork, args=(), name='worker')
    #t.start()

        
    # generate and send packets
    nbytes = int(1e6 * options.megabytes)
    n = 0
    sense_n=1
    pktno = 0
    pkt_size = int(options.size)
	

    while n < nbytes:
        if pktno%1000 == 0 and sense_n==1: #sence once
            #time.sleep(1)
            #tb.txgate.set_enabled(True)
            #time.sleep(.01)
            #tb.sensegate.set_enabled(True) #t
            #avail_subc_bin = tb.sensepath.GetAvailableSpectrum()
            #avail_subc_str = subc_bin2str(avail_subc_bin)
 #           print avail_subc_bin
            fftout=tb.sensepath.FFTresult()
            #fftout=tb.sensepath.GetPSD()
 
            sense_n=0
            #tb.txgate.set_enabled(True)
            #tb.sensegate.set_enabled(False)
        else:
            # linklab, loop to empty the lower layer buffers to avoid detecting old signals
            #send_pkt(eof=False)
            sense_n=1
#.........这里部分代码省略.........
开发者ID:tyc85,项目名称:nwsdr-3.6.3-dsc,代码行数:101,代码来源:benchmarkmulti_tx.py


示例20: main

def main():

    def send_pkt(payload='', eof=False):
        return tb.txpath.send_pkt(payload, eof)

    mods = digital.modulation_utils.type_1_mods()

    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]")
    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")

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

    for mod in mods.values( 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python ui.back函数代码示例发布时间:2022-05-27
下一篇:
Python uhd_receiver.add_options函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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