2018-08-19 18:38:33 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2018 Edouard Griffiths, F4EXB. //
|
|
|
|
// //
|
|
|
|
// SDRdaemon source channel (Tx) //
|
|
|
|
// //
|
|
|
|
// SDRdaemon is a detached SDR front end that handles the interface with a //
|
|
|
|
// physical device and sends or receives the I/Q samples stream to or from a //
|
|
|
|
// SDRangel instance via UDP. It is controlled via a Web REST API. //
|
|
|
|
// //
|
|
|
|
// 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 SDRDAEMON_CHANNEL_SDRDAEMONCHANNELSOURCE_H_
|
|
|
|
#define SDRDAEMON_CHANNEL_SDRDAEMONCHANNELSOURCE_H_
|
|
|
|
|
2018-08-26 11:22:22 -04:00
|
|
|
#include "cm256.h"
|
|
|
|
|
2018-08-19 18:38:33 -04:00
|
|
|
#include "dsp/basebandsamplesource.h"
|
|
|
|
#include "channel/channelsourceapi.h"
|
2018-08-23 16:45:43 -04:00
|
|
|
#include "channel/sdrdaemonchannelsourcesettings.h"
|
2018-08-26 11:22:22 -04:00
|
|
|
#include "channel/sdrdaemondataqueue.h"
|
2018-08-26 19:09:12 -04:00
|
|
|
#include "channel/sdrdaemondatablock.h"
|
2018-08-28 00:33:15 -04:00
|
|
|
#include "channel/sdrdaemondatareadqueue.h"
|
2018-08-19 18:38:33 -04:00
|
|
|
|
|
|
|
class ThreadedBasebandSampleSource;
|
|
|
|
class UpChannelizer;
|
|
|
|
class DeviceSinkAPI;
|
2018-08-26 11:22:22 -04:00
|
|
|
class SDRDaemonChannelSourceThread;
|
|
|
|
class SDRDaemonDataBlock;
|
2018-08-19 18:38:33 -04:00
|
|
|
|
|
|
|
class SDRDaemonChannelSource : public BasebandSampleSource, public ChannelSourceAPI {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-08-23 16:45:43 -04:00
|
|
|
class MsgConfigureSDRDaemonChannelSource : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const SDRDaemonChannelSourceSettings& getSettings() const { return m_settings; }
|
|
|
|
bool getForce() const { return m_force; }
|
|
|
|
|
|
|
|
static MsgConfigureSDRDaemonChannelSource* create(const SDRDaemonChannelSourceSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
return new MsgConfigureSDRDaemonChannelSource(settings, force);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SDRDaemonChannelSourceSettings m_settings;
|
|
|
|
bool m_force;
|
|
|
|
|
|
|
|
MsgConfigureSDRDaemonChannelSource(const SDRDaemonChannelSourceSettings& settings, bool force) :
|
|
|
|
Message(),
|
|
|
|
m_settings(settings),
|
|
|
|
m_force(force)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2018-08-19 18:38:33 -04:00
|
|
|
SDRDaemonChannelSource(DeviceSinkAPI *deviceAPI);
|
|
|
|
~SDRDaemonChannelSource();
|
|
|
|
virtual void destroy() { delete this; }
|
|
|
|
|
|
|
|
virtual void pull(Sample& sample);
|
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& cmd);
|
|
|
|
|
|
|
|
virtual void getIdentifier(QString& id) { id = objectName(); }
|
|
|
|
virtual void getTitle(QString& title) { title = "SDRDaemon Source"; }
|
|
|
|
virtual qint64 getCenterFrequency() const { return 0; }
|
|
|
|
|
|
|
|
virtual QByteArray serialize() const;
|
|
|
|
virtual bool deserialize(const QByteArray& data);
|
|
|
|
|
2018-08-29 19:56:53 -04:00
|
|
|
virtual int webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiReportGet(
|
|
|
|
SWGSDRangel::SWGChannelReport& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2018-08-28 17:31:07 -04:00
|
|
|
void setDataLink(const QString& dataAddress, uint16_t dataPort);
|
|
|
|
|
2018-08-19 18:38:33 -04:00
|
|
|
static const QString m_channelIdURI;
|
|
|
|
static const QString m_channelId;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DeviceSinkAPI *m_deviceAPI;
|
|
|
|
ThreadedBasebandSampleSource* m_threadedChannelizer;
|
|
|
|
UpChannelizer* m_channelizer;
|
2018-08-26 11:22:22 -04:00
|
|
|
SDRDaemonDataQueue m_dataQueue;
|
|
|
|
SDRDaemonChannelSourceThread *m_sourceThread;
|
|
|
|
CM256 m_cm256;
|
|
|
|
CM256 *m_cm256p;
|
2018-08-19 18:38:33 -04:00
|
|
|
bool m_running;
|
2018-08-26 11:22:22 -04:00
|
|
|
|
2018-08-23 16:45:43 -04:00
|
|
|
SDRDaemonChannelSourceSettings m_settings;
|
|
|
|
|
2018-08-26 19:09:12 -04:00
|
|
|
CM256::cm256_block m_cm256DescriptorBlocks[2*SDRDaemonNbOrginalBlocks]; //!< CM256 decoder descriptors (block addresses and block indexes)
|
|
|
|
SDRDaemonMetaDataFEC m_currentMeta;
|
|
|
|
|
2018-08-28 00:33:15 -04:00
|
|
|
SDRDaemonDataReadQueue m_dataReadQueue;
|
|
|
|
|
2018-08-29 19:56:53 -04:00
|
|
|
uint32_t m_nbCorrectableErrors; //!< count of correctable errors in number of blocks
|
|
|
|
uint32_t m_nbUncorrectableErrors; //!< count of uncorrectable errors in number of blocks
|
|
|
|
|
2018-08-23 16:45:43 -04:00
|
|
|
void applySettings(const SDRDaemonChannelSourceSettings& settings, bool force = false);
|
2018-08-28 00:33:15 -04:00
|
|
|
void handleDataBlock(SDRDaemonDataBlock *dataBlock);
|
2018-08-26 19:09:12 -04:00
|
|
|
void printMeta(const QString& header, SDRDaemonMetaDataFEC *metaData);
|
2018-08-29 02:48:57 -04:00
|
|
|
uint32_t calculateDataReadQueueSize(int sampleRate);
|
2018-08-29 19:56:53 -04:00
|
|
|
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const SDRDaemonChannelSourceSettings& settings);
|
|
|
|
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
|
2018-08-26 11:22:22 -04:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleData();
|
2018-08-19 18:38:33 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SDRDAEMON_CHANNEL_SDRDAEMONCHANNELSOURCE_H_ */
|