aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDimitri Stolnikov <horiz0n@gmx.net>2013-06-05 19:38:57 +0200
committerDimitri Stolnikov <horiz0n@gmx.net>2013-06-05 19:52:41 +0200
commit86b906a0190f25412f66530a7afa325971f2dfe4 (patch)
treef2de2687f04aeb8131a6273e9def944d2870c5d8 /apps
parent7a129238b71771ff0b1f0b24d5de37df7aeccfdd (diff)
apps: check for sample rate availability
Diffstat (limited to 'apps')
-rwxr-xr-xapps/osmocom_fft6
-rw-r--r--apps/osmocom_siggen_base.py6
-rwxr-xr-xapps/osmocom_spectrum_sense35
3 files changed, 34 insertions, 13 deletions
diff --git a/apps/osmocom_fft b/apps/osmocom_fft
index a346b2a..c087f6e 100755
--- a/apps/osmocom_fft
+++ b/apps/osmocom_fft
@@ -97,6 +97,12 @@ class app_top_block(stdgui2.std_top_block, pubsub):
self.src = osmosdr.source(options.args)
+ try:
+ self.src.get_sample_rates().start()
+ except RuntimeError:
+ print "Source has no sample rates (wrong device arguments?)."
+ sys.exit(1)
+
# Set the antenna
if(options.antenna):
self.src.set_antenna(options.antenna)
diff --git a/apps/osmocom_siggen_base.py b/apps/osmocom_siggen_base.py
index c32388c..50d6d66 100644
--- a/apps/osmocom_siggen_base.py
+++ b/apps/osmocom_siggen_base.py
@@ -160,6 +160,12 @@ class top_block(gr.top_block, pubsub):
def _setup_osmosdr(self, options):
self._sink = osmosdr.sink(options.args)
+ try:
+ self._sink.get_sample_rates().start()
+ except RuntimeError:
+ print "Sink has no sample rates (wrong device arguments?)."
+ sys.exit(1)
+
if options.samp_rate is None:
options.samp_rate = self._sink.get_sample_rates().start()
diff --git a/apps/osmocom_spectrum_sense b/apps/osmocom_spectrum_sense
index 71e14aa..ea365bb 100755
--- a/apps/osmocom_spectrum_sense
+++ b/apps/osmocom_spectrum_sense
@@ -21,8 +21,11 @@
#
import osmosdr
-from gnuradio import gr, eng_notation, window
+from gnuradio import gr, eng_notation
+from gnuradio import blocks
from gnuradio import audio
+from gnuradio import filter
+from gnuradio import fft
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import sys
@@ -47,7 +50,7 @@ class tune(gr.feval_dd):
def eval(self, ignore):
"""
- This method is called from gr.bin_statistics_f when it wants
+ This method is called from blocks.bin_statistics_f when it wants
to change the center frequency. This method tunes the front
end to the new center frequency, and returns the new frequency
as its result.
@@ -149,6 +152,12 @@ class my_top_block(gr.top_block):
# build graph
self.u = osmosdr.source(options.args)
+ try:
+ self.u.get_sample_rates().start()
+ except RuntimeError:
+ print "Source has no sample rates (wrong device arguments?)."
+ sys.exit(1)
+
# Set the antenna
if(options.antenna):
self.u.set_antenna(options.antenna, 0)
@@ -166,19 +175,19 @@ class my_top_block(gr.top_block):
self.squelch_threshold = options.squelch_threshold
- s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
+ s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
- mywindow = window.blackmanharris(self.fft_size)
- fft = gr.fft_vcc(self.fft_size, True, mywindow, True)
+ mywindow = filter.window.blackmanharris(self.fft_size)
+ ffter = fft.fft_vcc(self.fft_size, True, mywindow, True)
power = 0
for tap in mywindow:
power += tap*tap
- c2mag = gr.complex_to_mag_squared(self.fft_size)
+ c2mag = blocks.complex_to_mag_squared(self.fft_size)
# FIXME the log10 primitive is dog slow
- #log = gr.nlog10_ff(10, self.fft_size,
- # -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
+ #log = blocks.nlog10_ff(10, self.fft_size,
+ # -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
# Set the freq_step to 75% of the actual data throughput.
# This allows us to discard the bins on both ends of the spectrum.
@@ -195,13 +204,13 @@ class my_top_block(gr.top_block):
self.msgq = gr.msg_queue(1)
self._tune_callback = tune(self) # hang on to this to keep it from being GC'd
- stats = gr.bin_statistics_f(self.fft_size, self.msgq,
- self._tune_callback, tune_delay,
- dwell_delay)
+ stats = blocks.bin_statistics_f(self.fft_size, self.msgq,
+ self._tune_callback, tune_delay,
+ dwell_delay)
# FIXME leave out the log10 until we speed it up
- #self.connect(self.u, s2v, fft, c2mag, log, stats)
- self.connect(self.u, s2v, fft, c2mag, stats)
+ #self.connect(self.u, s2v, ffter, c2mag, log, stats)
+ self.connect(self.u, s2v, ffter, c2mag, stats)
if options.gain is None:
# if no gain was specified, use the mid-point in dB