From version < 33.1 >
edited by Jean-Yves Dupertuis
on 04-04-2018, 15:02
To version < 26.1 >
edited by Jean-Yves Dupertuis
on 27-03-2018, 17:03
< >
Change comment: Ajout du fichier testSDR.grc

Summary

Details

Page properties
Content
... ... @@ -27,436 +27,6 @@
27 27  Le wiki me demande de lancer un script écrit en python qui se trouve :
28 28  https://raw.githubusercontent.com/pothosware/gnuradio-companion-exe/master/GNURadioHelper.py
29 29  
30 -
31 -{{code language="python" title="fichier de test"}}
32 -# Copyright (c) 2015-2016 Josh Blum
33 -# SPDX-License-Identifier: BSL-1.0
34 -
35 -########################################################################
36 -## Do checks and prepare dependencies for GRC
37 -########################################################################
38 -import os
39 -import sys
40 -import inspect
41 -import tempfile
42 -import subprocess
43 -from ctypes.util import find_library
44 -
45 -########################################################################
46 -## Registry/Environment helpers
47 -########################################################################
48 -import ctypes
49 -from ctypes.wintypes import HWND, UINT, WPARAM, LPARAM, LPVOID
50 -LRESULT = LPARAM
51 -import os
52 -import sys
53 -try:
54 - import winreg
55 - unicode = str
56 -except ImportError:
57 - import _winreg as winreg # Python 2.x
58 -
59 -class Environment(object):
60 - #path = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
61 - #hklm = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
62 - path = r'Environment'
63 - hklm = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
64 - key = winreg.OpenKey(hklm, path, 0, winreg.KEY_READ | winreg.KEY_WRITE)
65 - SendMessage = ctypes.windll.user32.SendMessageW
66 - SendMessage.argtypes = HWND, UINT, WPARAM, LPVOID
67 - SendMessage.restype = LRESULT
68 - HWND_BROADCAST = 0xFFFF
69 - WM_SETTINGCHANGE = 0x1A
70 - NO_DEFAULT = type('NO_DEFAULT', (object,), {})()
71 -
72 - def get(self, name, default=NO_DEFAULT):
73 - try:
74 - value = winreg.QueryValueEx(self.key, name)[0]
75 - except WindowsError:
76 - if default is self.NO_DEFAULT:
77 - raise ValueError("No such registry key", name)
78 - value = default
79 - return value
80 -
81 - def set(self, name, value):
82 - if value:
83 - winreg.SetValueEx(self.key, name, 0, winreg.REG_EXPAND_SZ, value)
84 - else:
85 - winreg.DeleteValue(self.key, name)
86 - self.notify()
87 -
88 - def notify(self):
89 - self.SendMessage(
90 - self.HWND_BROADCAST, self.WM_SETTINGCHANGE, 0, u'Environment')
91 -
92 -########################################################################
93 -## determine-if-an-executable-or-library-is-32-or-64-bits-on-windows
94 -## https://stackoverflow.com/questions/1345632
95 -########################################################################
96 -import struct
97 -
98 -IMAGE_FILE_MACHINE_I386=332
99 -IMAGE_FILE_MACHINE_IA64=512
100 -IMAGE_FILE_MACHINE_AMD64=34404
101 -
102 -def getDllMachineType(path):
103 - f=open(path, "rb")
104 - s=f.read(2)
105 - if s!="MZ": raise Exception("%s is not a DLL"%path)
106 - f.seek(60)
107 - s=f.read(4)
108 - header_offset=struct.unpack("<L", s)[0]
109 - f.seek(header_offset+4)
110 - s=f.read(2)
111 - machine=struct.unpack("<H", s)[0]
112 - f.close()
113 - return machine
114 -
115 -########################################################################
116 -## Pip helpers
117 -########################################################################
118 -PIP_EXE = os.path.join(os.path.dirname(sys.executable), 'Scripts', 'pip.exe')
119 -
120 -def pip_install(arg):
121 - ret = subprocess.call([PIP_EXE, 'install', arg], shell=True)
122 - if ret != 0:
123 - print("Error: pip failed to install %s"%arg)
124 - return -1
125 -
126 -########################################################################
127 -## Python checks
128 -########################################################################
129 -def check_python_version():
130 - is_64bits = sys.maxsize > 2**32
131 - if not is_64bits:
132 - raise Exception("requires 64-bit Python")
133 -
134 - if sys.version_info.major != 2 or sys.version_info.minor != 7:
135 - raise Exception("requires Python version 2.7")
136 -
137 - if not os.path.exists(PIP_EXE):
138 - raise Exception("can't find pip executable %s"%PIP_EXE)
139 -
140 - return sys.version
141 -
142 -def handle_python_version():
143 - print("Error: Invoke/Reinstall Python2.7 for amd64")
144 - return -1
145 -
146 -########################################################################
147 -## GTK checks
148 -########################################################################
149 -def check_gtk_runtime():
150 -
151 - gtk_dll_name = "libgtk-win32-2.0-0.dll"
152 -
153 - #first check that the installer default is found
154 - installer_default = os.path.join("C:\\Program Files\\GTK2-Runtime Win64\\bin", gtk_dll_name)
155 - if os.path.exists(installer_default): return installer_default
156 -
157 - #regular dll search within the path
158 - libgtk = find_library(gtk_dll_name)
159 - if libgtk is None:
160 - raise Exception("failed to locate the GTK+ runtime DLL")
161 -
162 - #reject 32-bit versions of this dll
163 - if getDllMachineType(libgtk) != IMAGE_FILE_MACHINE_AMD64:
164 - raise Exception("%s is not AMD64"%libgtk)
165 -
166 - return libgtk
167 -
168 -def handle_gtk_runtime():
169 -
170 - GTK_URL = 'http://downloads.myriadrf.org/binaries/python27_amd64/gtk2-runtime-2.22.1-2014-02-01-ts-win64.exe'
171 - GTK_EXE = os.path.join(tempfile.gettempdir(), 'gtk2-runtime-2.22.1-2014-02-01-ts-win64.exe')
172 -
173 - if not os.path.exists(GTK_EXE):
174 -
175 - #need requests to download the exe
176 - try: import requests
177 - except: pip_install("requests")
178 - import requests
179 -
180 - #download from the url to the destination
181 - r = requests.get(GTK_URL)
182 - with open(GTK_EXE, 'wb') as fd:
183 - for chunk in r.iter_content(1024*1024):
184 - fd.write(chunk)
185 -
186 - if not os.path.exists(GTK_EXE):
187 - print("Cant find installer: %s"%GTK_EXE)
188 - print("Failed to download: %s"%GTK_URL)
189 - return -1
190 -
191 - print("Running installer: %s"%GTK_EXE)
192 - ret = subprocess.call([GTK_EXE, '/S'], shell=True) #silent install
193 - if ret != 0:
194 - print("The GTK installer failed with exit code %d"%ret)
195 - exit(ret)
196 -
197 - print("The GTK installer should have modified the system path")
198 - print("Open a new command window and re-run this script...")
199 -
200 -def check_import_gtk():
201 - import gtk
202 - return inspect.getfile(gtk)
203 -
204 -def handle_import_gtk():
205 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/pygtk-2.22.0-cp27-none-win_amd64.whl')
206 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/pygobject-2.28.6-cp27-none-win_amd64.whl')
207 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/pycairo_gtk-1.10.0-cp27-none-win_amd64.whl')
208 -
209 -########################################################################
210 -## GNU Radio checks
211 -########################################################################
212 -def guess_bin_path():
213 -
214 - #was it run from the proper install directory?
215 - path = os.path.abspath(os.path.dirname(__file__))
216 - if os.path.exists(os.path.join(path, "gnuradio-runtime.dll")): return path
217 -
218 - #otherwise search the path to find the root
219 - gnuradio_runtime = find_library("gnuradio-runtime.dll")
220 - if gnuradio_runtime: return gnuradio_runtime
221 -
222 -def check_gr_runtime():
223 - gnuradio_runtime = find_library("gnuradio-runtime.dll")
224 -
225 - if gnuradio_runtime is None:
226 - raise Exception("failed to locate the GNURadio runtime DLL")
227 -
228 - return gnuradio_runtime
229 -
230 -def handle_gr_runtime():
231 -
232 - path = guess_bin_path()
233 -
234 - #we dont know where the bin path is, this is probably an installer issue
235 - #print this message and return error so other handlers are not invoked
236 - if path is None:
237 - print("Error: PothosSDR DLLs missing from the system path")
238 - print(" See instructions to 'Add PothosSDR to the system PATH'")
239 - print(" https://github.com/pothosware/PothosSDR/wiki/Tutorial")
240 - return -1
241 -
242 - e = Environment()
243 - PATH = e.get('PATH', '')
244 - print("Current PATH: '%s'"%PATH)
245 - if not PATH: PATH = list()
246 - else: PATH = PATH.split(';')
247 -
248 - if path not in PATH:
249 - print("Adding %s to the PATH"%path)
250 - PATH.append(path)
251 - e.set('PATH', ';'.join(PATH))
252 -
253 - print("")
254 - print("The PATH for the current user has been modified")
255 - print("Open a new command window and re-run this script...")
256 -
257 -def check_import_gr():
258 - import gnuradio
259 - from gnuradio import gr
260 - return inspect.getfile(gnuradio)
261 -
262 -def handle_import_gr():
263 - binDir = guess_bin_path()
264 - path = os.path.join(os.path.dirname(binDir), 'lib', 'python2.7', 'site-packages')
265 - if not os.path.exists(path): #or use old-style path without python version
266 - path = os.path.join(os.path.dirname(binDir), 'lib', 'site-packages')
267 - path = os.path.normpath(path)
268 - print("Error: GNURadio modules missing from PYTHONPATH")
269 -
270 - print("")
271 - print("Current search path:")
272 - for searchPath in sys.path: print(" * %s"%searchPath)
273 - print("")
274 -
275 - e = Environment()
276 - PYTHONPATH = e.get('PYTHONPATH', '')
277 - print("Current PYTHONPATH: '%s'"%PYTHONPATH)
278 - if not PYTHONPATH: PYTHONPATH = list()
279 - else: PYTHONPATH = PYTHONPATH.split(';')
280 -
281 - if path not in PYTHONPATH:
282 - print("Adding %s to the PYTHONPATH"%path)
283 - PYTHONPATH.append(path)
284 - e.set('PYTHONPATH', ';'.join(PYTHONPATH))
285 -
286 - print("")
287 - print("The PYTHONPATH for the current user has been modified")
288 - print("Open a new command window and re-run this script...")
289 -
290 -def check_grc_blocks_path():
291 - GRC_BLOCKS_PATH = os.environ.get('GRC_BLOCKS_PATH', '').split(';')[0] #take the first entry
292 - if not GRC_BLOCKS_PATH:
293 - raise Exception("GRC_BLOCKS_PATH is not set")
294 - if not os.path.exists(GRC_BLOCKS_PATH):
295 - raise Exception("GRC_BLOCKS_PATH '%s' does not exist"%GRC_BLOCKS_PATH)
296 - if not os.path.exists(os.path.join(GRC_BLOCKS_PATH, 'options.xml')):
297 - raise Exception("GRC_BLOCKS_PATH '%s' does not contain options.xml"%GRC_BLOCKS_PATH)
298 - return GRC_BLOCKS_PATH
299 -
300 -def handle_grc_blocks_path():
301 - binDir = guess_bin_path()
302 - path = os.path.join(os.path.dirname(binDir), 'share', 'gnuradio', 'grc', 'blocks')
303 - path = os.path.normpath(path)
304 -
305 - print("Setting the GRC_BLOCKS_PATH to %s"%path)
306 - e = Environment()
307 - e.set('GRC_BLOCKS_PATH', path)
308 -
309 - print("")
310 - print("The GRC_BLOCKS_PATH for the current user has been modified")
311 - print("Open a new command window and re-run this script...")
312 -
313 -########################################################################
314 -## Other module checks
315 -########################################################################
316 -def check_import_numpy():
317 - import numpy
318 - return inspect.getfile(numpy)
319 -
320 -def handle_import_numpy():
321 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/numpy-1.12.0+mkl-cp27-cp27m-win_amd64.whl')
322 -
323 -def check_import_lxml():
324 - import lxml
325 - return inspect.getfile(lxml)
326 -
327 -def handle_import_lxml():
328 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/lxml-3.7.2-cp27-cp27m-win_amd64.whl')
329 -
330 -def check_import_cheetah():
331 - import Cheetah
332 - return inspect.getfile(Cheetah)
333 -
334 -def handle_import_cheetah():
335 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/Cheetah-2.4.4-cp27-none-win_amd64.whl')
336 -
337 -def check_import_wxpython():
338 - import wx
339 - import wx.glcanvas
340 - return inspect.getfile(wx)
341 -
342 -def handle_import_wxpython():
343 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/wxPython-3.0.2.0-cp27-none-win_amd64.whl')
344 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/wxPython_common-3.0.2.0-py2-none-any.whl')
345 -
346 -def check_import_pyopengl():
347 - import OpenGL
348 - import OpenGL.GL
349 - return inspect.getfile(OpenGL)
350 -
351 -def handle_import_pyopengl():
352 - print("Installing PyOpenGL with pip:")
353 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/PyOpenGL-3.1.1-cp27-cp27m-win_amd64.whl')
354 - pip_install('http://downloads.myriadrf.org/binaries/python27_amd64/PyOpenGL_accelerate-3.1.1-cp27-cp27m-win_amd64.whl')
355 - print(" Done!")
356 -
357 -CHECKS = [
358 - #first check gr runtime so we can locate the install based on runtime dll in PATH
359 - ("GR_RUNTIME", 'locate GNURadio runtime', check_gr_runtime, handle_gr_runtime),
360 -
361 - #gtk runtime is similar check for dlls in the seatch PATH (no python required)
362 - ("GTK_RUNTIME", 'locate GTK+ runtime', check_gtk_runtime, handle_gtk_runtime),
363 -
364 - #basic python environment and import checks and using pip to install from a URL
365 - ("PYVERSION", 'Python version is 2.7', check_python_version, handle_python_version),
366 - ("IMPORT_GTK", 'import gtk module', check_import_gtk, handle_import_gtk),
367 - ("IMPORT_NUMPY", 'import numpy module', check_import_numpy, handle_import_numpy),
368 - ("IMPORT_LXML", 'import lxml module', check_import_lxml, handle_import_lxml),
369 - ("IMPORT_CHEETAH", 'import Cheetah module', check_import_cheetah, handle_import_cheetah),
370 - ("IMPORT_WX", 'import wx module', check_import_wxpython, handle_import_wxpython),
371 - ("IMPORT_OPENGL", 'import OpenGL module', check_import_pyopengl, handle_import_pyopengl),
372 -
373 - #final checks for GNU Radio and GRC that set local environment variables
374 - ("GRC_BLOCKS", 'GRC blocks path set', check_grc_blocks_path, handle_grc_blocks_path),
375 - ("IMPORT_GR", 'import GNURadio module', check_import_gr, handle_import_gr),
376 -]
377 -
378 -def main():
379 - print("")
380 - print("="*40)
381 - print("== Runtime and import checks")
382 - print("="*40)
383 -
384 - maxLen = max([len(c[1]) for c in CHECKS])
385 - msgs = dict()
386 - statuses = dict()
387 - numFails = 0
388 - numPasses = 0
389 - for key, what, check, handle in CHECKS:
390 - whatStr = "%s...%s"%(what, ' '*(maxLen-len(what)))
391 - try:
392 - msg = check()
393 - statStr = "PASS"
394 - checkPassed = True
395 - numPasses += 1
396 - except Exception as ex:
397 - statStr = "FAIL"
398 - checkPassed = False
399 - msg = str(ex)
400 - numFails += 1
401 -
402 - print(" * Check %s %s"%(whatStr, statStr))
403 - msgs[key] = msg
404 - statuses[key] = checkPassed
405 -
406 - if numPasses:
407 - print("")
408 - print("="*40)
409 - print("== Checks passed summary")
410 - print("="*40)
411 - for key, what, check, handle in CHECKS:
412 - if statuses[key]: print("%s:\t%s"%(key, msgs[key]))
413 -
414 - if numFails == 0:
415 - print("")
416 - print("All checked passed! gnuradio-companion is ready to use.")
417 - return 0
418 -
419 - if numFails:
420 - print("")
421 - print("="*40)
422 - print("== Checks failed summary")
423 - print("="*40)
424 - for key, what, check, handle in CHECKS:
425 - if not statuses[key]: print("%s:\t%s"%(key, msgs[key]))
426 -
427 - if numFails:
428 - print("")
429 - print("="*40)
430 - print("== Fixing problems")
431 - print("="*40)
432 - for key, what, check, handle in CHECKS:
433 - if not statuses[key]:
434 - print("Handling issues for %s..."%key)
435 - ret = handle()
436 - #exit asap when return code provided
437 - if ret is not None: return ret
438 -
439 - print("")
440 - print("Changes made! Please re-run this script in a new terminal.")
441 -
442 -if __name__ == '__main__':
443 -
444 - #run main with exception handling
445 - ret = None
446 - try: ret = main()
447 - except Exception as ex:
448 - print("Error: %s"%str(ex))
449 -
450 - #give time to read message if opened from explorer
451 - #wait for user to press a key
452 - print("")
453 - os.system('pause')
454 -
455 - #return the error code from main
456 - if ret is None: ret = 0
457 - exit(ret)
458 -{{/code}}
459 -
460 460  Avec copier - coller, je l'ai sauvé sur mon PC.
461 461  
462 462  J'ouvre le fichier avec "Edit with IDLE", ensuite via "run modul F5" , après avoir installé GTK+ runtime, il m'annonce que je dois réinstallé python 2.7, car j'avais chargé un autre 2.7.14 !
... ... @@ -593,7 +593,7 @@
593 593  
594 594  Je profite pour installer directement GQRX :
595 595  
596 -~~$//sudo apt install gqrx-sdr//
166 +~~$//sudo apt install gqrx//
597 597  
598 598  Ensuite je branche ma clef DVB-t, et je regarde si le programme GQRX la trouve.
599 599  
... ... @@ -608,38 +608,4 @@
608 608  Après scan, je trouve une radio sur 98,2 MHz
609 609  
610 610  
611 -== GNURadio ==
612 -
613 -{{error}}
614 -Attention AVANT DE LANCER GNU COMPAGNON VOUS DEVEZ INSTALLER GQRX-SDR, SINON il vous manquera des bibliothèques !!!
615 -{{/error}}
616 -
617 -
618 -En suivant l'excellent document qui se trouve :
619 -http://f0fyf.blogspot.ch/2014/08/recepteur-fm-avec-gnuradio.html
620 -je réalise mon premier programme SDR avec ma clef RTL-SDR.
621 -
622 -[[testSDR.grc>>attach:testSDR.grc]]
623 -
624 -{{error}}
625 -Sur une version linux , mon module "Options" n'avait pas la dimension de la page !?
626 -ecrivez : 1280, 1024
627 -{{/error}}
628 -
629 -
630 -[[image:DJtestDaarioSDR.png||height="545" width="562"]]
631 -
632 -
633 -Normalement on doit pouvoir lancer directement avec le fichier python :
634 -
635 -[[DJTestRadioSDR.py>>attach:DJTestRadioSDR.py||title="fonctionne avec python 2.7"]]
636 -
637 -
638 -[[image:testRadioSDR.png||height="358" width="599"]]
639 -
640 -
641 -C'est confirmé ! depuis un terminal :
642 -
643 -~~$//python DJTestRadioSDR.py//
644 -
645 -[[image:terminalDirectPython.png||height="196" width="610"]]
181 +== GNURadio ==
DJTestRadioSDR.py
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Dupertuis
Size
... ... @@ -1,1 +1,0 @@
1 -7.3 KB
Content
... ... @@ -1,220 +1,0 @@
1 -#!/usr/bin/env python2
2 -# -*- coding: utf-8 -*-
3 -##################################################
4 -# GNU Radio Python Flow Graph
5 -# Title: Test Radion SDR
6 -# Author: Jean-Yves HB9FOU
7 -# Generated: Tue Mar 27 17:01:00 2018
8 -##################################################
9 -
10 -if __name__ == '__main__':
11 - import ctypes
12 - import sys
13 - if sys.platform.startswith('linux'):
14 - try:
15 - x11 = ctypes.cdll.LoadLibrary('libX11.so')
16 - x11.XInitThreads()
17 - except:
18 - print "Warning: failed to XInitThreads()"
19 -
20 -from gnuradio import analog
21 -from gnuradio import audio
22 -from gnuradio import blocks
23 -from gnuradio import eng_notation
24 -from gnuradio import filter
25 -from gnuradio import gr
26 -from gnuradio import wxgui
27 -from gnuradio.eng_option import eng_option
28 -from gnuradio.fft import window
29 -from gnuradio.filter import firdes
30 -from gnuradio.wxgui import forms
31 -from gnuradio.wxgui import waterfallsink2
32 -from grc_gnuradio import wxgui as grc_wxgui
33 -from optparse import OptionParser
34 -import osmosdr
35 -import time
36 -import wx
37 -
38 -
39 -class DJTestRadioSDR(grc_wxgui.top_block_gui):
40 -
41 - def __init__(self):
42 - grc_wxgui.top_block_gui.__init__(self, title="Test Radion SDR")
43 - _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
44 - self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
45 -
46 - ##################################################
47 - # Variables
48 - ##################################################
49 - self.samp_rate = samp_rate = 2e6
50 - self.quadrature = quadrature = 500e3
51 - self.freq = freq = 98.2
52 - self.cutoff = cutoff = 100e3
53 - self.audio_dec = audio_dec = 10
54 - self.Volume = Volume = 8
55 -
56 - ##################################################
57 - # Blocks
58 - ##################################################
59 - _freq_sizer = wx.BoxSizer(wx.VERTICAL)
60 - self._freq_text_box = forms.text_box(
61 - parent=self.GetWin(),
62 - sizer=_freq_sizer,
63 - value=self.freq,
64 - callback=self.set_freq,
65 - label="Frequence",
66 - converter=forms.float_converter(),
67 - proportion=0,
68 - )
69 - self._freq_slider = forms.slider(
70 - parent=self.GetWin(),
71 - sizer=_freq_sizer,
72 - value=self.freq,
73 - callback=self.set_freq,
74 - minimum=88,
75 - maximum=108,
76 - num_steps=100,
77 - style=wx.SL_HORIZONTAL,
78 - cast=float,
79 - proportion=1,
80 - )
81 - self.Add(_freq_sizer)
82 - _Volume_sizer = wx.BoxSizer(wx.VERTICAL)
83 - self._Volume_text_box = forms.text_box(
84 - parent=self.GetWin(),
85 - sizer=_Volume_sizer,
86 - value=self.Volume,
87 - callback=self.set_Volume,
88 - label="volume",
89 - converter=forms.float_converter(),
90 - proportion=0,
91 - )
92 - self._Volume_slider = forms.slider(
93 - parent=self.GetWin(),
94 - sizer=_Volume_sizer,
95 - value=self.Volume,
96 - callback=self.set_Volume,
97 - minimum=0,
98 - maximum=100,
99 - num_steps=100,
100 - style=wx.SL_HORIZONTAL,
101 - cast=float,
102 - proportion=1,
103 - )
104 - self.Add(_Volume_sizer)
105 - self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
106 - self.GetWin(),
107 - baseband_freq=0,
108 - dynamic_range=100,
109 - ref_level=0,
110 - ref_scale=2.0,
111 - sample_rate=samp_rate,
112 - fft_size=512,
113 - fft_rate=15,
114 - average=False,
115 - avg_alpha=None,
116 - title="Waterfall ",
117 - )
118 - self.Add(self.wxgui_waterfallsink2_0.win)
119 - self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
120 - self.rtlsdr_source_0.set_sample_rate(samp_rate)
121 - self.rtlsdr_source_0.set_center_freq(freq*1e6, 0)
122 - self.rtlsdr_source_0.set_freq_corr(-30, 0)
123 - self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
124 - self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
125 - self.rtlsdr_source_0.set_gain_mode(True, 0)
126 - self.rtlsdr_source_0.set_gain(50, 0)
127 - self.rtlsdr_source_0.set_if_gain(30, 0)
128 - self.rtlsdr_source_0.set_bb_gain(20, 0)
129 - self.rtlsdr_source_0.set_antenna("1", 0)
130 - self.rtlsdr_source_0.set_bandwidth(0, 0)
131 -
132 - self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
133 - interpolation=48,
134 - decimation=int(quadrature/1e3/audio_dec),
135 - taps=None,
136 - fractional_bw=None,
137 - )
138 - self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
139 - interpolation=1,
140 - decimation=int(samp_rate/quadrature),
141 - taps=None,
142 - fractional_bw=None,
143 - )
144 - self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
145 - 1, samp_rate, cutoff, 1e6, firdes.WIN_HAMMING, 6.76))
146 - self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((Volume, ))
147 - self.audio_sink_0 = audio.sink(48000, "", True)
148 - self.analog_wfm_rcv_0 = analog.wfm_rcv(
149 - quad_rate=quadrature,
150 - audio_decimation=audio_dec,
151 - )
152 -
153 - ##################################################
154 - # Connections
155 - ##################################################
156 - self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_1, 0))
157 - self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))
158 - self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
159 - self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
160 - self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0))
161 - self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
162 - self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
163 -
164 - def get_samp_rate(self):
165 - return self.samp_rate
166 -
167 - def set_samp_rate(self, samp_rate):
168 - self.samp_rate = samp_rate
169 - self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, self.cutoff, 1e6, firdes.WIN_HAMMING, 6.76))
170 - self.rtlsdr_source_0.set_sample_rate(self.samp_rate)
171 - self.wxgui_waterfallsink2_0.set_sample_rate(self.samp_rate)
172 -
173 - def get_quadrature(self):
174 - return self.quadrature
175 -
176 - def set_quadrature(self, quadrature):
177 - self.quadrature = quadrature
178 -
179 - def get_freq(self):
180 - return self.freq
181 -
182 - def set_freq(self, freq):
183 - self.freq = freq
184 - self._freq_slider.set_value(self.freq)
185 - self._freq_text_box.set_value(self.freq)
186 - self.rtlsdr_source_0.set_center_freq(self.freq*1e6, 0)
187 -
188 - def get_cutoff(self):
189 - return self.cutoff
190 -
191 - def set_cutoff(self, cutoff):
192 - self.cutoff = cutoff
193 - self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, self.cutoff, 1e6, firdes.WIN_HAMMING, 6.76))
194 -
195 - def get_audio_dec(self):
196 - return self.audio_dec
197 -
198 - def set_audio_dec(self, audio_dec):
199 - self.audio_dec = audio_dec
200 -
201 - def get_Volume(self):
202 - return self.Volume
203 -
204 - def set_Volume(self, Volume):
205 - self.Volume = Volume
206 - self._Volume_slider.set_value(self.Volume)
207 - self._Volume_text_box.set_value(self.Volume)
208 - self.blocks_multiply_const_vxx_0.set_k((self.Volume, ))
209 -
210 -
211 -def main(top_block_cls=DJTestRadioSDR, options=None):
212 -
213 - tb = top_block_cls()
214 - tb.Start(True)
215 - tb.Wait()
216 -
217 -
218 -if __name__ == '__main__':
219 - main()
220 -
DJtestDaarioSDR.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Dupertuis
Size
... ... @@ -1,1 +1,0 @@
1 -107.0 KB
Content
terminalDirectPython.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Dupertuis
Size
... ... @@ -1,1 +1,0 @@
1 -46.8 KB
Content
testRadioSDR.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.Dupertuis
Size
... ... @@ -1,1 +1,0 @@
1 -279.5 KB
Content