1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

Deep redesign: revised RTLSDR source serialization. Optimisation of data to blob serialization

This commit is contained in:
f4exb 2015-08-28 03:20:00 +02:00
parent 5f0056f442
commit 77fed9a1c7
7 changed files with 94 additions and 34 deletions

View File

@ -36,7 +36,7 @@ public:
qint32 m_RxGain3; //!< Rx third stage amplifier gain qint32 m_RxGain3; //!< Rx third stage amplifier gain
}; };
static void writeSerializedData(const Data& data, QByteArray& serializedData); static const QByteArray& writeSerializedData(const Data& data);
static bool readSerializedData(const QByteArray& serializedData, Data& data); static bool readSerializedData(const QByteArray& serializedData, Data& data);
static void setDefaults(Data& data); static void setDefaults(Data& data);

View File

@ -19,8 +19,7 @@
void BladeRFSerializer::writeSerializedData(const BladeRFData& data, QByteArray& serializedData) void BladeRFSerializer::writeSerializedData(const BladeRFData& data, QByteArray& serializedData)
{ {
QByteArray sampleSourceSerialized; const QByteArray& sampleSourceSerialized = SampleSourceSerializer::writeSerializedData(data.m_data);
SampleSourceSerializer::writeSerializedData(data.m_data, sampleSourceSerialized);
SimpleSerializer s(1); SimpleSerializer s(1);

View File

@ -4,6 +4,7 @@ set(rtlsdr_SOURCES
rtlsdrgui.cpp rtlsdrgui.cpp
rtlsdrinput.cpp rtlsdrinput.cpp
rtlsdrplugin.cpp rtlsdrplugin.cpp
rtlsdrserializer.cpp
rtlsdrthread.cpp rtlsdrthread.cpp
) )
@ -11,6 +12,7 @@ set(rtlsdr_HEADERS
rtlsdrgui.h rtlsdrgui.h
rtlsdrinput.h rtlsdrinput.h
rtlsdrplugin.h rtlsdrplugin.h
rtlsdrserializer.h
rtlsdrthread.h rtlsdrthread.h
) )

View File

@ -22,7 +22,7 @@
#include "rtlsdrthread.h" #include "rtlsdrthread.h"
#include "rtlsdrgui.h" #include "rtlsdrgui.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "util/simpleserializer.h" #include "rtlsdrserializer.h"
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message) MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message) MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message)
@ -47,39 +47,34 @@ void RTLSDRInput::Settings::resetToDefaults()
QByteArray RTLSDRInput::Settings::serialize() const QByteArray RTLSDRInput::Settings::serialize() const
{ {
SimpleSerializer s(1); SampleSourceSerializer::Data data;
s.writeS32(1, m_devSampleRate);
s.writeU64(2, m_centerFrequency); data.m_lnaGain = m_gain;
s.writeS32(3, m_gain); data.m_log2Decim = m_log2Decim;
s.writeS32(4, m_loPpmCorrection); data.m_frequency = m_centerFrequency;
s.writeU32(5, m_log2Decim); data.m_rate = m_devSampleRate;
return s.final(); data.m_correction = m_loPpmCorrection;
QByteArray byteArray;
RTLSDRSerializer::writeSerializedData(data, byteArray);
return byteArray;
} }
bool RTLSDRInput::Settings::deserialize(const QByteArray& data) bool RTLSDRInput::Settings::deserialize(const QByteArray& serializedData)
{ {
SimpleDeserializer d(data); SampleSourceSerializer::Data data;
if (!d.isValid()) bool valid = RTLSDRSerializer::readSerializedData(serializedData, data);
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1) m_gain = data.m_lnaGain;
{ m_log2Decim = data.m_log2Decim;
d.readS32(1, &m_devSampleRate, 1024*1000); m_centerFrequency = data.m_frequency;
d.readU64(2, &m_centerFrequency, 435000*1000); m_devSampleRate = data.m_rate;
d.readS32(3, &m_gain, 0); m_loPpmCorrection = data.m_correction;
d.readS32(4, &m_loPpmCorrection, 0);
d.readU32(5, &m_log2Decim, 4); return valid;
return true;
}
else
{
resetToDefaults();
return false;
}
} }
RTLSDRInput::RTLSDRInput() : RTLSDRInput::RTLSDRInput() :

View File

@ -0,0 +1,32 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 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 "rtlsdrserializer.h"
void RTLSDRSerializer::writeSerializedData(const SampleSourceSerializer::Data& data, QByteArray& serializedData)
{
serializedData = SampleSourceSerializer::writeSerializedData(data);
}
bool RTLSDRSerializer::readSerializedData(const QByteArray& serializedData, SampleSourceSerializer::Data& data)
{
return SampleSourceSerializer::readSerializedData(serializedData, data);
}
void RTLSDRSerializer::setDefaults(SampleSourceSerializer::Data& data)
{
SampleSourceSerializer::setDefaults(data);
}

View File

@ -0,0 +1,32 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 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_RTLSDR_RTLSDRSERIALIZER_H_
#define PLUGINS_SAMPLESOURCE_RTLSDR_RTLSDRSERIALIZER_H_
#include "util/samplesourceserializer.h"
class RTLSDRSerializer
{
public:
SampleSourceSerializer::Data m_data;
static void writeSerializedData(const SampleSourceSerializer::Data& data, QByteArray& serializedData);
static bool readSerializedData(const QByteArray& serializedData, SampleSourceSerializer::Data& data);
static void setDefaults(SampleSourceSerializer::Data& data);
};
#endif /* PLUGINS_SAMPLESOURCE_RTLSDR_RTLSDRSERIALIZER_H_ */

View File

@ -18,7 +18,7 @@
const uint SampleSourceSerializer::m_version = 1; const uint SampleSourceSerializer::m_version = 1;
void SampleSourceSerializer::writeSerializedData(const Data& data, QByteArray& serializedData) const QByteArray& SampleSourceSerializer::writeSerializedData(const Data& data)
{ {
SimpleSerializer s(1); SimpleSerializer s(1);
@ -33,7 +33,7 @@ void SampleSourceSerializer::writeSerializedData(const Data& data, QByteArray& s
s.writeS32(9, data.m_RxGain2); s.writeS32(9, data.m_RxGain2);
s.writeS32(10, data.m_RxGain3); s.writeS32(10, data.m_RxGain3);
serializedData = s.final(); return s.final();
} }
bool SampleSourceSerializer::readSerializedData(const QByteArray& serializedData, Data& data) bool SampleSourceSerializer::readSerializedData(const QByteArray& serializedData, Data& data)