2014-10-27 20:05:40 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
//WX_GL_CORE_PROFILE 1
|
|
|
|
//WX_GL_MAJOR_VERSION 3
|
|
|
|
//WX_GL_MINOR_VERSION 2
|
|
|
|
|
2014-11-23 19:39:27 -05:00
|
|
|
#include <thread>
|
|
|
|
|
2015-02-09 20:49:21 -05:00
|
|
|
#include "GLExt.h"
|
2014-10-27 21:22:29 -04:00
|
|
|
#include "PrimaryGLContext.h"
|
2014-10-27 20:05:40 -04:00
|
|
|
|
2014-11-23 19:39:27 -05:00
|
|
|
#include "ThreadQueue.h"
|
2015-09-13 22:18:29 -04:00
|
|
|
#ifdef USE_RTL_SDR
|
|
|
|
#include "SDRThread.h"
|
|
|
|
#else
|
|
|
|
#include "SoapySDRThread.h"
|
2015-10-04 16:07:14 -04:00
|
|
|
#include "SDREnumerator.h"
|
2015-09-13 22:18:29 -04:00
|
|
|
#endif
|
2014-11-29 13:58:20 -05:00
|
|
|
#include "SDRPostThread.h"
|
2014-11-23 19:39:27 -05:00
|
|
|
#include "AudioThread.h"
|
|
|
|
#include "DemodulatorMgr.h"
|
2015-04-13 19:58:34 -04:00
|
|
|
#include "AppConfig.h"
|
2015-05-04 19:44:03 -04:00
|
|
|
#include "AppFrame.h"
|
2015-08-14 20:19:37 -04:00
|
|
|
#include "FrequencyDialog.h"
|
2015-08-03 01:38:38 -04:00
|
|
|
|
2015-08-01 11:03:00 -04:00
|
|
|
#include "ScopeVisualProcessor.h"
|
2015-08-03 01:38:38 -04:00
|
|
|
#include "SpectrumVisualProcessor.h"
|
2015-08-16 18:12:12 -04:00
|
|
|
#include "SpectrumVisualDataThread.h"
|
2015-10-05 02:21:08 -04:00
|
|
|
#include "SDRDevices.h"
|
2015-11-17 00:21:17 -05:00
|
|
|
#include "Modem.h"
|
2015-11-18 23:06:21 -05:00
|
|
|
|
2015-11-17 00:21:17 -05:00
|
|
|
#include "ModemFM.h"
|
|
|
|
#include "ModemFMStereo.h"
|
|
|
|
#include "ModemAM.h"
|
|
|
|
#include "ModemUSB.h"
|
|
|
|
#include "ModemLSB.h"
|
|
|
|
#include "ModemDSB.h"
|
|
|
|
#include "ModemIQ.h"
|
2014-11-23 19:39:27 -05:00
|
|
|
|
2015-11-22 19:56:25 -05:00
|
|
|
#ifdef ENABLE_DIGITAL_LAB
|
2015-11-18 23:06:21 -05:00
|
|
|
#include "ModemAPSK.h"
|
|
|
|
#include "ModemASK.h"
|
|
|
|
#include "ModemBPSK.h"
|
|
|
|
#include "ModemDPSK.h"
|
2015-12-01 22:06:50 -05:00
|
|
|
#if ENABLE_LIQUID_EXPERIMENTAL
|
2015-11-22 19:56:25 -05:00
|
|
|
#include "ModemFSK.h"
|
2015-12-01 22:06:50 -05:00
|
|
|
#endif
|
2015-11-30 21:58:54 -05:00
|
|
|
#include "ModemGMSK.h"
|
2015-11-18 23:06:21 -05:00
|
|
|
#include "ModemOOK.h"
|
|
|
|
#include "ModemPSK.h"
|
|
|
|
#include "ModemQAM.h"
|
|
|
|
#include "ModemQPSK.h"
|
|
|
|
#include "ModemSQAM.h"
|
|
|
|
#include "ModemST.h"
|
2015-11-22 19:56:25 -05:00
|
|
|
#endif
|
2015-11-18 23:06:21 -05:00
|
|
|
|
2016-01-03 19:00:26 -05:00
|
|
|
#ifdef USE_HAMLIB
|
|
|
|
class RigThread;
|
|
|
|
#endif
|
|
|
|
|
2015-07-20 18:39:45 -04:00
|
|
|
#include <wx/cmdline.h>
|
|
|
|
|
2014-12-08 02:16:06 -05:00
|
|
|
#define NUM_DEMODULATORS 1
|
2014-12-06 21:55:05 -05:00
|
|
|
|
2015-10-20 23:00:10 -04:00
|
|
|
std::string& filterChars(std::string& s, const std::string& allowed);
|
|
|
|
std::string frequencyToStr(long long freq);
|
|
|
|
long long strToFrequency(std::string freqStr);
|
|
|
|
|
2014-10-28 21:39:59 -04:00
|
|
|
class CubicSDR: public wxApp {
|
2014-10-27 20:05:40 -04:00
|
|
|
public:
|
2015-07-27 21:45:24 -04:00
|
|
|
CubicSDR();
|
2014-10-27 20:05:40 -04:00
|
|
|
|
2014-10-27 21:22:29 -04:00
|
|
|
PrimaryGLContext &GetContext(wxGLCanvas *canvas);
|
2014-10-27 20:05:40 -04:00
|
|
|
|
|
|
|
virtual bool OnInit();
|
|
|
|
virtual int OnExit();
|
|
|
|
|
2015-07-20 18:39:45 -04:00
|
|
|
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
|
|
|
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
|
|
|
|
2015-10-04 16:07:14 -04:00
|
|
|
void deviceSelector();
|
2015-10-03 21:35:11 -04:00
|
|
|
void sdrThreadNotify(SDRThread::SDRThreadState state, std::string message);
|
2015-10-04 16:07:14 -04:00
|
|
|
void sdrEnumThreadNotify(SDREnumerator::SDREnumState state, std::string message);
|
|
|
|
|
2015-01-04 17:11:20 -05:00
|
|
|
void setFrequency(long long freq);
|
|
|
|
long long getFrequency();
|
2016-01-07 00:35:02 -05:00
|
|
|
|
|
|
|
void lockFrequency(long long freq);
|
|
|
|
bool isFrequencyLocked();
|
|
|
|
void unlockFrequency();
|
2014-11-23 19:39:27 -05:00
|
|
|
|
2015-01-06 00:57:57 -05:00
|
|
|
void setOffset(long long ofs);
|
|
|
|
long long getOffset();
|
|
|
|
|
2015-01-11 17:08:16 -05:00
|
|
|
void setSampleRate(long long rate_in);
|
|
|
|
long long getSampleRate();
|
|
|
|
|
2015-01-12 00:40:43 -05:00
|
|
|
std::vector<SDRDeviceInfo *> *getDevices();
|
2015-10-04 16:07:14 -04:00
|
|
|
void setDevice(SDRDeviceInfo *dev);
|
2016-01-17 21:54:22 -05:00
|
|
|
void stopDevice();
|
2015-10-03 21:35:11 -04:00
|
|
|
SDRDeviceInfo * getDevice();
|
2015-01-12 00:40:43 -05:00
|
|
|
|
2015-08-01 11:03:00 -04:00
|
|
|
ScopeVisualProcessor *getScopeProcessor();
|
2015-08-16 18:12:12 -04:00
|
|
|
SpectrumVisualProcessor *getSpectrumProcessor();
|
|
|
|
SpectrumVisualProcessor *getDemodSpectrumProcessor();
|
2015-08-01 11:03:00 -04:00
|
|
|
|
2014-12-10 21:22:13 -05:00
|
|
|
DemodulatorThreadOutputQueue* getAudioVisualQueue();
|
2014-12-26 16:15:35 -05:00
|
|
|
DemodulatorThreadInputQueue* getIQVisualQueue();
|
2015-08-11 00:50:43 -04:00
|
|
|
DemodulatorThreadInputQueue* getWaterfallVisualQueue();
|
2015-10-17 16:17:12 -04:00
|
|
|
DemodulatorThreadInputQueue* getActiveDemodVisualQueue();
|
2014-12-10 21:22:13 -05:00
|
|
|
DemodulatorMgr &getDemodMgr();
|
2014-11-23 19:39:27 -05:00
|
|
|
|
2015-10-18 12:26:07 -04:00
|
|
|
SDRPostThread *getSDRPostThread();
|
2015-11-03 21:06:22 -05:00
|
|
|
SDRThread *getSDRThread();
|
|
|
|
|
2014-12-10 21:22:13 -05:00
|
|
|
void bindDemodulator(DemodulatorInstance *demod);
|
|
|
|
void removeDemodulator(DemodulatorInstance *demod);
|
2014-12-10 18:52:24 -05:00
|
|
|
|
2015-05-10 21:43:03 -04:00
|
|
|
void setFrequencySnap(int snap);
|
|
|
|
int getFrequencySnap();
|
|
|
|
|
2015-04-13 19:58:34 -04:00
|
|
|
AppConfig *getConfig();
|
2015-04-22 22:54:48 -04:00
|
|
|
void saveConfig();
|
2015-04-13 19:58:34 -04:00
|
|
|
|
2015-04-13 21:18:45 -04:00
|
|
|
void setPPM(int ppm_in);
|
|
|
|
int getPPM();
|
|
|
|
|
2016-02-07 19:32:05 -05:00
|
|
|
void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT, wxString initString = "");
|
2015-09-08 21:32:15 -04:00
|
|
|
AppFrame *getAppFrame();
|
|
|
|
|
2015-10-05 02:21:08 -04:00
|
|
|
bool areDevicesReady();
|
|
|
|
bool areDevicesEnumerating();
|
2016-01-13 21:59:47 -05:00
|
|
|
bool areModulesMissing();
|
2015-10-05 02:21:08 -04:00
|
|
|
std::string getNotification();
|
|
|
|
|
|
|
|
void addRemote(std::string remoteAddr);
|
|
|
|
void removeRemote(std::string remoteAddr);
|
|
|
|
|
|
|
|
void setDeviceSelectorClosed();
|
2016-01-17 21:54:22 -05:00
|
|
|
void reEnumerateDevices();
|
|
|
|
bool isDeviceSelectorOpen();
|
2015-11-12 18:38:38 -05:00
|
|
|
void closeDeviceSelector();
|
2015-10-05 02:21:08 -04:00
|
|
|
|
2015-10-27 01:56:49 -04:00
|
|
|
void setAGCMode(bool mode);
|
|
|
|
bool getAGCMode();
|
|
|
|
|
|
|
|
void setGain(std::string name, float gain_in);
|
|
|
|
float getGain(std::string name);
|
|
|
|
|
2015-11-04 02:04:52 -05:00
|
|
|
void setStreamArgs(SoapySDR::Kwargs streamArgs_in);
|
|
|
|
void setDeviceArgs(SoapySDR::Kwargs settingArgs_in);
|
2015-11-08 16:45:06 -05:00
|
|
|
|
|
|
|
bool getUseLocalMod();
|
2015-11-12 18:38:38 -05:00
|
|
|
std::string getModulePath();
|
|
|
|
|
2016-02-07 22:19:05 -05:00
|
|
|
void setActiveGainEntry(std::string gainName);
|
|
|
|
std::string getActiveGainEntry();
|
|
|
|
|
2016-02-11 01:09:15 -05:00
|
|
|
void setSoloMode(bool solo);
|
|
|
|
bool getSoloMode();
|
|
|
|
|
2016-01-03 19:00:26 -05:00
|
|
|
#ifdef USE_HAMLIB
|
|
|
|
RigThread *getRigThread();
|
|
|
|
void initRig(int rigModel, std::string rigPort, int rigSerialRate);
|
|
|
|
void stopRig();
|
|
|
|
bool rigIsActive();
|
|
|
|
#endif
|
|
|
|
|
2014-10-27 20:05:40 -04:00
|
|
|
private:
|
2016-02-07 18:01:11 -05:00
|
|
|
int FilterEvent(wxEvent& event);
|
|
|
|
|
2015-05-04 19:44:03 -04:00
|
|
|
AppFrame *appframe;
|
2015-04-13 19:58:34 -04:00
|
|
|
AppConfig config;
|
2014-10-27 20:05:40 -04:00
|
|
|
PrimaryGLContext *m_glContext;
|
2015-09-13 22:18:29 -04:00
|
|
|
std::vector<SDRDeviceInfo *> *devs;
|
2014-11-04 17:25:04 -05:00
|
|
|
|
2014-11-23 19:39:27 -05:00
|
|
|
DemodulatorMgr demodMgr;
|
|
|
|
|
2015-01-04 17:11:20 -05:00
|
|
|
long long frequency;
|
2015-01-06 00:57:57 -05:00
|
|
|
long long offset;
|
2015-05-10 21:43:03 -04:00
|
|
|
int ppm, snap;
|
2015-01-11 17:08:16 -05:00
|
|
|
long long sampleRate;
|
2015-10-27 01:56:49 -04:00
|
|
|
std::atomic_bool agcMode;
|
2014-11-23 19:39:27 -05:00
|
|
|
|
|
|
|
SDRThread *sdrThread;
|
2015-10-04 16:07:14 -04:00
|
|
|
SDREnumerator *sdrEnum;
|
2014-11-29 13:58:20 -05:00
|
|
|
SDRPostThread *sdrPostThread;
|
2015-08-16 18:12:12 -04:00
|
|
|
SpectrumVisualDataThread *spectrumVisualThread;
|
|
|
|
SpectrumVisualDataThread *demodVisualThread;
|
2014-11-30 17:11:29 -05:00
|
|
|
|
2015-07-30 20:36:06 -04:00
|
|
|
SDRThreadIQDataQueue* pipeSDRIQData;
|
|
|
|
DemodulatorThreadInputQueue* pipeIQVisualData;
|
|
|
|
DemodulatorThreadOutputQueue* pipeAudioVisualData;
|
2015-08-03 01:38:38 -04:00
|
|
|
DemodulatorThreadInputQueue* pipeDemodIQVisualData;
|
2015-08-11 00:50:43 -04:00
|
|
|
DemodulatorThreadInputQueue* pipeWaterfallIQVisualData;
|
2015-10-17 16:17:12 -04:00
|
|
|
DemodulatorThreadInputQueue* pipeActiveDemodIQVisualData;
|
2014-11-23 19:39:27 -05:00
|
|
|
|
2015-08-01 11:03:00 -04:00
|
|
|
ScopeVisualProcessor scopeProcessor;
|
2015-08-03 01:38:38 -04:00
|
|
|
|
2015-10-05 02:21:08 -04:00
|
|
|
SDRDevicesDialog *deviceSelectorDialog;
|
2015-08-16 18:12:12 -04:00
|
|
|
|
2015-11-04 02:04:52 -05:00
|
|
|
SoapySDR::Kwargs streamArgs;
|
|
|
|
SoapySDR::Kwargs settingArgs;
|
|
|
|
|
2015-10-04 16:07:14 -04:00
|
|
|
std::thread *t_SDR, *t_SDREnum, *t_PostSDR, *t_SpectrumVisual, *t_DemodVisual;
|
2015-10-05 02:21:08 -04:00
|
|
|
std::atomic_bool devicesReady;
|
2016-01-13 21:59:47 -05:00
|
|
|
std::atomic_bool devicesFailed;
|
2015-10-05 02:21:08 -04:00
|
|
|
std::atomic_bool deviceSelectorOpen;
|
2015-10-21 16:56:32 -04:00
|
|
|
std::atomic_bool sampleRateInitialized;
|
2015-11-08 16:45:06 -05:00
|
|
|
std::atomic_bool useLocalMod;
|
2015-10-05 02:21:08 -04:00
|
|
|
std::string notifyMessage;
|
2015-11-12 18:38:38 -05:00
|
|
|
std::string modulePath;
|
2015-10-05 02:21:08 -04:00
|
|
|
std::mutex notify_busy;
|
2016-01-07 00:35:02 -05:00
|
|
|
std::atomic_bool frequency_locked;
|
|
|
|
std::atomic_llong lock_freq;
|
2016-02-07 21:05:49 -05:00
|
|
|
FrequencyDialog::FrequencyDialogTarget fdlgTarget;
|
2016-02-07 22:19:05 -05:00
|
|
|
std::string activeGain;
|
2016-02-11 01:09:15 -05:00
|
|
|
std::atomic_bool soloMode;
|
2016-01-03 19:00:26 -05:00
|
|
|
#ifdef USE_HAMLIB
|
|
|
|
RigThread *rigThread;
|
|
|
|
std::thread *t_Rig;
|
|
|
|
#endif
|
2014-10-27 20:05:40 -04:00
|
|
|
};
|
|
|
|
|
2015-11-08 16:45:06 -05:00
|
|
|
static const wxCmdLineEntryDesc commandLineInfo [] =
|
|
|
|
{
|
|
|
|
{ wxCMD_LINE_SWITCH, "h", "help", "Command line parameter help", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
|
2016-01-26 19:20:14 -05:00
|
|
|
{ wxCMD_LINE_OPTION, "c", "config", "Specify a named configuration to use, i.e. '-c ham'", wxCMD_LINE_VAL_STRING, 0 },
|
|
|
|
{ wxCMD_LINE_OPTION, "m", "modpath", "Load modules from suppplied path, i.e. '-m ~/SoapyMods/'", wxCMD_LINE_VAL_STRING, 0 },
|
|
|
|
#ifdef BUNDLE_SOAPY_MODS
|
|
|
|
{ wxCMD_LINE_SWITCH, "b", "bundled", "Use bundled SoapySDR modules first instead of local.", wxCMD_LINE_VAL_NONE, 0 },
|
2015-11-08 16:45:06 -05:00
|
|
|
#endif
|
2016-01-26 19:20:14 -05:00
|
|
|
{ wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0 }
|
|
|
|
};
|
2015-07-20 18:39:45 -04:00
|
|
|
|
2014-10-27 21:22:29 -04:00
|
|
|
DECLARE_APP(CubicSDR)
|