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.
hackrfoutputsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 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 "hackrfoutputsettings.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_log2Interp = 0;
36  m_lnaExt = false;
37  m_vgaGain = 22;
38  m_bandwidth = 1750000;
39  m_devSampleRate = 2400000;
40  m_useReverseAPI = false;
41  m_reverseAPIAddress = "127.0.0.1";
42  m_reverseAPIPort = 8888;
44 }
45 
47 {
48  SimpleSerializer s(1);
49 
50  s.writeS32(1, m_LOppmTenths);
51  s.writeS32(2, (int) m_fcPos);
52  s.writeBool(3, m_biasT);
53  s.writeU32(4, m_log2Interp);
54  s.writeBool(5, m_lnaExt);
55  s.writeU32(6, m_vgaGain);
56  s.writeU32(7, m_bandwidth);
62 
63  return s.final();
64 }
65 
66 bool HackRFOutputSettings::deserialize(const QByteArray& data)
67 {
68  SimpleDeserializer d(data);
69 
70  if (!d.isValid())
71  {
73  return false;
74  }
75 
76  if (d.getVersion() == 1)
77  {
78  uint32_t uintval;
79  int32_t intval;
80 
81  d.readS32(1, &m_LOppmTenths, 0);
82  d.readS32(2, &intval, 2);
83  m_fcPos = (fcPos_t) (intval < 0 ? 0 : intval > 2 ? 2 : intval);
84  d.readBool(3, &m_biasT, false);
85  d.readU32(4, &m_log2Interp, 0);
86  d.readBool(5, &m_lnaExt, false);
87  d.readU32(6, &m_vgaGain, 30);
88  d.readU32(7, &m_bandwidth, 1750000);
89  d.readU64(8, &m_devSampleRate, 2400000);
90  d.readBool(9, &m_useReverseAPI, false);
91  d.readString(10, &m_reverseAPIAddress, "127.0.0.1");
92  d.readU32(11, &uintval, 0);
93 
94  if ((uintval > 1023) && (uintval < 65535)) {
95  m_reverseAPIPort = uintval;
96  } else {
97  m_reverseAPIPort = 8888;
98  }
99 
100  d.readU32(12, &uintval, 0);
101  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
102 
103  return true;
104  }
105  else
106  {
107  resetToDefaults();
108  return false;
109  }
110 }
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
int int32_t
Definition: rtptypes_win.h:45
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
bool deserialize(const QByteArray &data)
bool readU64(quint32 id, quint64 *result, quint64 def=0) const
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
QByteArray serialize() const
void writeU64(quint32 id, quint64 value)