diff --git a/include/util/samplesourceserializer.h b/include/util/samplesourceserializer.h
index 95b3ea0ca..8d38b2efe 100644
--- a/include/util/samplesourceserializer.h
+++ b/include/util/samplesourceserializer.h
@@ -36,7 +36,7 @@ public:
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 void setDefaults(Data& data);
diff --git a/plugins/samplesource/bladerf/bladerfserializer.cpp b/plugins/samplesource/bladerf/bladerfserializer.cpp
index 56e465c89..75b036a42 100644
--- a/plugins/samplesource/bladerf/bladerfserializer.cpp
+++ b/plugins/samplesource/bladerf/bladerfserializer.cpp
@@ -19,8 +19,7 @@
void BladeRFSerializer::writeSerializedData(const BladeRFData& data, QByteArray& serializedData)
{
- QByteArray sampleSourceSerialized;
- SampleSourceSerializer::writeSerializedData(data.m_data, sampleSourceSerialized);
+ const QByteArray& sampleSourceSerialized = SampleSourceSerializer::writeSerializedData(data.m_data);
SimpleSerializer s(1);
diff --git a/plugins/samplesource/rtlsdr/CMakeLists.txt b/plugins/samplesource/rtlsdr/CMakeLists.txt
index 35c408111..02537afa0 100644
--- a/plugins/samplesource/rtlsdr/CMakeLists.txt
+++ b/plugins/samplesource/rtlsdr/CMakeLists.txt
@@ -4,6 +4,7 @@ set(rtlsdr_SOURCES
rtlsdrgui.cpp
rtlsdrinput.cpp
rtlsdrplugin.cpp
+ rtlsdrserializer.cpp
rtlsdrthread.cpp
)
@@ -11,6 +12,7 @@ set(rtlsdr_HEADERS
rtlsdrgui.h
rtlsdrinput.h
rtlsdrplugin.h
+ rtlsdrserializer.h
rtlsdrthread.h
)
diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp
index f0c2d0e79..6f768128e 100644
--- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp
+++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp
@@ -22,7 +22,7 @@
#include "rtlsdrthread.h"
#include "rtlsdrgui.h"
#include "dsp/dspcommands.h"
-#include "util/simpleserializer.h"
+#include "rtlsdrserializer.h"
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message)
@@ -47,39 +47,34 @@ void RTLSDRInput::Settings::resetToDefaults()
QByteArray RTLSDRInput::Settings::serialize() const
{
- SimpleSerializer s(1);
- s.writeS32(1, m_devSampleRate);
- s.writeU64(2, m_centerFrequency);
- s.writeS32(3, m_gain);
- s.writeS32(4, m_loPpmCorrection);
- s.writeU32(5, m_log2Decim);
- return s.final();
+ SampleSourceSerializer::Data data;
+
+ data.m_lnaGain = m_gain;
+ data.m_log2Decim = m_log2Decim;
+ data.m_frequency = m_centerFrequency;
+ data.m_rate = m_devSampleRate;
+ 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())
- {
- resetToDefaults();
- return false;
- }
+ bool valid = RTLSDRSerializer::readSerializedData(serializedData, data);
- if(d.getVersion() == 1)
- {
- d.readS32(1, &m_devSampleRate, 1024*1000);
- d.readU64(2, &m_centerFrequency, 435000*1000);
- d.readS32(3, &m_gain, 0);
- d.readS32(4, &m_loPpmCorrection, 0);
- d.readU32(5, &m_log2Decim, 4);
- return true;
- }
- else
- {
- resetToDefaults();
- return false;
- }
+ m_gain = data.m_lnaGain;
+ m_log2Decim = data.m_log2Decim;
+ m_centerFrequency = data.m_frequency;
+ m_devSampleRate = data.m_rate;
+ m_loPpmCorrection = data.m_correction;
+
+ return valid;
}
RTLSDRInput::RTLSDRInput() :
diff --git a/plugins/samplesource/rtlsdr/rtlsdrserializer.cpp b/plugins/samplesource/rtlsdr/rtlsdrserializer.cpp
new file mode 100644
index 000000000..1571d1db4
--- /dev/null
+++ b/plugins/samplesource/rtlsdr/rtlsdrserializer.cpp
@@ -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 . //
+///////////////////////////////////////////////////////////////////////////////////
+
+#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);
+}
diff --git a/plugins/samplesource/rtlsdr/rtlsdrserializer.h b/plugins/samplesource/rtlsdr/rtlsdrserializer.h
new file mode 100644
index 000000000..4cc8b826d
--- /dev/null
+++ b/plugins/samplesource/rtlsdr/rtlsdrserializer.h
@@ -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 . //
+///////////////////////////////////////////////////////////////////////////////////
+
+#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_ */
diff --git a/sdrbase/util/samplesourceserializer.cpp b/sdrbase/util/samplesourceserializer.cpp
index 551a321e6..415b290fe 100644
--- a/sdrbase/util/samplesourceserializer.cpp
+++ b/sdrbase/util/samplesourceserializer.cpp
@@ -18,7 +18,7 @@
const uint SampleSourceSerializer::m_version = 1;
-void SampleSourceSerializer::writeSerializedData(const Data& data, QByteArray& serializedData)
+const QByteArray& SampleSourceSerializer::writeSerializedData(const Data& data)
{
SimpleSerializer s(1);
@@ -33,7 +33,7 @@ void SampleSourceSerializer::writeSerializedData(const Data& data, QByteArray& s
s.writeS32(9, data.m_RxGain2);
s.writeS32(10, data.m_RxGain3);
- serializedData = s.final();
+ return s.final();
}
bool SampleSourceSerializer::readSerializedData(const QByteArray& serializedData, Data& data)