jopohl / urh

Universal Radio Hacker: Investigate Wireless Protocols Like A Boss
GNU General Public License v3.0
10.96k stars 873 forks source link

Enable SDRPlay in Windows version #371

Closed vsboost closed 6 years ago

vsboost commented 6 years ago

I'm unable to enable SDRPlay in windows version .msi

Not sure if it requires a dll file like other sdr's in the C:\Program Files\Universal Radio Hacker directory Also i have the pothossdr suite installed and am able to use gqrx in windows with the SDRPlay, not sure if that makes a difference or not. image

jopohl commented 6 years ago

SDRPlay has unfortunately no native support. You can use it via the GNU Radio backend, by entering the directory GNU Radio was installed to at the bottom of the dialog.

vsboost commented 6 years ago

I tried to, but which directory do you choose? it seems like there needs to be some sort of OK button once the directory is picked, i have tried. C:\Program Files\PothosSDR\bin C:\Program Files\PothosSDR\include\gnuradio C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio

But what ever i choose doesn't seem to stick.

jopohl commented 6 years ago

It should be the one where GNU Radios python.exe is located at. I am not sure if this is compatible with PothosSDR (never tried that).

The supported way is to use the official GNU Radio installer from here.

jopohl commented 6 years ago

Just had a look at the source. There should be a directory gr-python27 in the directory you define here. For example, lets assume you installed GNU Radio to C:\Programs then C:\Programs\GNURadio-3.7 will work, because the directory C:\Programs\GNURadio-3.7\gr-python27 exists.

vsboost commented 6 years ago

Unfortunately it seems that there is no gr-python27 directory with pothossdr :-(

C:. ├───bin │ ├───iconengines │ └───platforms ├───cmake ├───etc │ └───gnuradio │ └───conf.d ├───include │ ├───cppunit │ │ ├───config │ │ ├───extensions │ │ ├───plugin │ │ ├───portability │ │ ├───tools │ │ └───ui │ │ └───text │ ├───drm │ │ └───drm │ │ └───swig │ ├───gnuradio │ │ ├───analog │ │ ├───atsc │ │ ├───audio │ │ ├───blocks │ │ ├───channels │ │ ├───digital │ │ ├───dtv │ │ ├───fcd │ │ ├───fec │ │ ├───fft │ │ ├───filter │ │ ├───messages │ │ ├───noaa │ │ ├───pager │ │ ├───swig │ │ ├───thread │ │ ├───trellis │ │ ├───uhd │ │ ├───vocoder │ │ ├───wavelet │ │ ├───wxgui │ │ └───zeromq │ ├───gsl │ ├───libairspy │ ├───libhackrf │ ├───libusb-1.0 │ ├───lime │ ├───liquid │ ├───muparserx │ ├───osmosdr │ │ └───swig │ ├───pmt │ ├───Poco │ │ ├───Data │ │ │ ├───ODBC │ │ │ └───SQLite │ │ ├───DOM │ │ ├───Dynamic │ │ ├───JSON │ │ ├───MongoDB │ │ ├───Net │ │ ├───Redis │ │ ├───SAX │ │ ├───Util │ │ ├───XML │ │ └───Zip │ ├───Pothos │ │ ├───Archive │ │ ├───Callable │ │ ├───Framework │ │ ├───Managed │ │ ├───Object │ │ ├───Plugin │ │ ├───Proxy │ │ ├───Remote │ │ ├───System │ │ └───Util │ ├───rds │ │ ├───gnuradio │ │ │ └───rds │ │ └───rds │ │ └───swig │ ├───rftap │ ├───SoapySDR │ ├───spuce │ │ ├───dsp_classes │ │ ├───dsp_functions │ │ └───filters │ ├───sys │ ├───uhd │ │ ├───transport │ │ ├───types │ │ ├───usrp │ │ ├───usrp_clock │ │ └───utils │ └───volk ├───lib │ ├───cmake │ │ ├───drm │ │ ├───gnuradio │ │ ├───Poco │ │ ├───rftap │ │ ├───uhd │ │ └───volk │ ├───pkgconfig │ ├───Pothos │ │ └───modules0.5 │ │ ├───audio │ │ ├───blocks │ │ │ └───gnuradio │ │ ├───btle │ │ ├───comms │ │ ├───gnuradio │ │ ├───gui │ │ ├───liquid │ │ ├───lora │ │ ├───plotters │ │ ├───PothosTestBlocks │ │ ├───proxy │ │ │ └───environment │ │ ├───sdr │ │ └───widgets │ ├───python2.7 │ │ └───site-packages │ │ ├───drm │ │ ├───gnuradio │ │ │ ├───analog │ │ │ ├───atsc │ │ │ ├───audio │ │ │ ├───blocks │ │ │ ├───channels │ │ │ ├───ctrlport │ │ │ ├───digital │ │ │ │ └───utils │ │ │ ├───dtv │ │ │ ├───fcd │ │ │ ├───fec │ │ │ │ ├───LDPC │ │ │ │ └───polar │ │ │ ├───fft │ │ │ ├───filter │ │ │ ├───gr │ │ │ ├───grc │ │ │ │ ├───core │ │ │ │ │ ├───generator │ │ │ │ │ └───utils │ │ │ │ └───gui │ │ │ ├───gru │ │ │ ├───modtool │ │ │ ├───noaa │ │ │ ├───pager │ │ │ ├───trellis │ │ │ ├───uhd │ │ │ ├───vocoder │ │ │ ├───wavelet │ │ │ ├───wxgui │ │ │ │ ├───forms │ │ │ │ └───plotter │ │ │ └───zeromq │ │ ├───grc_gnuradio │ │ │ ├───blks2 │ │ │ └───wxgui │ │ ├───osmosdr │ │ ├───pmt │ │ ├───Pothos │ │ ├───PothosTestBlocks │ │ ├───rds │ │ ├───rftap │ │ └───volk_modtool │ ├───python3.6 │ │ └───site-packages │ │ ├───Pothos │ │ └───PothosTestBlocks │ ├───SoapySDR │ │ └───modules0.6 │ └───uhd │ ├───examples │ ├───modules │ ├───tests │ │ └───devtest │ └───utils ├───licenses │ ├───airspy │ ├───bladeRF │ ├───Boost │ ├───BtleDemo │ ├───CppUnit │ ├───CppZMQ │ ├───CubicSDR │ ├───faac │ ├───faad2 │ ├───fftw │ ├───GNURadio │ ├───GnuradioCompanionExe │ ├───GQRX │ ├───GrDRM │ ├───GrOsmoSDR │ ├───GrPothos │ ├───GrRDS │ ├───GrRFtap │ ├───gsl │ ├───hackRF │ ├───Inspectrum │ ├───kissfft │ ├───libusb │ ├───LimeSuite │ ├───liquiddsp │ ├───LoRaDemo │ ├───miri-sdr │ ├───mman │ ├───muparserx │ ├───osmo-sdr │ ├───Poco │ ├───PortAudio │ ├───Pothos │ ├───PothosAudio │ ├───PothosBlocks │ ├───PothosComms │ ├───PothosCore │ ├───PothosGui │ ├───PothosLiquidDSP │ ├───PothosPlotters │ ├───PothosPython2 │ ├───PothosPython3 │ ├───PothosSDR │ ├───PothosWidgets │ ├───Pthreads │ ├───Qt │ ├───qtcolorpicker │ ├───qwt │ ├───rtl-sdr │ ├───SoapyAirspy │ ├───SoapyAudio │ ├───SoapyBladeRF │ ├───SoapyHackRF │ ├───SoapyOsmo │ ├───SoapyRedPitaya │ ├───SoapyRemote │ ├───SoapyRTLSDR │ ├───SoapyRxTools │ ├───SoapySDR │ ├───SoapySDRPlay │ ├───SoapyUHD │ ├───Spuce │ ├───swig │ ├───udt │ ├───uhd │ ├───umtrx │ ├───volk │ ├───wxWidgets │ └───ZeroMQ ├───patches ├───Scripts └───share ├───cubicsdr │ └───fonts ├───doc │ ├───gnuradio-3.7.11.1 │ │ └───xml │ └───uhd ├───gnuradio │ ├───examples │ │ ├───analog │ │ ├───atsc │ │ ├───audio │ │ ├───blocks │ │ ├───channels │ │ ├───ctrlport │ │ ├───digital │ │ │ ├───demod │ │ │ ├───narrowband │ │ │ ├───ofdm │ │ │ └───packet │ │ ├───dtv │ │ ├───fcd │ │ ├───fec │ │ ├───filter │ │ ├───hf_explorer │ │ ├───hf_radio │ │ ├───metadata │ │ ├───mp-sched │ │ ├───network │ │ ├───noaa │ │ ├───tags │ │ ├───trellis │ │ │ └───fsm_files │ │ ├───uhd │ │ ├───vocoder │ │ ├───volk_benchmark │ │ └───zeromq │ ├───fec │ │ └───ldpc │ ├───grc │ │ ├───blocks │ │ └───freedesktop │ └───modtool │ └───gr-newmod │ ├───apps │ ├───cmake │ │ └───Modules │ ├───docs │ │ └───doxygen │ │ ├───doxyxml │ │ │ └───generated │ │ └───other │ ├───examples │ ├───grc │ ├───include │ │ └───howto │ ├───lib │ ├───python │ └───swig ├───man │ └───man1 └───uhd └───rfnoc └───blocks

C:\Program Files\PothosSDR>

jopohl commented 6 years ago

Seems like this woll not work then. Is there a python.exe somewhere in the Pothos Install dir? If so, I could maybe add support for it.

Is it an option for you to install GNU Radio to get the backend working?

jopohl commented 6 years ago

What you could also try is to define the path to the python 2 Interpreter (assuming you have one installed). I could imagine, that PothosSDR modifies the PYTHONPATH so it may be enough to just configure a Python 2 interpreter.

vsboost commented 6 years ago

Unfortunately no python.exe within C:\Program Files\PothosSDR With the PothosSDR bundle Gnuradio does work and is located in "C:\Program Files\PothosSDR\bin\gnuradio-companion.exe"

My python directory is C:\Python27

vsboost commented 6 years ago

PYTHONPATH=C:\Program Files\PothosSDR\lib\python2.7\site-packages

jopohl commented 6 years ago

It may work if you choose the radio button "Python2 interpreter" in the URH dialog from your screenshot and enter C:\Python27.

vsboost commented 6 years ago

Tried that too, but the settings does not stay. Its like there needs to be an OK button when the directory is chosen if that makes sense.

image

vsboost commented 6 years ago

As soon as you close the dialog box and get back in it defaults back to. image

jopohl commented 6 years ago

This setting should stay if it works. If there is an error it defaults back to the empty value. You can check if your Python2 interpreter has GNU Radio support with this command:

C:\Python27\python.exe -c 'import gnuradio'
vsboost commented 6 years ago

No Go.

C:\Python27>python.exe -c 'import gnuradio' File "", line 1 'import ^ SyntaxError: EOL while scanning string literal

C:\Python27>

jopohl commented 6 years ago

Looks like the Windows CMD behaves a bit weird. If you are in that directory you can also simply enter python.exe in command line this will bring you in the interactive python shell. From here you can then type

>>> import gnuradio

and see if it works.

If that is so, you can try to enter C:\Python27\python.exe to the Python2 interpreter field in URH. Just realized that you need to give an actual interpreter there, and not just a directory.

vsboost commented 6 years ago

C:\Python27>python.exe Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import gnuradio

jopohl commented 6 years ago

Is it working when you press enter?

vsboost commented 6 years ago

Yep, it accepts it when i enter the full filename. image

vsboost commented 6 years ago

But still cant enable SDRPlay :-(

image

jopohl commented 6 years ago

Was the import gnuradio successful after pressing enter in the python interpreter or did it raise an ImportError?

vsboost commented 6 years ago

No, it just came up blank.

image

jopohl commented 6 years ago

This is actually a good sign! I have a suspicion what is going wrong here. Could you try entering

C:\Python27\python.exe -c "import gnuradio"

with double quotes instead of single quotes like before and see if this runs without error?

vsboost commented 6 years ago

Runs without error.

C:\Python27>python.exe -c "import gnuradio"

C:\Python27>

jopohl commented 6 years ago

Thanks for your help, this is actually a Windows Bug in URH then because the Windows CMD, unlike a linux shell, does not work with single quotes in this case.

I will fix this ASAP.

vsboost commented 6 years ago

Thanks Jopohl,

Your work is truly appreciated.

xykts commented 6 years ago

windows msi install version how to solve the problem?

Thanks jopohl

xykts commented 6 years ago

sdrplay api is open ! Can it be native to support it?

jopohl commented 6 years ago

Just released version 1.8.17 which adresses this issue.

@xykts I would like to add a native support. However, we do not possess any devices for testing. If you or someone you know can provide us with two test devices we may add it to our agenda.

xykts commented 6 years ago

i am windows run urh(py36)+sdrplay problems arose

C:\Users\Administrator>urh Will not regenerate UI, because script can't be found. This is okay in release. Win32; Microsoft Visual C++ version 14.0; Boost_105900; UHD_003.010.001.001-rele ase

[DEBUG::SpectrumThread.py::run] Spectrum Thread: Init Process [INFO::AbstractBaseThread.py::initialize_process] Starting Gnuradio [DEBUG::AbstractBaseThread.py::initialize_process] C:\Python27\python.exe c:\pyt hon36\lib\site-packages\urh\dev\gr\scripts\sdrplay_recv.py --samplerate 2000000. 0 --freq 433920000.0 --gain 25 --bandwidth 2000000.0 --port 1337 [INFO::AbstractBaseThread.py::initialize_process] Started Gnuradio [DEBUG::SpectrumThread.py::run] Spectrum Thread: Process Intialized [INFO::AbstractBaseThread.py::init_recv_socket] Initalizing receive socket [INFO::AbstractBaseThread.py::init_recv_socket] Initalized receive socket [INFO::AbstractBaseThread.py::init_recv_socket] Trying to get a connection to gn uradio... [INFO::AbstractBaseThread.py::init_recv_socket] Got connection [DEBUG::SpectrumThread.py::run] Spectrum Thread: Socket initialized [DEBUG::SpectrumThread.py::run] Spectrum Thread: Enter main loop Traceback (most recent call last): File "c:\python36\lib\site-packages\urh\controller\SpectrumDialogController.py ", line 90, in update_view if super().update_view(): File "c:\python36\lib\site-packages\urh\controller\SendRecvDialogController.py ", line 555, in update_view new_messages = self.device.read_messages() File "c:\python36\lib\site-packages\urh\dev\VirtualDevice.py", line 594, in re ad_messages return self.__dev.read_errors() File "c:\python36\lib\site-packages\urh\dev\gr\AbstractBaseThread.py", line 27 1, in read_errors return result.decode("utf-8") UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 131: invali d continuation byte

jopohl commented 6 years ago

Does it work with GNU Radio?

jopohl commented 6 years ago

Could you try it with this installer? I just build it with a version where I catched the Unicode Error.

xykts commented 6 years ago

i am the pip install version

jopohl commented 6 years ago

Ah I see, then please replace line 27 ( return result.decode("utf-8")) in c:\python36\lib\site-packages\urh\dev\gr\AbstractBaseThread.py with this:

        try:
            return result.decode("utf-8")
        except UnicodeDecodeError:
            return "Could not decode device message"

and see if it works then. If so, it will be included in next release.

xykts commented 6 years ago

This is effective. It seems that there is no correct reception

image

jopohl commented 6 years ago

Could you share your top_block.py from your GNU Radio example ?

xykts commented 6 years ago

uplpad sdrplay api , try to build add a native support.

Thanks jopohl SDRplay.zip

xykts commented 6 years ago

This is my gnuradio top_block.py

top_block.zip

jopohl commented 6 years ago

Does it help if you change c:\pyt hon36\lib\site-packages\urh\dev\gr\scripts\sdrplay_recv.py :62 from

self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "sdrplay")

to

self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'sdrplay=0' )

Sorry for the long shots, but the SDRplay support was actually added by the community, so I can not verify my ideas because I do not possess an SDRPlay device. This would also make it very hard to develop a native interface.

xykts commented 6 years ago

Change this" sdrplay=0"

There is no use for anything,In the same way as the above

xykts commented 6 years ago

Pothos sdr uses soapy device sdrplay

Soapy imitates UHD devices,I can use USRP as an input But the received signals are problematic. This may be a problem with soapy

So it's still building native support.

image

jopohl commented 6 years ago

Can you provide us with some test devices or make a PR with native support?

xykts commented 6 years ago

I'm sorry that my English is poor. I think I can only do remote testing sdrplay native support !Sdrplay.com $99 for RSP1A! I'm not familiar with international shipping I don't know what I can do

Thank you very much! I'm here at one o'clock in the morning, and I go to bed first

jopohl commented 6 years ago

Sure get some sleep mate. :+1: I will talk with @andynoack about this. Maybe we have some bucks left so we can buy at least one them, as $99 is not that expensive.

vsboost commented 6 years ago

Im getting. image

image

jopohl commented 6 years ago

This seems to be an issue with the python2 interpreter. Does it work when you run this in terminal:

C:\Python27\python.exe -c "from gnuradio import gr"

Note the slight difference to the test we did above.

vsboost commented 6 years ago

It just returns a blank new line. image

jopohl commented 6 years ago

What happens if you call:

C:\Python27\python.exe "C:\Program Files\Universal Radio Hacker\sdrplay_recv.py"

from command line?

vsboost commented 6 years ago

C:>cd Python27

C:\Python27>C:\Python27\python.exe "C:\Program Files\Universal Radio Hacker\sdrplay_recv.py" Traceback (most recent call last): File "C:\Program Files\Universal Radio Hacker\sdrplay_recv.py", line 25, in from gnuradio import gr File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\gr__init__.py", line 41, in from runtime_swig import * File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\gr\runtime_swig.py", line 17, in _runtime_swig = swig_import_helper() File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\gr\runtime_swig.py", line 14, in swig_import_helper return importlib.import_module(mname) AttributeError: 'module' object has no attribute 'import_module'

C:\Python27>

jopohl commented 6 years ago

Alright, this is the same error as in the application. Please add print("SYS Path", sys.path) before line 25 of C:\Program Files\Universal Radio Hacker\sdrplay_recv.py and run it again, so we can see what is in sys.path at this point.

Futhermore, please share the output of C:\Python27\python.exe -c "import sys; print(sys.path)" for comparision.

vsboost commented 6 years ago

C:\Python27>C:\Python27\python.exe "C:\Program Files\Universal Radio Hacker\sdrplay_recv.py" ('SYS Path', ['C:\Program Files\Universal Radio Hacker', 'C:\Program Files\PothosSDR\lib\python2.7\site-packages', 'C:\WINDOWS\SYSTEM32\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib', 'C:\Python27\lib\plat-win', 'C:\Python27\lib\lib-tk', 'C:\Python27', 'C:\Python27\lib\site-packages', 'C:\Python27\lib\site-packages\gtk-2.0', 'C:\Python27\lib\site-packages\wx-3.0-msw']) Traceback (most recent call last): File "C:\Program Files\Universal Radio Hacker\sdrplay_recv.py", line 26, in from gnuradio import gr File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\gr__init__.py", line 41, in from runtime_swig import * File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\gr\runtime_swig.py", line 17, in _runtime_swig = swig_import_helper() File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\gr\runtime_swig.py", line 14, in swig_import_helper return importlib.import_module(mname) AttributeError: 'module' object has no attribute 'import_module'

C:\Python27> C:\Python27>C:\Python27\python.exe -c "import sys; print(sys.path)" ['', 'C:\Program Files\PothosSDR\lib\python2.7\site-packages', 'C:\WINDOWS\SYSTEM32\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib', 'C:\Python27\lib\plat-win', 'C:\Python27\lib\lib-tk', 'C:\Python27', 'C:\Python27\lib\site-packages', 'C:\Python27\lib\site-packages\gtk-2.0', 'C:\Python27\lib\site-packages\wx-3.0-msw']

C:\Python27>