From 5061ac56192707eda716fdd45b4e4060a8405389 Mon Sep 17 00:00:00 2001 From: blackflag Date: Wed, 9 Nov 2016 19:25:27 +0100 Subject: [PATCH] first commit --- README.md | 0 scanna.grc | 1080 ++++++++++++++++++++++++++++++++++++++++++++++++++++ scanna.py | 209 ++++++++++ 3 files changed, 1289 insertions(+) create mode 100644 README.md create mode 100644 scanna.grc create mode 100755 scanna.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/scanna.grc b/scanna.grc new file mode 100644 index 0000000..1e14d8f --- /dev/null +++ b/scanna.grc @@ -0,0 +1,1080 @@ + + + + Tue Nov 8 14:43:44 2016 + + options + + id + scanna + + + _enabled + True + + + title + Scanna + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + max_nouts + 0 + + + realtime_scheduling + + + + alias + + + + _coordinate + (48, 21) + + + _rotation + 0 + + + + variable + + id + transition + + + _enabled + True + + + value + 8000 + + + alias + + + + _coordinate + (336, 21) + + + _rotation + 0 + + + + variable + + id + variable_0 + + + _enabled + True + + + value + 0 + + + alias + + + + _coordinate + (560, 21) + + + _rotation + 0 + + + + variable + + id + volume + + + _enabled + True + + + value + 1 + + + alias + + + + _coordinate + (688, 21) + + + _rotation + 0 + + + + variable + + id + cutoff + + + _enabled + True + + + value + 100e3 + + + alias + + + + _coordinate + (448, 21) + + + _rotation + 0 + + + + variable + + id + samp_rate + + + _enabled + True + + + value + 2000000 + + + alias + + + + _coordinate + (232, 21) + + + _rotation + 0 + + + + rational_resampler_xxx + + id + rational_resampler_xxx_0 + + + _enabled + True + + + type + ccc + + + interp + 500000 + + + decim + 2000000 + + + taps + + + + fbw + 0 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (296, 191) + + + _rotation + 0 + + + + audio_sink + + id + audio_sink_0 + + + _enabled + True + + + samp_rate + 24000 + + + device_name + + + + ok_to_block + True + + + num_inputs + 1 + + + alias + + + + affinity + + + + _coordinate + (1088, 348) + + + _rotation + 0 + + + + analog_pwr_squelch_xx + + id + analog_pwr_squelch_xx_0 + + + _enabled + True + + + type + float + + + threshold + squelch_0 + + + alpha + 1 + + + ramp + 1 + + + gate + True + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (904, 327) + + + _rotation + 0 + + + + blocks_wavfile_sink + + id + blocks_wavfile_sink_0 + + + _enabled + True + + + file + ./output.wav + + + nchan + 1 + + + samp_rate + 24000 + + + bits_per_sample + 8 + + + alias + + + + affinity + + + + _coordinate + (1096, 446) + + + _rotation + 0 + + + + variable_text_box + + id + squelch_0 + + + _enabled + True + + + label + Squelch (db) + + + value + 0 + + + converver + int_converter + + + formatter + None + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (840, 23) + + + _rotation + 0 + + + + variable_slider + + id + freq_1 + + + _enabled + True + + + label + Frequency + + + value + 446000000 + + + min + 445800000 + + + max + 446100000 + + + num_steps + 200 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + + + + notebook + + + + alias + + + + _coordinate + (976, 25) + + + _rotation + 0 + + + + analog_nbfm_rx + + id + analog_nbfm_rx_0 + + + _enabled + True + + + audio_rate + 25000 + + + quad_rate + 500000 + + + tau + 75e-6 + + + max_dev + 5e3 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (664, 191) + + + _rotation + 0 + + + + rational_resampler_xxx + + id + rational_resampler_xxx_1 + + + _enabled + True + + + type + fff + + + interp + 24 + + + decim + 25 + + + taps + + + + fbw + 0 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (888, 191) + + + _rotation + 0 + + + + low_pass_filter + + id + low_pass_filter_0 + + + _enabled + True + + + type + fir_filter_ccf + + + decim + 1 + + + interp + 1 + + + gain + 1 + + + samp_rate + 500000 + + + cutoff_freq + 100000 + + + width + transition + + + win + firdes.WIN_HAMMING + + + beta + 6.76 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (480, 170) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + wxgui_fftsink2_0 + + + _enabled + True + + + type + complex + + + title + FFT Plot + + + samp_rate + samp_rate + + + baseband_freq + freq_1 + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 0 + + + ref_scale + 2 + + + fft_size + 1024 + + + fft_rate + 15 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + win + None + + + win_size + + + + grid_pos + + + + notebook + + + + freqvar + None + + + alias + + + + affinity + + + + _coordinate + (320, 469) + + + _rotation + 0 + + + + rtlsdr_source + + id + rtlsdr_source_0 + + + _enabled + True + + + type + fc32 + + + args + + + + nchan + 1 + + + sample_rate + samp_rate + + + freq0 + freq_1 + + + corr0 + 0 + + + dc_offset_mode0 + 0 + + + iq_balance_mode0 + 0 + + + gain_mode0 + True + + + gain0 + 10 + + + if_gain0 + 20 + + + bb_gain0 + 20 + + + ant0 + + + + bw0 + 0 + + + freq1 + 100e6 + + + corr1 + 0 + + + dc_offset_mode1 + 0 + + + iq_balance_mode1 + 0 + + + gain_mode1 + False + + + gain1 + 10 + + + if_gain1 + 20 + + + bb_gain1 + 20 + + + ant1 + + + + bw1 + 0 + + + freq2 + 100e6 + + + corr2 + 0 + + + dc_offset_mode2 + 0 + + + iq_balance_mode2 + 0 + + + gain_mode2 + False + + + gain2 + 10 + + + if_gain2 + 20 + + + bb_gain2 + 20 + + + ant2 + + + + bw2 + 0 + + + freq3 + 100e6 + + + corr3 + 0 + + + dc_offset_mode3 + 0 + + + iq_balance_mode3 + 0 + + + gain_mode3 + False + + + gain3 + 10 + + + if_gain3 + 20 + + + bb_gain3 + 20 + + + ant3 + + + + bw3 + 0 + + + freq4 + 100e6 + + + corr4 + 0 + + + dc_offset_mode4 + 0 + + + iq_balance_mode4 + 0 + + + gain_mode4 + False + + + gain4 + 10 + + + if_gain4 + 20 + + + bb_gain4 + 20 + + + ant4 + + + + bw4 + 0 + + + alias + + + + affinity + + + + minoutbuf + 0 + + + maxoutbuf + 0 + + + _coordinate + (56, 268) + + + _rotation + 0 + + + + analog_pwr_squelch_xx_0 + blocks_wavfile_sink_0 + 0 + 0 + + + rational_resampler_xxx_1 + analog_pwr_squelch_xx_0 + 0 + 0 + + + analog_nbfm_rx_0 + rational_resampler_xxx_1 + 0 + 0 + + + low_pass_filter_0 + analog_nbfm_rx_0 + 0 + 0 + + + rational_resampler_xxx_0 + low_pass_filter_0 + 0 + 0 + + + analog_pwr_squelch_xx_0 + audio_sink_0 + 0 + 0 + + + rtlsdr_source_0 + wxgui_fftsink2_0 + 0 + 0 + + + rtlsdr_source_0 + rational_resampler_xxx_0 + 0 + 0 + + diff --git a/scanna.py b/scanna.py new file mode 100755 index 0000000..8a4d5c2 --- /dev/null +++ b/scanna.py @@ -0,0 +1,209 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Scanna +# Generated: Sat Nov 5 18:04:51 2016 +################################################## + +from gnuradio import analog +from gnuradio import audio +from gnuradio import blocks +from gnuradio import eng_notation +from gnuradio import filter +from gnuradio import gr +from gnuradio import wxgui +from gnuradio.eng_option import eng_option +from gnuradio.fft import window +from gnuradio.filter import firdes +from gnuradio.wxgui import fftsink2 +from gnuradio.wxgui import forms +from grc_gnuradio import wxgui as grc_wxgui +from optparse import OptionParser +import osmosdr +import wx + +class scanna(grc_wxgui.top_block_gui): + + def __init__(self): + grc_wxgui.top_block_gui.__init__(self, title="Scanna") + _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" + self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) + + ################################################## + # Variables + ################################################## + self.volume = volume = 1 + self.variable_0 = variable_0 = 0 + self.transition = transition = 8000 + self.squelch_0 = squelch_0 = 0 + self.samp_rate = samp_rate = 2000000 + self.freq_1 = freq_1 = 446000000 + self.cutoff = cutoff = 100e3 + + ################################################## + # Blocks + ################################################## + self._squelch_0_text_box = forms.text_box( + parent=self.GetWin(), + value=self.squelch_0, + callback=self.set_squelch_0, + label="Squelch (db)", + converter=forms.int_converter(), + ) + self.Add(self._squelch_0_text_box) + _freq_1_sizer = wx.BoxSizer(wx.VERTICAL) + self._freq_1_text_box = forms.text_box( + parent=self.GetWin(), + sizer=_freq_1_sizer, + value=self.freq_1, + callback=self.set_freq_1, + label="Frequency", + converter=forms.float_converter(), + proportion=0, + ) + self._freq_1_slider = forms.slider( + parent=self.GetWin(), + sizer=_freq_1_sizer, + value=self.freq_1, + callback=self.set_freq_1, + minimum=445800000, + maximum=446100000, + num_steps=200, + style=wx.SL_HORIZONTAL, + cast=float, + proportion=1, + ) + self.Add(_freq_1_sizer) + self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( + self.GetWin(), + baseband_freq=freq_1, + y_per_div=10, + y_divs=10, + ref_level=0, + ref_scale=2, + sample_rate=samp_rate, + fft_size=1024, + fft_rate=15, + average=False, + avg_alpha=None, + title="FFT Plot", + peak_hold=False, + ) + self.Add(self.wxgui_fftsink2_0.win) + self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) + self.rtlsdr_source_0.set_sample_rate(samp_rate) + self.rtlsdr_source_0.set_center_freq(freq_1, 0) + self.rtlsdr_source_0.set_freq_corr(0, 0) + self.rtlsdr_source_0.set_dc_offset_mode(0, 0) + self.rtlsdr_source_0.set_iq_balance_mode(0, 0) + self.rtlsdr_source_0.set_gain_mode(True, 0) + self.rtlsdr_source_0.set_gain(10, 0) + self.rtlsdr_source_0.set_if_gain(20, 0) + self.rtlsdr_source_0.set_bb_gain(20, 0) + self.rtlsdr_source_0.set_antenna("", 0) + self.rtlsdr_source_0.set_bandwidth(0, 0) + + self.rational_resampler_xxx_1 = filter.rational_resampler_fff( + interpolation=24, + decimation=25, + taps=None, + fractional_bw=None, + ) + self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( + interpolation=500000, + decimation=2000000, + taps=None, + fractional_bw=None, + ) + self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( + 1, 500000, freq_1, transition, firdes.WIN_HAMMING, 6.76)) + self.blocks_wavfile_sink_0 = blocks.wavfile_sink("./output.wav", 1, 24000, 8) + self.audio_sink_0 = audio.sink(24000, "", True) + self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(squelch_0, 1, 1, True) + self.analog_nbfm_rx_0 = analog.nbfm_rx( + audio_rate=25000, + quad_rate=500000, + tau=75e-6, + max_dev=5e3, + ) + + ################################################## + # Connections + ################################################## + self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_wavfile_sink_0, 0)) + self.connect((self.rational_resampler_xxx_1, 0), (self.analog_pwr_squelch_xx_0, 0)) + self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_1, 0)) + self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0)) + self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) + self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) + self.connect((self.analog_pwr_squelch_xx_0, 0), (self.audio_sink_0, 0)) + self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0)) + + + + def get_volume(self): + return self.volume + + def set_volume(self, volume): + self.volume = volume + + def get_variable_0(self): + return self.variable_0 + + def set_variable_0(self, variable_0): + self.variable_0 = variable_0 + + def get_transition(self): + return self.transition + + def set_transition(self, transition): + self.transition = transition + self.low_pass_filter_0.set_taps(firdes.low_pass(1, 500000, self.freq_1, self.transition, firdes.WIN_HAMMING, 6.76)) + + def get_squelch_0(self): + return self.squelch_0 + + def set_squelch_0(self, squelch_0): + self.squelch_0 = squelch_0 + self.analog_pwr_squelch_xx_0.set_threshold(self.squelch_0) + self._squelch_0_text_box.set_value(self.squelch_0) + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.rtlsdr_source_0.set_sample_rate(self.samp_rate) + self.wxgui_fftsink2_0.set_sample_rate(self.samp_rate) + + def get_freq_1(self): + return self.freq_1 + + def set_freq_1(self, freq_1): + self.freq_1 = freq_1 + self.rtlsdr_source_0.set_center_freq(self.freq_1, 0) + self._freq_1_slider.set_value(self.freq_1) + self._freq_1_text_box.set_value(self.freq_1) + self.wxgui_fftsink2_0.set_baseband_freq(self.freq_1) + self.low_pass_filter_0.set_taps(firdes.low_pass(1, 500000, self.freq_1, self.transition, firdes.WIN_HAMMING, 6.76)) + + def get_cutoff(self): + return self.cutoff + + def set_cutoff(self, cutoff): + self.cutoff = cutoff + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + tb = scanna() + tb.Start(True) + tb.Wait()