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.
bladerf1inputsettings.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 "bladerf1inputsettings.h"
19 
20 #include <QtGlobal>
21 #include "util/simpleserializer.h"
22 
23 
25 {
27 }
28 
30 {
31  m_centerFrequency = 435000*1000;
32  m_devSampleRate = 3072000;
33  m_lnaGain = 0;
34  m_vga1 = 20;
35  m_vga2 = 9;
36  m_bandwidth = 1500000;
37  m_log2Decim = 0;
39  m_xb200 = false;
40  m_xb200Path = BLADERF_XB200_MIX;
41  m_xb200Filter = BLADERF_XB200_AUTO_1DB;
42  m_dcBlock = false;
43  m_iqCorrection = false;
44  m_fileRecordName = "";
45  m_useReverseAPI = false;
46  m_reverseAPIAddress = "127.0.0.1";
47  m_reverseAPIPort = 8888;
49 }
50 
52 {
53  SimpleSerializer s(1);
54 
56  s.writeS32(2, m_lnaGain);
57  s.writeS32(3, m_vga1);
58  s.writeS32(4, m_vga2);
59  s.writeS32(5, m_bandwidth);
60  s.writeU32(6, m_log2Decim);
61  s.writeS32(7, (int) m_fcPos);
62  s.writeBool(8, m_xb200);
63  s.writeS32(9, (int) m_xb200Path);
64  s.writeS32(10, (int) m_xb200Filter);
65  s.writeBool(11, m_dcBlock);
71 
72  return s.final();
73 }
74 
75 bool BladeRF1InputSettings::deserialize(const QByteArray& data)
76 {
77  SimpleDeserializer d(data);
78 
79  if (!d.isValid())
80  {
82  return false;
83  }
84 
85  if (d.getVersion() == 1)
86  {
87  int intval;
88  uint32_t uintval;
89 
90  d.readS32(1, &m_devSampleRate, 3072000);
91  d.readS32(2, &m_lnaGain);
92  d.readS32(3, &m_vga1);
93  d.readS32(4, &m_vga2);
94  d.readS32(5, &m_bandwidth);
95  d.readU32(6, &m_log2Decim);
96  d.readS32(7, &intval);
97  m_fcPos = (fcPos_t) intval;
98  d.readBool(8, &m_xb200);
99  d.readS32(9, &intval);
100  m_xb200Path = (bladerf_xb200_path) intval;
101  d.readS32(10, &intval);
102  m_xb200Filter = (bladerf_xb200_filter) intval;
103  d.readBool(11, &m_dcBlock);
104  d.readBool(12, &m_iqCorrection);
105  d.readBool(13, &m_useReverseAPI, false);
106  d.readString(14, &m_reverseAPIAddress, "127.0.0.1");
107  d.readU32(15, &uintval, 0);
108 
109  if ((uintval > 1023) && (uintval < 65535)) {
110  m_reverseAPIPort = uintval;
111  } else {
112  m_reverseAPIPort = 8888;
113  }
114 
115  d.readU32(16, &uintval, 0);
116  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
117 
118  return true;
119  }
120  else
121  {
122  resetToDefaults();
123  return false;
124  }
125 }
bladerf_xb200_filter m_xb200Filter
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
QByteArray serialize() const
bladerf_xb200_path m_xb200Path
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)
bool deserialize(const QByteArray &data)
void writeString(quint32 id, const QString &value)
const QByteArray & final()