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.
bladerf1outputsettings.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 "bladerf1outputsettings.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_vga1 = -20;
34  m_vga2 = 20;
35  m_bandwidth = 1500000;
36  m_log2Interp = 0;
37  m_xb200 = false;
38  m_xb200Path = BLADERF_XB200_MIX;
39  m_xb200Filter = BLADERF_XB200_AUTO_1DB;
40  m_useReverseAPI = false;
41  m_reverseAPIAddress = "127.0.0.1";
42  m_reverseAPIPort = 8888;
44 }
45 
47 {
48  SimpleSerializer s(1);
49 
51  s.writeS32(2, m_vga1);
52  s.writeS32(3, m_vga2);
53  s.writeS32(4, m_bandwidth);
54  s.writeU32(5, m_log2Interp);
55  s.writeBool(6, m_xb200);
56  s.writeS32(7, (int) m_xb200Path);
57  s.writeS32(8, (int) m_xb200Filter);
62 
63  return s.final();
64 }
65 
66 bool BladeRF1OutputSettings::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  int intval;
79  uint32_t uintval;
80 
81  d.readS32(1, &m_devSampleRate);
82  d.readS32(2, &m_vga1);
83  d.readS32(3, &m_vga2);
84  d.readS32(4, &m_bandwidth);
85  d.readU32(5, &m_log2Interp);
86  d.readBool(6, &m_xb200);
87  d.readS32(7, &intval);
88  m_xb200Path = (bladerf_xb200_path) intval;
89  d.readS32(8, &intval);
90  m_xb200Filter = (bladerf_xb200_filter) intval;
91  d.readBool(9, &m_useReverseAPI, false);
92  d.readString(10, &m_reverseAPIAddress, "127.0.0.1");
93  d.readU32(11, &uintval, 0);
94 
95  if ((uintval > 1023) && (uintval < 65535)) {
96  m_reverseAPIPort = uintval;
97  } else {
98  m_reverseAPIPort = 8888;
99  }
100 
101  d.readU32(12, &uintval, 0);
102  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
103 
104  return true;
105  }
106  else
107  {
108  resetToDefaults();
109  return false;
110  }
111 }
bool deserialize(const QByteArray &data)
bladerf_xb200_path m_xb200Path
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
bladerf_xb200_filter m_xb200Filter
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()