SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
hackrfinputsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2015 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include "../hackrfinput/hackrfinputsettings.h"
19 
20 #include <QtGlobal>
21 #include "util/simpleserializer.h"
22 
23 
25 {
27 }
28 
30 {
31  m_centerFrequency = 435000 * 1000;
32  m_LOppmTenths = 0;
33  m_biasT = false;
34  m_log2Decim = 0;
36  m_lnaExt = false;
37  m_lnaGain = 16;
38  m_bandwidth = 1750000;
39  m_vgaGain = 16;
40  m_dcBlock = false;
41  m_iqCorrection = false;
42  m_devSampleRate = 2400000;
43  m_fileRecordName = "";
44  m_useReverseAPI = false;
45  m_reverseAPIAddress = "127.0.0.1";
46  m_reverseAPIPort = 8888;
48 }
49 
51 {
52  SimpleSerializer s(1);
53 
54  s.writeS32(1, m_LOppmTenths);
55  s.writeBool(3, m_biasT);
56  s.writeU32(4, m_log2Decim);
57  s.writeS32(5, m_fcPos);
58  s.writeBool(6, m_lnaExt);
59  s.writeU32(7, m_lnaGain);
60  s.writeU32(8, m_bandwidth);
61  s.writeU32(9, m_vgaGain);
62  s.writeBool(10, m_dcBlock);
69 
70  return s.final();
71 }
72 
73 bool HackRFInputSettings::deserialize(const QByteArray& data)
74 {
75  SimpleDeserializer d(data);
76 
77  if (!d.isValid())
78  {
80  return false;
81  }
82 
83  if (d.getVersion() == 1)
84  {
85  int intval;
86  uint32_t uintval;
87 
88  d.readS32(1, &m_LOppmTenths, 0);
89  d.readBool(3, &m_biasT, false);
90  d.readU32(4, &m_log2Decim, 0);
91  d.readS32(5, &intval, 0);
92  m_fcPos = (fcPos_t) intval;
93  d.readBool(6, &m_lnaExt, false);
94  d.readU32(7, &m_lnaGain, 16);
95  d.readU32(8, &m_bandwidth, 1750000);
96  d.readU32(9, &m_vgaGain, 16);
97  d.readBool(10, &m_dcBlock, false);
98  d.readBool(11, &m_iqCorrection, false);
99  d.readU64(12, &m_devSampleRate, 2400000U);
100  d.readBool(14, &m_useReverseAPI, false);
101  d.readString(15, &m_reverseAPIAddress, "127.0.0.1");
102  d.readU32(16, &uintval, 0);
103 
104  if ((uintval > 1023) && (uintval < 65535)) {
105  m_reverseAPIPort = uintval;
106  } else {
107  m_reverseAPIPort = 8888;
108  }
109 
110  d.readU32(17, &uintval, 0);
111  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
112 
113  return true;
114  }
115  else
116  {
117  resetToDefaults();
118  return false;
119  }
120 }
QByteArray serialize() const
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
bool readBool(quint32 id, bool *result, bool def=false) const
bool isValid() const
unsigned int uint32_t
Definition: rtptypes_win.h:46
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
bool readU64(quint32 id, quint64 *result, quint64 def=0) const
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
bool deserialize(const QByteArray &data)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
void writeU64(quint32 id, quint64 value)