本文整理汇总了Python中uhd_interface.uhd_transmitter.add_options函数的典型用法代码示例。如果您正苦于以下问题:Python add_options函数的具体用法?Python add_options怎么用?Python add_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_options函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例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)")
示例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)
示例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
示例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()
示例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
示例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)
示例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]")
示例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]")
示例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
示例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()
示例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
示例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)