jopohl / urh

Universal Radio Hacker: Investigate Wireless Protocols Like A Boss
GNU General Public License v3.0
10.81k stars 863 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

I just noticed, that the line numbers in your sdrplay_recv.py do not quite match the latest version. Maybe there went something wrong during install? Please verify, that your C:\Program Files\Universal Radio Hacker\sdrplay_recv.py looks like below. If it doesn't you can safely copy and paste the contents.

#!/usr/bin/env python2
##################################################
# GNU Radio Python Flow Graph
# Title: Top Block
# Generated: Fri Aug 21 15:56:13 2015
##################################################

from optparse import OptionParser
import Initializer

Initializer.init_path()

from gnuradio import gr
from gnuradio.eng_option import eng_option
from grc_gnuradio import blks2 as grc_blks2
from InputHandlerThread import InputHandlerThread
import osmosdr
from gnuradio import zeromq

class top_block(gr.top_block):
    def __init__(self, samp_rate, freq, gain, bw, port):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate
        self.gain = gain
        self.freq = freq
        self.bw = bw

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "sdrplay")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(gain, 0)
        self.osmosdr_source_0.set_bb_gain(gain, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(bw, 0)

        self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:' + str(port))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.zeromq_push_sink_0, 0))

    def get_samp_rate(self):
        return self.samp_rate

    def set_samp_rate(self, samp_rate):
        self.samp_rate = samp_rate
        self.osmosdr_source_0.set_sample_rate(self.samp_rate)

    def get_gain(self):
        return self.gain

    def set_gain(self, gain):
        self.gain = gain
        self.osmosdr_source_0.set_gain(self.gain, 0)
        self.osmosdr_source_0.set_if_gain(self.gain, 0)
        self.osmosdr_source_0.set_bb_gain(self.gain, 0)

    def get_freq(self):
        return self.freq

    def set_freq(self, freq):
        self.freq = freq
        self.osmosdr_source_0.set_center_freq(self.freq, 0)

    def get_bw(self):
        return self.bw

    def set_bw(self, bw):
        self.bw = bw
        self.osmosdr_source_0.set_bandwidth(self.bw, 0)

if __name__ == '__main__':
    parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
    parser.add_option("-s", "--samplerate", dest="samplerate", help="Sample Rate", default=100000)
    parser.add_option("-f", "--freq", dest="freq", help="Frequency", default=433000)
    parser.add_option("-g", "--gain", dest="gain", help="Gain", default=30)
    parser.add_option("-b", "--bandwidth", dest="bw", help="Bandwidth", default=200000)
    parser.add_option("-p", "--port", dest="port", help="Port", default=1337)
    (options, args) = parser.parse_args()
    tb = top_block(float(options.samplerate), float(options.freq), int(options.gain),
                   float(options.bw), int(options.port))
    iht = InputHandlerThread(tb)
    iht.start()
    tb.start()
    tb.wait()

If it then should complain about a missing Initalizer.py file, just create that file in that directory with this conent:

import sys

import os
import tempfile

def init_path():
    # Append script path at end to prevent conflicts in case of frozen interpreter
    sys.path.append(sys.path.pop(0))

    try:
        with open(os.path.join(tempfile.gettempdir(), "gnuradio_path.txt"), "r") as f:
            gnuradio_path = f.read().strip()

        os.environ["PATH"] = os.path.join(gnuradio_path, "bin") + os.pathsep + os.environ["PATH"]
        sys.path.insert(0, os.path.join(gnuradio_path, "lib", "site-packages"))

    except IOError:
        pass

However, a clean reinstall (with prior uninstall) may be the better option here.

vsboost commented 6 years ago

The file was different, did an uninstall and clean install,

Traceback (most recent call last): File "C:\Program Files\Universal Radio Hacker\sdrplay_recv.py", line 18, in from gnuradio import zeromq File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\zeromq__init__.py", line 35, in from probe_manager import probe_manager File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\zeromq\probe_manager.py", line 22, in import zmq ImportError: Bad magic number in C:\Program Files\Universal Radio Hacker\zmq__init__.pyc

vsboost commented 6 years ago

Also noticed a crash when pressing the X to close the window. image

jopohl commented 6 years ago

What does

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

give you?

vsboost commented 6 years ago

C:\Python27>python.exe -c "from gnuradio import zeromq" Traceback (most recent call last): File "", line 1, in File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\zeromq__init__.py", line 35, in from probe_manager import probe_manager File "C:\Program Files\PothosSDR\lib\python2.7\site-packages\gnuradio\zeromq\probe_manager.py", line 22, in import zmq ImportError: No module named zmq

C:\Python27>

jopohl commented 6 years ago

Seems like you have no zeromq installed for you python2 interpreter. You could try this:

C:\Python27\python.exe -m pip install pyzmq
vsboost commented 6 years ago

Getting close now lol

image

gr-osmosdr v0.1.4-98-gc653754d (0.1.5git) gnuradio 3.7.11.1 built-in source types: file osmosdr fcd rtl rtl_tcp uhd miri hackrf bladerf airspy soapy redpitaya [ERROR] SoapySDR::loadModule(C:\Program Files\PothosSDR/lib/SoapySDR/modules0.6/LMS7Support.dll) LoadLibrary() failed: The specified procedure could not be found.



FATAL: GR-UHD detected ABI compatibility mismatch with UHD library. GR-UHD was build against ABI: 3.10.2, but UHD library reports ABI: 3.10.1 Suggestion: install an ABI compatible version of UHD, or rebuild GR-UHD component against this ABI version.

Trying to fill up 1 missing channel(s) with null source(s). This is being done to prevent the application from crashing due to gnuradio bug #528.

vsboost commented 6 years ago

This may be an issue with Pothos by the looks of it, so don't worry too much about it if it cant be done.. I always have hackrf to capture with. :-)

jopohl commented 6 years ago

Looks also like a PothosSDR error for me, maybe Pothos is not supposed to be used in this way.

You still have the option to install the official GNU Radio for Windows, which is better supported. If you do so, you need to configure the GNU Radio install dir in URH options.

Unfortunately, we do not have the budget at the moment to afford a SDRPlay. I would add native support otherwise.

vsboost commented 6 years ago

Thanks Johannes for trying, ill try to reach out to the SDRPlay team and see what they can arrange, do you have an email address i could send them to contact you?

jopohl commented 6 years ago

Sure, just use my GMail address: Johannes.Pohl90@gmail.com Thanks for your support.

vsboost commented 6 years ago

No.. Thank you.. Can close this one if need be.