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.
xtrxinputsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 Sergey Kostanbaev, Fairwaves Inc. //
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 "util/simpleserializer.h"
19 #include "xtrxinputsettings.h"
20 
22 {
24 }
25 
27 {
28  m_centerFrequency = 435000*1000;
29  m_devSampleRate = 5e6;
30  m_log2HardDecim = 1;
31  m_dcBlock = false;
32  m_iqCorrection = false;
33  m_log2SoftDecim = 0;
34  m_lpfBW = 4.5e6f;
35  m_gain = 50;
36  m_ncoEnable = false;
37  m_ncoFrequency = 0;
38  m_antennaPath = XTRX_RX_L;
40  m_lnaGain = 15;
41  m_tiaGain = 2;
42  m_pgaGain = 16;
43  m_extClock = false;
44  m_extClockFreq = 0; // Auto
45  m_pwrmode = 1;
46  m_fileRecordName = "";
47  m_useReverseAPI = false;
48  m_reverseAPIAddress = "127.0.0.1";
49  m_reverseAPIPort = 8888;
51 }
52 
53 QByteArray XTRXInputSettings::serialize() const
54 {
55  SimpleSerializer s(1);
56 
59  s.writeBool(3, m_dcBlock);
62  s.writeFloat(7, m_lpfBW);
63  s.writeU32(10, m_gain);
64  s.writeBool(11, m_ncoEnable);
65  s.writeS32(12, m_ncoFrequency);
66  s.writeS32(13, (int) m_antennaPath);
67  s.writeS32(14, (int) m_gainMode);
68  s.writeU32(15, m_lnaGain);
69  s.writeU32(16, m_tiaGain);
70  s.writeU32(17, m_pgaGain);
71  s.writeBool(18, m_extClock);
72  s.writeU32(19, m_extClockFreq);
73  s.writeU32(20, m_pwrmode);
79 
80  return s.final();
81 }
82 
83 bool XTRXInputSettings::deserialize(const QByteArray& data)
84 {
85  SimpleDeserializer d(data);
86 
87  if (!d.isValid())
88  {
90  return false;
91  }
92 
93  if (d.getVersion() == 1)
94  {
95  int intval;
96  uint32_t uintval;
97 
98  d.readDouble(1, &m_devSampleRate, 5e6);
99  d.readU32(2, &m_log2HardDecim, 2);
100  d.readBool(3, &m_dcBlock, false);
101  d.readBool(4, &m_iqCorrection, false);
102  d.readU32(5, &m_log2SoftDecim, 0);
103  d.readFloat(7, &m_lpfBW, 1.5e6);
104  d.readU32(10, &m_gain, 50);
105  d.readBool(11, &m_ncoEnable, false);
106  d.readS32(12, &m_ncoFrequency, 0);
107  d.readS32(13, &intval, 0);
108  m_antennaPath = (xtrx_antenna_t) intval;
109  d.readS32(14, &intval, 0);
110  m_gainMode = (GainMode) intval;
111  d.readU32(15, &m_lnaGain, 15);
112  d.readU32(16, &m_tiaGain, 2);
113  d.readU32(17, &m_pgaGain, 16);
114  d.readBool(18, &m_extClock, false);
115  d.readU32(19, &m_extClockFreq, 0);
116  d.readU32(20, &m_pwrmode, 2);
117  d.readString(21, &m_fileRecordName, "");
118  d.readBool(22, &m_useReverseAPI, false);
119  d.readString(23, &m_reverseAPIAddress, "127.0.0.1");
120  d.readU32(24, &uintval, 0);
121 
122  if ((uintval > 1023) && (uintval < 65535)) {
123  m_reverseAPIPort = uintval;
124  } else {
125  m_reverseAPIPort = 8888;
126  }
127 
128  d.readU32(25, &uintval, 0);
129  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
130 
131  return true;
132  }
133  else
134  {
135  resetToDefaults();
136  return false;
137  }
138 
139 }
bool m_extClock
True if external clock source.
bool m_ncoEnable
Enable TSP NCO and mixing.
void writeDouble(quint32 id, double value)
bool readFloat(quint32 id, float *result, float def=0) const
bool deserialize(const QByteArray &data)
void writeFloat(quint32 id, float value)
int m_ncoFrequency
Actual NCO frequency (the resulting frequency with mixing is displayed)
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readDouble(quint32 id, double *result, double 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
uint16_t m_reverseAPIDeviceIndex
GainMode m_gainMode
Gain mode: auto or manual.
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
float m_lpfBW
LMS analog lowpass filter bandwidth (Hz)
uint32_t m_gain
Optimally distributed gain (dB)
uint32_t m_extClockFreq
Frequency (Hz) of external clock source.
QByteArray serialize() const
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
uint32_t m_tiaGain
Manual TIA gain.
void writeU32(quint32 id, quint32 value)
uint32_t m_lnaGain
Manual LNA gain.
void writeBool(quint32 id, bool value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
xtrx_antenna_t m_antennaPath
uint32_t m_pgaGain
Manual PGA gain.