diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 5e936a4..7296799 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -768,6 +768,8 @@ void AppFrame::OnMenu(wxCommandEvent& event) { } void AppFrame::OnClose(wxCloseEvent& event) { + wxGetApp().closeDeviceSelector(); + wxGetApp().getDemodSpectrumProcessor()->removeOutput(demodSpectrumCanvas->getVisualDataQueue()); wxGetApp().getDemodSpectrumProcessor()->removeOutput(demodWaterfallCanvas->getVisualDataQueue()); wxGetApp().getSpectrumProcessor()->removeOutput(spectrumCanvas->getVisualDataQueue()); diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index 28509b3..186f9a8 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -279,10 +279,26 @@ bool CubicSDR::OnCmdLineParsed(wxCmdLineParser& parser) { #else useLocalMod.store(true); #endif + + wxString *modPath = new wxString; + + if (parser.Found("m",modPath)) { + if (modPath) { + modulePath = modPath->ToStdString(); + } else { + modulePath = ""; + } + } return true; } +void CubicSDR::closeDeviceSelector() { + if (deviceSelectorOpen) { + deviceSelectorDialog->Close(); + } +} + void CubicSDR::deviceSelector() { if (deviceSelectorOpen) { deviceSelectorDialog->Raise(); @@ -623,4 +639,8 @@ void CubicSDR::setDeviceArgs(SoapySDR::Kwargs settingArgs_in) { bool CubicSDR::getUseLocalMod() { return useLocalMod.load(); -} \ No newline at end of file +} + +std::string CubicSDR::getModulePath() { + return modulePath; +} diff --git a/src/CubicSDR.h b/src/CubicSDR.h index faff1c3..9cba67a 100644 --- a/src/CubicSDR.h +++ b/src/CubicSDR.h @@ -102,6 +102,8 @@ public: void setDeviceSelectorClosed(); bool isDeviceSelectorOpen(); + void closeDeviceSelector(); + void setAGCMode(bool mode); bool getAGCMode(); @@ -113,6 +115,8 @@ public: void setDeviceArgs(SoapySDR::Kwargs settingArgs_in); bool getUseLocalMod(); + std::string getModulePath(); + private: AppFrame *appframe; AppConfig config; @@ -153,6 +157,7 @@ private: std::atomic_bool sampleRateInitialized; std::atomic_bool useLocalMod; std::string notifyMessage; + std::string modulePath; std::mutex notify_busy; }; @@ -161,6 +166,7 @@ static const wxCmdLineEntryDesc commandLineInfo [] = { { wxCMD_LINE_SWITCH, "h", "help", "Command line parameter help", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_OPTION, "c", "config", "Specify a named configuration to use, i.e. '-c ham'" }, + { wxCMD_LINE_OPTION, "m", "modpath", "Load modules from suppplied path, i.e. '-m ~/SoapyMods/'" }, { wxCMD_LINE_SWITCH, "b", "bundled", "Use bundled SoapySDR modules first instead of local." }, { wxCMD_LINE_NONE } }; @@ -169,6 +175,7 @@ static const wxCmdLineEntryDesc commandLineInfo [] = { { wxCMD_LINE_SWITCH, "h", "help", "Command line parameter help", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_OPTION, "c", "config", "Specify a named configuration to use, i.e. '-c ham'" }, + { wxCMD_LINE_OPTION, "m", "modpath", "Load modules from suppplied path, i.e. '-m ~/SoapyMods/'" }, { wxCMD_LINE_NONE } }; #endif diff --git a/src/sdr/SDREnumerator.cpp b/src/sdr/SDREnumerator.cpp index 236fea3..991555a 100644 --- a/src/sdr/SDREnumerator.cpp +++ b/src/sdr/SDREnumerator.cpp @@ -38,32 +38,45 @@ std::vector *SDREnumerator::enumerate_devices(std::string remot std::cout << "\tInstall root: " << SoapySDR::getRootPath() << std::endl; std::cout << "\tLoading modules... " << std::endl; - #ifdef BUNDLE_SOAPY_MODS - bool localModPref = wxGetApp().getUseLocalMod(); - if (localModPref) { - wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules.."); - std::cout << "Checking local system SoapySDR modules.." << std::flush; - SoapySDR::loadModules(); - } + + std::string userModPath = wxGetApp().getModulePath(); + + if (userModPath != "") { + wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules from " + userModPath + ".."); + std::vector localMods = SoapySDR::listModules(userModPath); + for (std::vector::iterator mods_i = localMods.begin(); mods_i != localMods.end(); mods_i++) { + wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Initializing user specified SoapySDR module " + (*mods_i) + ".."); + std::cout << "Initializing user specified SoapySDR module " << (*mods_i) << ".." << std::endl; + SoapySDR::loadModule(*mods_i); + } + } else { + #ifdef BUNDLE_SOAPY_MODS + bool localModPref = wxGetApp().getUseLocalMod(); + if (localModPref) { + wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules.."); + std::cout << "Checking local system SoapySDR modules.." << std::flush; + SoapySDR::loadModules(); + } - wxFileName exePath = wxFileName(wxStandardPaths::Get().GetExecutablePath()); - std::vector localMods = SoapySDR::listModules(exePath.GetPath().ToStdString() + "/modules/"); - for (std::vector::iterator mods_i = localMods.begin(); mods_i != localMods.end(); mods_i++) { - wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Initializing bundled SoapySDR module " + (*mods_i) + ".."); - std::cout << "Loading bundled SoapySDR module " << (*mods_i) << ".." << std::endl; - SoapySDR::loadModule(*mods_i); - } - - if (!localModPref) { + wxFileName exePath = wxFileName(wxStandardPaths::Get().GetExecutablePath()); + std::vector localMods = SoapySDR::listModules(exePath.GetPath().ToStdString() + "/modules/"); + for (std::vector::iterator mods_i = localMods.begin(); mods_i != localMods.end(); mods_i++) { + wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Initializing bundled SoapySDR module " + (*mods_i) + ".."); + std::cout << "Loading bundled SoapySDR module " << (*mods_i) << ".." << std::endl; + SoapySDR::loadModule(*mods_i); + } + + if (!localModPref) { + wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules.."); + std::cout << "Checking system SoapySDR modules.." << std::flush; + SoapySDR::loadModules(); + } + #else wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules.."); - std::cout << "Checking system SoapySDR modules.." << std::flush; SoapySDR::loadModules(); - } - #else - wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules.."); - SoapySDR::loadModules(); - #endif + #endif + } // modules = SoapySDR::listModules(); // for (size_t i = 0; i < modules.size(); i++) { // std::cout << "\tModule found: " << modules[i] << std::endl;