Last active
January 28, 2018 11:27
-
-
Save gvanem/8ebc16da2eb367aec3f0ef5f2544c675 to your computer and use it in GitHub Desktop.
A diff to enable multiple SDR-sticks in Welle-IO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -Hb -u3 a/src/CRadioController.cpp src/CRadioController.cpp | |
| --- a/src/CRadioController.cpp 2018-01-25 17:15:49 | |
| +++ b/src/CRadioController.cpp 2018-01-28 11:08:21 | |
| @@ -185,6 +185,8 @@ | |
| QString dabDevice = "auto"; | |
| #endif | |
| + int instance = 0; | |
| + | |
| #ifdef HAVE_SOAPYSDR | |
| QString sdrDriverArgs; | |
| QString sdrAntenna; | |
| @@ -198,6 +200,9 @@ | |
| if(commandLineOptions["dabDevice"] != "") | |
| dabDevice = commandLineOptions["dabDevice"].toString(); | |
| + if(commandLineOptions["instance"] != "") | |
| + instance = commandLineOptions["instance"].toInt(); | |
| + | |
| #ifdef HAVE_SOAPYSDR | |
| if(commandLineOptions["sdr-driver-args"] != "") | |
| sdrDriverArgs = commandLineOptions["sdr-driver-args"].toString(); | |
| @@ -223,7 +228,7 @@ | |
| // Init device | |
| CSplashScreen::ShowMessage(tr("Init radio receiver")); | |
| - Device = CInputFactory::GetDevice(*this, dabDevice); | |
| + Device = CInputFactory::GetDevice(*this, dabDevice, instance); | |
| // Set rtl_tcp settings | |
| if (Device->getID() == CDeviceID::RTL_TCP) { | |
| diff -Hb -u3 a/src/input/CInputFactory.cpp src/input/CInputFactory.cpp | |
| --- a/src/input/CInputFactory.cpp 2017-09-28 18:06:03 | |
| +++ b/src/input/CInputFactory.cpp 2018-01-28 11:00:27 | |
| @@ -42,16 +42,16 @@ | |
| #include "CSoapySdr.h" | |
| #endif | |
| -CVirtualInput *CInputFactory::GetDevice(CRadioController &RadioController, QString Device) | |
| +CVirtualInput *CInputFactory::GetDevice(CRadioController &RadioController, QString Device, int instance /* = 0 */) | |
| { | |
| CVirtualInput *InputDevice = NULL; | |
| qDebug() << "InputFactory:" << "Input device:" << Device; | |
| if(Device == "auto") | |
| - InputDevice = GetAutoDevice(RadioController); | |
| + InputDevice = GetAutoDevice(RadioController, instance); | |
| else | |
| - InputDevice = GetManualDevice(RadioController, Device); | |
| + InputDevice = GetManualDevice(RadioController, Device, instance); | |
| // Fallback if no device is found or an error occured | |
| if(InputDevice == NULL) | |
| @@ -71,7 +71,7 @@ | |
| return InputDevice; | |
| } | |
| -CVirtualInput *CInputFactory::GetAutoDevice(CRadioController &RadioController) | |
| +CVirtualInput *CInputFactory::GetAutoDevice(CRadioController &RadioController, int instance) | |
| { | |
| (void) RadioController; | |
| CVirtualInput *InputDevice = NULL; | |
| @@ -87,7 +87,7 @@ | |
| case 0: InputDevice = new CAirspy(); break; | |
| #endif | |
| #ifdef HAVE_RTLSDR | |
| - case 1: InputDevice = new CRTL_SDR(RadioController); break; | |
| + case 1: InputDevice = new CRTL_SDR(RadioController, instance); break; | |
| #endif | |
| #ifdef HAVE_SOAPYSDR | |
| case 2: InputDevice = new CSoapySdr(); break; | |
| @@ -110,7 +110,7 @@ | |
| return InputDevice; | |
| } | |
| -CVirtualInput *CInputFactory::GetManualDevice(CRadioController &RadioController, QString Device) | |
| +CVirtualInput *CInputFactory::GetManualDevice(CRadioController &RadioController, QString Device, int instance) | |
| { | |
| CVirtualInput *InputDevice = NULL; | |
| @@ -126,7 +126,7 @@ | |
| else | |
| #ifdef HAVE_RTLSDR | |
| if (Device == "rtl_sdr") | |
| - InputDevice = new CRTL_SDR(RadioController); | |
| + InputDevice = new CRTL_SDR(RadioController, instance); | |
| else | |
| #endif | |
| #ifdef HAVE_SOAPYSDR | |
| @@ -143,7 +143,7 @@ | |
| // Catch all exceptions | |
| catch(...) | |
| { | |
| - qDebug() << "InputFactory:" << "Error while opening device \"" << Device << "\"."; | |
| + qDebug() << "InputFactory:" << "Error while opening device \"" << Device << "\" (instance " << instance << ".)"; | |
| } | |
| return InputDevice; | |
| diff -Hb -u3 a/src/input/CInputFactory.h src/input/CInputFactory.h | |
| --- a/src/input/CInputFactory.h 2017-06-29 14:11:34 | |
| +++ b/src/input/CInputFactory.h 2018-01-28 10:58:35 | |
| @@ -35,11 +35,11 @@ | |
| class CInputFactory | |
| { | |
| public: | |
| - static CVirtualInput* GetDevice(CRadioController &RadioController, QString Device); | |
| + static CVirtualInput* GetDevice(CRadioController &RadioController, QString Device, int instance = 0); | |
| private: | |
| - static CVirtualInput* GetAutoDevice(CRadioController &RadioController); | |
| - static CVirtualInput* GetManualDevice(CRadioController &RadioController, QString Device); | |
| + static CVirtualInput* GetAutoDevice(CRadioController &RadioController, int instance); | |
| + static CVirtualInput* GetManualDevice(CRadioController &RadioController, QString Device, int instance); | |
| }; | |
| #endif // CINPUTFACTORY_H | |
| diff -Hb -u3 a/src/input/CRTL_SDR.cpp src/input/CRTL_SDR.cpp | |
| --- a/src/input/CRTL_SDR.cpp 2017-10-21 14:18:26 | |
| +++ b/src/input/CRTL_SDR.cpp 2018-01-28 11:09:40 | |
| @@ -67,14 +67,17 @@ | |
| } | |
| // Our wrapper is a simple classs | |
| -CRTL_SDR::CRTL_SDR(CRadioController &RadioController) : | |
| +CRTL_SDR::CRTL_SDR(CRadioController &RadioController, int instance) : | |
| SampleBuffer(1024 * 1024), | |
| SpectrumSampleBuffer(8192) | |
| { | |
| int ret = 0; | |
| + int first_dev = 0; | |
| + int last_dev = 0; | |
| this->RadioController = &RadioController; | |
| qDebug() << "RTL_SDR:" << "Open rtl-sdr"; | |
| @@ -98,13 +101,21 @@ | |
| qDebug() << "RTL_SDR:" << "No devices found"; | |
| throw 0; | |
| } | |
| + else if (instance > 0) | |
| + { | |
| + first_dev = instance; | |
| + last_dev = instance+1; | |
| + qDebug() << "RTL_SDR:" << "Found" << deviceCount << "devices. Try to open instance" << instance; | |
| + } | |
| else | |
| { | |
| + last_dev = deviceCount; | |
| qDebug() << "RTL_SDR:" << "Found" << deviceCount << "devices. Uses the first working one"; | |
| } | |
| + // Check only a single 'instance' rtl-sdr device or. | |
| // Iterate over all found rtl-sdr devices and try to open it. Stops if one device is successfull opened. | |
| - for(uint32_t i=0; i<deviceCount; i++) | |
| + for(uint32_t i = first_dev; i < last_dev; i++) | |
| { | |
| ret = rtlsdr_open(&device, i); | |
| if (ret >= 0) | |
| @@ -116,7 +127,7 @@ | |
| if (ret < 0) | |
| { | |
| - qDebug() << "RTL_SDR:" << "Opening rtl-sdr failed"; | |
| + qDebug() << "RTL_SDR:" << "Opening rtl-sdr failed (instance: " << instance << ")"; | |
| throw 0; | |
| } | |
| diff -Hb -u3 a/src/input/CRTL_SDR.h src/input/CRTL_SDR.h | |
| --- a/src/input/CRTL_SDR.h 2017-09-28 18:06:03 | |
| +++ b/src/input/CRTL_SDR.h 2018-01-28 10:52:23 | |
| @@ -51,7 +51,7 @@ | |
| class CRTL_SDR : public CVirtualInput { | |
| Q_OBJECT | |
| public: | |
| - CRTL_SDR(CRadioController &RadioController); | |
| + CRTL_SDR(CRadioController &RadioController, int instance = 0); | |
| ~CRTL_SDR(void); | |
| // Interface methods |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment