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.
bladerf2inputsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 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 "bladerf2inputsettings.h"
19 
20 #include "util/simpleserializer.h"
21 
23 {
25 }
26 
28 {
29  m_centerFrequency = 435000*1000;
30  m_LOppmTenths = 0;
31  m_devSampleRate = 3072000;
32  m_bandwidth = 1500000;
33  m_gainMode = 0;
34  m_globalGain = 0;
35  m_biasTee = false;
36  m_log2Decim = 0;
38  m_dcBlock = false;
39  m_iqCorrection = false;
40  m_transverterMode = false;
42  m_fileRecordName = "";
43  m_useReverseAPI = false;
44  m_reverseAPIAddress = "127.0.0.1";
45  m_reverseAPIPort = 8888;
47 }
48 
50 {
51  SimpleSerializer s(1);
52 
54  s.writeS32(2, m_bandwidth);
55  s.writeS32(3, m_gainMode);
56  s.writeS32(4, m_globalGain);
57  s.writeBool(5, m_biasTee);
58  s.writeU32(6, m_log2Decim);
59  s.writeS32(7, (int) m_fcPos);
60  s.writeBool(8, m_dcBlock);
62  s.writeS32(10, m_LOppmTenths);
69 
70  return s.final();
71 }
72 
73 bool BladeRF2InputSettings::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_devSampleRate, 3072000);
89  d.readS32(2, &m_bandwidth);
90  d.readS32(3, &m_gainMode);
91  d.readS32(4, &m_globalGain);
92  d.readBool(5, &m_biasTee);
93  d.readU32(6, &m_log2Decim);
94  d.readS32(7, &intval);
95  m_fcPos = (fcPos_t) intval;
96  d.readBool(8, &m_dcBlock);
97  d.readBool(9, &m_iqCorrection);
98  d.readS32(10, &m_LOppmTenths);
99  d.readBool(11, &m_transverterMode, false);
101  d.readBool(13, &m_useReverseAPI, false);
102  d.readString(14, &m_reverseAPIAddress, "127.0.0.1");
103  d.readU32(15, &uintval, 0);
104 
105  if ((uintval > 1023) && (uintval < 65535)) {
106  m_reverseAPIPort = uintval;
107  } else {
108  m_reverseAPIPort = 8888;
109  }
110 
111  d.readU32(16, &uintval, 0);
112  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
113 
114  return true;
115  }
116  else
117  {
118  resetToDefaults();
119  return false;
120  }
121 }
122 
123 
QByteArray serialize() const
bool readS64(quint32 id, qint64 *result, qint64 def=0) 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
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
void writeS64(quint32 id, qint64 value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
bool deserialize(const QByteArray &data)