[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3654 - gnuradio/branches/developers/eb/digital-wip/gn
From: |
eb |
Subject: |
[Commit-gnuradio] r3654 - gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2 |
Date: |
Tue, 26 Sep 2006 20:13:01 -0600 (MDT) |
Author: eb
Date: 2006-09-26 20:13:01 -0600 (Tue, 26 Sep 2006)
New Revision: 3654
Modified:
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/rx_voice.py
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/tx_voice.py
Log:
Refactored to use updated receive_path and transmit_path.
Modified:
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/rx_voice.py
===================================================================
---
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/rx_voice.py
2006-09-27 02:12:20 UTC (rev 3653)
+++
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/rx_voice.py
2006-09-27 02:13:01 UTC (rev 3654)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005 Free Software Foundation, Inc.
+# Copyright 2005,2006 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,7 +20,7 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, gru, blks
+from gnuradio import gr, gru, modulation_utils
from gnuradio import usrp
from gnuradio import audio
from gnuradio import eng_notation
@@ -34,6 +34,7 @@
# from current dir
from receive_path import receive_path
+import fusb_options
#import os
#print os.getpid()
@@ -56,11 +57,9 @@
class my_graph(gr.flow_graph):
- def __init__(self, rx_subdev_spec, bitrate, decim_rate, spb, rx_callback,
log):
+ def __init__(self, demod_class, rx_callback, options):
gr.flow_graph.__init__(self)
- self.rxpath = receive_path(self, rx_subdev_spec, bitrate, decim_rate,
- spb, rx_callback, log)
-
+ self.rxpath = receive_path(self, demod_class, rx_callback, options)
self.audio_tx = audio_tx(self)
@@ -87,41 +86,42 @@
print "ok = %r n_rcvd = %4d n_right = %4d" % (
ok, n_rcvd, n_right)
- parser = OptionParser (option_class=eng_option)
- parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
- help="select USRP Rx side A or B")
- parser.add_option("-f", "--freq", type="eng_float", default=423.1e6,
- help="set Rx frequency to FREQ [default=%default]",
metavar="FREQ")
- parser.add_option("-r", "--bitrate", type="eng_float", default=100e3,
- help="specify bitrate. spb and interp will be derived.")
- parser.add_option("-S", "--spb", type="int", default=None, help="set
samples/baud [default=%default]")
- parser.add_option("-d", "--decim", type="intx", default=None,
- help="set fpga decim rate to DECIM [default=%default]")
- parser.add_option("-g", "--gain", type="eng_float", default=27,
- help="set rx gain")
- parser.add_option("","--log", action="store_true", default=False,
- help="enable diagnostic logging")
+ demods = 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()),))
+
+ receive_path.add_options(parser, expert_grp)
+
+ for mod in demods.values():
+ mod.add_options(expert_grp)
+
+ fusb_options.add_options(expert_grp)
(options, args) = parser.parse_args ()
if len(args) != 0:
- parser.print_help()
+ parser.print_help(sys.stderr)
sys.exit(1)
- if options.freq < 1e6:
- options.freq *= 1e6
+ 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
- fg = my_graph(options.rx_subdev_spec, options.bitrate,
- options.decim, options.spb, rx_callback, options.log)
+ fg = my_graph(demods[options.modulation], rx_callback, options)
- print "bitrate: %sb/sec" % (eng_notation.num_to_str(fg.rxpath.bitrate()),)
- print "spb: %3d" % (fg.rxpath.spb(),)
- print "decim: %3d" % (fg.rxpath.decim(),)
+ r = gr.enable_realtime_scheduling()
+ if r != gr.RT_OK:
+ print "Warning: Failed to enable realtime scheduling."
- fg.rxpath.set_freq(options.freq)
- fg.rxpath.set_gain(options.gain)
- print "Rx gain_range: ", fg.rxpath.subdev.gain_range(), " using",
fg.rxpath.gain
-
fg.start() # start flow graph
fg.wait() # wait for it to finish
Modified:
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/tx_voice.py
===================================================================
---
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/tx_voice.py
2006-09-27 02:12:20 UTC (rev 3653)
+++
gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2/tx_voice.py
2006-09-27 02:13:01 UTC (rev 3654)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005 Free Software Foundation, Inc.
+# Copyright 2005,2006 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,7 +20,7 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, gru, blks
+from gnuradio import gr, gru, modulation_utils
from gnuradio import usrp
from gnuradio import audio
from gnuradio import eng_notation
@@ -36,6 +36,7 @@
# from current dir
from transmit_path import transmit_path
+import fusb_options
#import os
#print os.getpid()
@@ -44,9 +45,9 @@
class my_graph(gr.flow_graph):
- def __init__(self, tx_subdev_spec, bitrate, interp_rate, spb, bt):
+ def __init__(self, modulator_class, options):
gr.flow_graph.__init__(self)
- self.txpath = transmit_path(self, tx_subdev_spec, bitrate,
interp_rate, spb, bt)
+ self.txpath = transmit_path(self, modulator_class, options)
audio_input = ""
sample_rate = 8000
@@ -72,43 +73,44 @@
def rx_callback(ok, payload):
print "ok = %r, payload = '%s'" % (ok, payload)
- parser = OptionParser (option_class=eng_option)
- parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
- help="select USRP Tx side A or B")
- parser.add_option("-f", "--freq", type="eng_float", default=423.1e6,
- help="set Tx and Rx frequency to FREQ
[default=%default]", metavar="FREQ")
- parser.add_option("-r", "--bitrate", type="eng_float", default=100e3,
- help="specify bitrate. spb and interp will be derived.")
- parser.add_option("-S", "--spb", type="int", default=None, help="set
samples/baud [default=%default]")
- parser.add_option("-i", "--interp", type="intx", default=None,
- help="set fpga interpolation rate to INTERP
[default=%default]")
- parser.add_option("-s", "--size", type="eng_float", default=1500,
- help="set packet size [default=%default]")
- parser.add_option("", "--bt", type="float", default=0.3, help="set
bandwidth-time product [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)")
+ mods = 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='gmsk',
+ help="Select modulation from: %s [default=%%default]"
+ % (', '.join(mods.keys()),))
+
+ parser.add_option("-M", "--megabytes", type="eng_float", default=0,
+ help="set megabytes to transmit [default=inf]")
+
+ transmit_path.add_options(parser, expert_grp)
+
+ for mod in mods.values():
+ mod.add_options(expert_grp)
+
+ fusb_options.add_options(expert_grp)
(options, args) = parser.parse_args ()
if len(args) != 0:
parser.print_help()
sys.exit(1)
- if options.freq < 1e6:
- options.freq *= 1e6
+ if 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)
- pkt_size = int(options.size)
# build the graph
- fg = my_graph(options.tx_subdev_spec, options.bitrate, options.interp,
- options.spb, options.bt)
+ fg = my_graph(mods[options.modulation], options)
- print "bitrate: %sb/sec" % (eng_notation.num_to_str(fg.txpath.bitrate()),)
- print "spb: %3d" % (fg.txpath.spb(),)
- print "interp: %3d" % (fg.txpath.interp(),)
+ r = gr.enable_realtime_scheduling()
+ if r != gr.RT_OK:
+ print "Warning: failed to enable realtime scheduling"
- fg.txpath.set_freq(options.freq)
fg.start() # start flow graph
@@ -117,14 +119,12 @@
n = 0
pktno = 0
- while n < nbytes:
+ while nbytes == 0 or n < nbytes:
packet = fg.packets_from_encoder.delete_head()
s = packet.to_string()
send_pkt(s)
n += len(s)
sys.stderr.write('.')
- if options.discontinuous and pktno % 5 == 4:
- time.sleep(1)
pktno += 1
send_pkt(eof=True)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3654 - gnuradio/branches/developers/eb/digital-wip/gnuradio-examples/python/gmsk2,
eb <=