Wiki source code of SDR
Last modified by Administrator on 10-03-2021, 11:01
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{box cssClass="floatinginfobox" title="**Contenu**"}} | ||
| 2 | {{toc depth="2"/}} | ||
| 3 | {{/box}} | ||
| 4 | |||
| 5 | = Introduction = | ||
| 6 | |||
| 7 | Je vais décrire les différentes étapes que je réalise pour tenter de faire fonctionner un système SDR. En effet, même si certain dise que c'est simple, je trouve des plus compliqué ! Suite à de plus amples renseignements arrachés lors des journées du libre à St-Cergue et à l'achat de mon matériel "Pluto" à Vich; je me lance ! | ||
| 8 | |||
| 9 | == PIPO 12 == | ||
| 10 | |||
| 11 | Avec Michel ( HB9DUG ) nous avons installé le logiciel Pothos & Python. Bien que nous ayons réussi à faire fonctionner ma clef USB vis SDR# on est pas arrivé à recevoir le straeming TV de son système. Eh oui !! Facile !! | ||
| 12 | |||
| 13 | == Mon PC == | ||
| 14 | |||
| 15 | Suite à ce fiasco, je vais utiliser mon notebook pour tenter l'aventure. Type de mon matériel : Aspire E15 "E5-575G-79G5", Intel Core i7-6500U 2.5GHz, NVIDIA GeForce 940MX. OS window 10. | ||
| 16 | |||
| 17 | === Installation === | ||
| 18 | |||
| 19 | J'ai commencé par installé //python-2.7.14.amd64//. En effet, on m'a dit qu'il valait mieux commencé par le logiciel Python. Ensuite j'ai recherché le logiciel "Pothos" ( pas simple !, c'est en recherchant : **pothosware** que je l'ai trouvé ! ). J'ai téléchargé //PothosSDR-2018.03.12-vc14-x64// et l'ai installé sur ma machine. **Atttention lors de l'installation il demande le lien avec Python (bien cocher python 2 !)** | ||
| 20 | |||
| 21 | === Test === | ||
| 22 | |||
| 23 | Selon information du wiki GNURadio, il nous informe que très certainement des liens n'ont pas été mis à jour et pour le savoir il suffit de lancer le programme GNURadio. Comme prévu j'ai reçu ce message : | ||
| 24 | |||
| 25 | [[image:PythonError.PNG]] | ||
| 26 | |||
| 27 | Le wiki me demande de lancer un script écrit en python qui se trouve : | ||
| 28 | https://raw.githubusercontent.com/pothosware/gnuradio-companion-exe/master/GNURadioHelper.py | ||
| 29 | |||
| 30 | {{code language="python" title=" | ||
| 31 | 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 | Avec copier - coller, je l'ai sauvé sur mon PC. | ||
| 461 | |||
| 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 ! | ||
| 463 | |||
| 464 | [[image:Pyversion.PNG]] | ||
| 465 | |||
| 466 | J'ai déinstallé python 2.7 , chargé celui marqué avec **amd64** et relancé l'installation ! | ||
| 467 | Ensuite j'ai lancé le script GNURadionHelper.py avec le nouvel IDLE | ||
| 468 | |||
| 469 | |||
| 470 | [[image:GNURadioHelper-re-run.PNG||height="480" width="725"]] | ||
| 471 | |||
| 472 | Comme il me le demande , je relance le script ! | ||
| 473 | |||
| 474 | Il n'arrive pas a charger GTK et WX ! | ||
| 475 | |||
| 476 | |||
| 477 | [[image:Gtk-wx-error.PNG]] | ||
| 478 | |||
| 479 | **Je l'ai relancé plus de 5 fois et rien a faire, faut trouver une autre solution !** | ||
| 480 | |||
| 481 | {{warning}} | ||
| 482 | Le script n'était pas placé au bon endroit ! Il doit se trouver dans Pyton27 ! | ||
| 483 | {{/warning}} | ||
| 484 | |||
| 485 | |||
| 486 | [[image:GNURadioHelper2.PNG]] | ||
| 487 | |||
| 488 | {{info}} | ||
| 489 | Enfin, une chose en place ! | ||
| 490 | {{/info}} | ||
| 491 | |||
| 492 | Je vais tester si je peux importé toutes ces bibliothèques : | ||
| 493 | |||
| 494 | [[image:TestImportation.PNG]] | ||
| 495 | |||
| 496 | {{info}} | ||
| 497 | Pas besoinn de faire la même erreur de syntaxe que moi ;-) | ||
| 498 | {{/info}} | ||
| 499 | |||
| 500 | |||
| 501 | Selon le wiki GNURadion il demande d'utiliser "portaudio" dans le fichier config.conf. Je l'ai trouvé en utilisant PowerShell : | ||
| 502 | |||
| 503 | [[image:GNUAudio_2.PNG]] | ||
| 504 | |||
| 505 | comme on le voit le fichier n'existe pas. Donc il faut le créer : | ||
| 506 | |||
| 507 | [[image:GNUAudio_3.PNG]] | ||
| 508 | |||
| 509 | Voilà mon fichier ! Ensuite je l'ai ouvert avec un éditeur (notepad pour moi) et inscrit ce qu'il veulent : | ||
| 510 | |||
| 511 | |||
| 512 | [[image:GNUAudio_4.PNG]] | ||
| 513 | |||
| 514 | Je test si le prefix //PothosSDR// existe via PowwerShell : | ||
| 515 | |||
| 516 | |||
| 517 | [[image:GNUAudio_5.PNG]] | ||
| 518 | |||
| 519 | Je contrôle si elle est chargée : pour ce faire je vais ou se trouve le programme python : | ||
| 520 | |||
| 521 | |||
| 522 | [[image:GNUAudio_6.PNG]] | ||
| 523 | |||
| 524 | à ce moment audio est en auto et non en portaudio ! | ||
| 525 | |||
| 526 | |||
| 527 | === Liens === | ||
| 528 | |||
| 529 | python 2.7 : https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi | ||
| 530 | pothos : https://github.com/pothosware/PothosCore/wiki/Downloads | ||
| 531 | pothos wiki : https://github.com/pothosware/PothosCore/wiki | ||
| 532 | pothos tutorial : https://github.com/pothosware/PothosFlow/wiki/Tutorial | ||
| 533 | GNURadio : https://github.com/pothosware/PothosSDR/wiki/GNURadio | ||
| 534 | |||
| 535 | = GNURadio = | ||
| 536 | |||
| 537 | == Premier pas == | ||
| 538 | |||
| 539 | https://fr.wikibooks.org/wiki/Introduction_aux_radios_logicielles_avec_GNU_Radio/Prise_en_main | ||
| 540 | |||
| 541 | {{info}} | ||
| 542 | Ce programme a été pris de la documentation se trouvant à l'adresse du dessus ! | ||
| 543 | {{/info}} | ||
| 544 | |||
| 545 | Nous souhaitons ici générer un signal sinusoïdal s de fréquence f réglable, et afficher sa représentation graphique à la manière d'un oscilloscope numérique. Pour cela, il nous faut utiliser les blocs : | ||
| 546 | |||
| 547 | Dans le block "//Options//" , il faut changer **QT gui par WX gui** | ||
| 548 | |||
| 549 | |||
| 550 | [[image:GNUOption.PNG||height="358" width="607"]] | ||
| 551 | |||
| 552 | de génération de signaux : Signal Source (de la catégorie Waveform Generators) ; | ||
| 553 | |||
| 554 | {{info}} | ||
| 555 | Pour ajouter le module : ouvrir Waveform et double clic gauche sur signal | ||
| 556 | {{/info}} | ||
| 557 | |||
| 558 | [[image:GNUSignalSource.PNG]] | ||
| 559 | |||
| 560 | Dans //Frequency //, à la place d'une valeure, se trouve une variable **f**. Ce qui permet via un potentiomètre WX GUI Slider de la régler. Qui se trouve sous GUI Widgets - WX . | ||
| 561 | |||
| 562 | |||
| 563 | On retrouve notre variable **f **dans **ID**. Ce block n'est pas câblé. | ||
| 564 | |||
| 565 | [[image:GNUGUISlider2.PNG]] | ||
| 566 | |||
| 567 | |||
| 568 | de visualisation : WX GUI Scope Sink (de Instrumentation >> WX). | ||
| 569 | |||
| 570 | {{info}} | ||
| 571 | Pour ajouter l'instrument oscilloscope, il se trouve sous l'onglet Instrumentation - wx - wx gui scope skin | ||
| 572 | {{/info}} | ||
| 573 | |||
| 574 | = Linux = | ||
| 575 | |||
| 576 | Cette partie explique mon installation sur une distribution Ubuntu 16.04.4. Pour info j'ai créé une clef USB avec cette version avec le logiciel "RUFUS2.18" sous window XP. | ||
| 577 | Je suis sur une machine Dell Optiplex 780 64 bits. De base une windows 7 est installée, j'ai placé mon Ubuntu dessus. | ||
| 578 | |||
| 579 | $ //sudo apt update// | ||
| 580 | $ //sudo apt install gnuradio// | ||
| 581 | |||
| 582 | le programme GNURadio ce trouve dans le lanceur ( logo ubuntu ), suffit de faire une recherche avec gnu, et il apparaît. Je le lance : | ||
| 583 | |||
| 584 | [[image:gnuradio-1.png]] | ||
| 585 | |||
| 586 | python 2.7.12 c'est aussi installé ! | ||
| 587 | |||
| 588 | {{info}} | ||
| 589 | C'est pas merveilleux LINUX !! | ||
| 590 | {{/info}} | ||
| 591 | |||
| 592 | Je profite pour installer directement GQRX : | ||
| 593 | |||
| 594 | ~~$//sudo apt install gqrx-sdr// | ||
| 595 | |||
| 596 | Ensuite je branche ma clef DVB-t, et je regarde si le programme GQRX la trouve. | ||
| 597 | |||
| 598 | {{warning}} | ||
| 599 | Ma clef fonctionnait déjà ! sous SDR# | ||
| 600 | {{/warning}} | ||
| 601 | |||
| 602 | je la trouve dans les entrées du programme : | ||
| 603 | |||
| 604 | [[image:gqrx-iq.png]] | ||
| 605 | |||
| 606 | Après scan, je trouve une radio sur 98,2 MHz | ||
| 607 | |||
| 608 | |||
| 609 | == GNURadio == | ||
| 610 | |||
| 611 | {{error}} | ||
| 612 | Attention AVANT DE LANCER GNU COMPAGNON VOUS DEVEZ INSTALLER GQRX-SDR, SINON il vous manquera des bibliothèques !!! | ||
| 613 | {{/error}} | ||
| 614 | |||
| 615 | |||
| 616 | En suivant l'excellent document qui se trouve : | ||
| 617 | http://f0fyf.blogspot.ch/2014/08/recepteur-fm-avec-gnuradio.html | ||
| 618 | je réalise mon premier programme SDR avec ma clef RTL-SDR. | ||
| 619 | |||
| 620 | [[testSDR-b.grc>>attach:testSDR-b.grc]] | ||
| 621 | |||
| 622 | {{error}} | ||
| 623 | Sur une version linux , mon module "Options" n'avait pas la dimension de la page !? | ||
| 624 | ecrivez : 1280, 1024 | ||
| 625 | {{/error}} | ||
| 626 | |||
| 627 | |||
| 628 | [[image:DJtestDaarioSDR.png||height="545" width="562"]] | ||
| 629 | |||
| 630 | |||
| 631 | Normalement on doit pouvoir lancer directement avec le fichier python : | ||
| 632 | |||
| 633 | [[DJTestRadioSDR.py>>attach:DJTestRadioSDR.py||title="fonctionne avec python 2.7"]] | ||
| 634 | |||
| 635 | |||
| 636 | [[image:testRadioSDR.png||height="358" width="599"]] | ||
| 637 | |||
| 638 | |||
| 639 | C'est confirmé ! depuis un terminal : | ||
| 640 | |||
| 641 | ~~$//python DJTestRadioSDR.py// | ||
| 642 | |||
| 643 | [[image:terminalDirectPython.png||height="196" width="610"]] |