2018-10-29 11:39:25 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_
|
|
|
|
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2018-10-29 20:58:39 -04:00
|
|
|
#include "soapysdr/devicesoapysdrshared.h"
|
2018-10-29 11:39:25 -04:00
|
|
|
#include "dsp/devicesamplesource.h"
|
|
|
|
|
2018-10-31 21:32:26 -04:00
|
|
|
#include "soapysdrinputsettings.h"
|
|
|
|
|
2018-10-29 11:39:25 -04:00
|
|
|
class DeviceSourceAPI;
|
2018-10-30 15:31:16 -04:00
|
|
|
class SoapySDRInputThread;
|
2018-11-01 21:33:04 -04:00
|
|
|
class FileRecord;
|
|
|
|
|
|
|
|
namespace SoapySDR
|
|
|
|
{
|
|
|
|
class Device;
|
|
|
|
}
|
2018-10-29 11:39:25 -04:00
|
|
|
|
|
|
|
class SoapySDRInput : public DeviceSampleSource
|
|
|
|
{
|
|
|
|
public:
|
2018-11-01 06:43:42 -04:00
|
|
|
class MsgConfigureSoapySDRInput : public Message {
|
2018-10-31 21:32:26 -04:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const SoapySDRInputSettings& getSettings() const { return m_settings; }
|
|
|
|
bool getForce() const { return m_force; }
|
|
|
|
|
2018-11-01 06:43:42 -04:00
|
|
|
static MsgConfigureSoapySDRInput* create(const SoapySDRInputSettings& settings, bool force)
|
2018-10-31 21:32:26 -04:00
|
|
|
{
|
2018-11-01 06:43:42 -04:00
|
|
|
return new MsgConfigureSoapySDRInput(settings, force);
|
2018-10-31 21:32:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SoapySDRInputSettings m_settings;
|
|
|
|
bool m_force;
|
|
|
|
|
2018-11-01 06:43:42 -04:00
|
|
|
MsgConfigureSoapySDRInput(const SoapySDRInputSettings& settings, bool force) :
|
2018-10-31 21:32:26 -04:00
|
|
|
Message(),
|
|
|
|
m_settings(settings),
|
|
|
|
m_force(force)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2018-11-01 06:43:42 -04:00
|
|
|
class MsgFileRecord : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getStartStop() const { return m_startStop; }
|
|
|
|
|
|
|
|
static MsgFileRecord* create(bool startStop) {
|
|
|
|
return new MsgFileRecord(startStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_startStop;
|
|
|
|
|
|
|
|
MsgFileRecord(bool startStop) :
|
|
|
|
Message(),
|
|
|
|
m_startStop(startStop)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgStartStop : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getStartStop() const { return m_startStop; }
|
|
|
|
|
|
|
|
static MsgStartStop* create(bool startStop) {
|
|
|
|
return new MsgStartStop(startStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_startStop;
|
|
|
|
|
|
|
|
MsgStartStop(bool startStop) :
|
|
|
|
Message(),
|
|
|
|
m_startStop(startStop)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2018-10-29 11:39:25 -04:00
|
|
|
SoapySDRInput(DeviceSourceAPI *deviceAPI);
|
|
|
|
virtual ~SoapySDRInput();
|
|
|
|
virtual void destroy();
|
|
|
|
|
|
|
|
virtual void init();
|
|
|
|
virtual bool start();
|
|
|
|
virtual void stop();
|
2018-10-30 15:31:16 -04:00
|
|
|
SoapySDRInputThread *getThread() { return m_thread; }
|
|
|
|
void setThread(SoapySDRInputThread *thread) { m_thread = thread; }
|
2018-10-29 11:39:25 -04:00
|
|
|
|
|
|
|
virtual QByteArray serialize() const;
|
|
|
|
virtual bool deserialize(const QByteArray& data);
|
|
|
|
|
|
|
|
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
|
|
|
virtual const QString& getDeviceDescription() const;
|
|
|
|
virtual int getSampleRate() const;
|
|
|
|
virtual quint64 getCenterFrequency() const;
|
|
|
|
virtual void setCenterFrequency(qint64 centerFrequency);
|
|
|
|
|
|
|
|
virtual bool handleMessage(const Message& message);
|
|
|
|
|
2018-10-31 21:32:26 -04:00
|
|
|
void getFrequencyRange(uint64_t& min, uint64_t& max);
|
2018-11-06 19:33:17 -05:00
|
|
|
void getGlobalGainRange(int& min, int& max);
|
2018-11-04 17:54:16 -05:00
|
|
|
const std::vector<std::string>& getAntennas();
|
2018-11-04 20:19:40 -05:00
|
|
|
const SoapySDR::RangeList& getRateRanges();
|
|
|
|
const SoapySDR::RangeList& getBandwidthRanges();
|
2018-11-04 17:54:16 -05:00
|
|
|
int getAntennaIndex(const std::string& antenna);
|
2018-11-05 11:27:32 -05:00
|
|
|
const std::vector<DeviceSoapySDRParams::FrequencySetting>& getTunableElements();
|
2018-11-06 19:33:17 -05:00
|
|
|
const std::vector<DeviceSoapySDRParams::GainSetting>& getIndividualGainsRanges();
|
2018-10-31 21:32:26 -04:00
|
|
|
|
2018-10-29 11:39:25 -04:00
|
|
|
private:
|
2018-10-29 20:58:39 -04:00
|
|
|
DeviceSourceAPI *m_deviceAPI;
|
2018-11-01 21:33:04 -04:00
|
|
|
QMutex m_mutex;
|
|
|
|
SoapySDRInputSettings m_settings;
|
2018-10-29 11:39:25 -04:00
|
|
|
QString m_deviceDescription;
|
2018-10-29 20:58:39 -04:00
|
|
|
bool m_running;
|
2018-11-01 21:33:04 -04:00
|
|
|
SoapySDRInputThread *m_thread;
|
|
|
|
DeviceSoapySDRShared m_deviceShared;
|
|
|
|
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
2018-10-29 20:58:39 -04:00
|
|
|
|
|
|
|
bool openDevice();
|
|
|
|
void closeDevice();
|
2018-11-01 21:33:04 -04:00
|
|
|
SoapySDRInputThread *findThread();
|
2018-10-30 15:31:16 -04:00
|
|
|
void moveThreadToBuddy();
|
2018-11-01 21:33:04 -04:00
|
|
|
bool applySettings(const SoapySDRInputSettings& settings, bool force = false);
|
|
|
|
bool setDeviceCenterFrequency(SoapySDR::Device *dev, int requestedChannel, quint64 freq_hz, int loPpmTenths);
|
2018-10-29 11:39:25 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_ */
|