PlutoSDRInput: added rudimentary core class

This commit is contained in:
f4exb 2017-09-04 13:32:31 +02:00
parent fd851592ba
commit 75a6040f40
5 changed files with 172 additions and 4 deletions

View File

@ -2,17 +2,17 @@ project(plutosdrinput)
set(plutosdrinput_SOURCES
plutosdrinputgui.cpp
# plutosdrinput.cpp
plutosdrinput.cpp
plutosdrinputplugin.cpp
# plutosdrinputsettings.cpp
plutosdrinputsettings.cpp
# plutosdrinputthread.cpp
)
set(plutosdrinput_HEADERS
plutosdrinputgui.h
# plutosdrinput.h
plutosdrinput.h
plutosdrinputplugin.h
# plutosdrinputsettings.h
plutosdrinputsettings.h
# plutosdrinputthread.h
)

View File

@ -0,0 +1,82 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "dsp/filerecord.h"
#include "plutosdrinput.h"
MESSAGE_CLASS_DEFINITION(PlutoSDRInput::MsgFileRecord, Message)
PlutoSDRInput::PlutoSDRInput(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_fileSink(0),
m_deviceDescription("PlutoSDR"),
m_running(false)
{
char recFileNameCStr[30];
sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID());
m_fileSink = new FileRecord(std::string(recFileNameCStr));
m_deviceAPI->addSink(m_fileSink);
}
PlutoSDRInput::~PlutoSDRInput()
{
m_deviceAPI->removeSink(m_fileSink);
delete m_fileSink;
}
bool PlutoSDRInput::start()
{
}
void PlutoSDRInput::stop()
{
}
const QString& PlutoSDRInput::getDeviceDescription() const
{
return m_deviceDescription;
}
int PlutoSDRInput::getSampleRate() const
{
return (m_settings.m_devSampleRate / (1<<m_settings.m_log2Decim));
}
quint64 PlutoSDRInput::getCenterFrequency() const
{
return m_settings.m_centerFrequency;
}
bool PlutoSDRInput::handleMessage(const Message& message)
{
if (MsgFileRecord::match(message))
{
MsgFileRecord& conf = (MsgFileRecord&) message;
qDebug() << "PlutoSDRInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
if (conf.getStartStop()) {
m_fileSink->startRecording();
} else {
m_fileSink->stopRecording();
}
}
else
{
return false;
}
}

View File

@ -0,0 +1,74 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 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_PLUTOSDRINPUT_PLUTOSDRINPUT_H_
#define PLUGINS_SAMPLESOURCE_PLUTOSDRINPUT_PLUTOSDRINPUT_H_
#include <QString>
#include <dsp/devicesamplesource.h>
#include "plutosdrinputsettings.h"
class DeviceSourceAPI;
class FileRecord;
class PlutoSDRInput : public DeviceSampleSource {
public:
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)
{ }
};
PlutoSDRInput(DeviceSourceAPI *deviceAPI);
~PlutoSDRInput();
virtual bool start();
virtual void stop();
virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const;
virtual bool handleMessage(const Message& message);
private:
DeviceSourceAPI *m_deviceAPI;
FileRecord *m_fileSink;
QString m_deviceDescription;
PlutoSDRInputSettings m_settings;
bool m_running;
QMutex m_mutex;
};
#endif /* PLUGINS_SAMPLESOURCE_PLUTOSDRINPUT_PLUTOSDRINPUT_H_ */

View File

@ -29,13 +29,19 @@ void PlutoSDRInputSettings::resetToDefaults()
{
m_centerFrequency = 435000 * 1000;
m_fcPos = FC_POS_CENTER;
m_LOppmTenths = 0;
m_log2Decim = 0;
m_devSampleRate = 1536 * 1000;
}
QByteArray PlutoSDRInputSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_LOppmTenths);
s.writeU32(4, m_log2Decim);
s.writeS32(5, m_fcPos);
s.writeU64(12, m_devSampleRate);
return s.final();
}
@ -54,8 +60,11 @@ bool PlutoSDRInputSettings::deserialize(const QByteArray& data)
{
int intval;
d.readS32(1, &m_LOppmTenths, 0);
d.readU32(4, &m_log2Decim, 0);
d.readS32(5, &intval, 0);
m_fcPos = (fcPos_t) intval;
d.readU64(12, &m_devSampleRate, 1536000U);
return true;
}

View File

@ -28,6 +28,9 @@ struct PlutoSDRInputSettings {
quint64 m_centerFrequency;
fcPos_t m_fcPos;
qint32 m_LOppmTenths;
quint32 m_log2Decim;
quint64 m_devSampleRate;
PlutoSDRInputSettings();
void resetToDefaults();