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.
limesdrinputsettings.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 "util/simpleserializer.h"
19 #include "limesdrinputsettings.h"
20 
22 {
24 }
25 
27 {
28  m_centerFrequency = 435000*1000;
29  m_devSampleRate = 5000000;
30  m_log2HardDecim = 3;
31  m_dcBlock = false;
32  m_iqCorrection = false;
33  m_log2SoftDecim = 0;
34  m_lpfBW = 4.5e6f;
35  m_lpfFIREnable = false;
36  m_lpfFIRBW = 2.5e6f;
37  m_gain = 50;
38  m_ncoEnable = false;
39  m_ncoFrequency = 0;
42  m_lnaGain = 15;
43  m_tiaGain = 2;
44  m_pgaGain = 16;
45  m_extClock = false;
46  m_extClockFreq = 10000000; // 10 MHz
47  m_transverterMode = false;
49  m_fileRecordName = "";
50  m_gpioDir = 0;
51  m_gpioPins = 0;
52  m_useReverseAPI = false;
53  m_reverseAPIAddress = "127.0.0.1";
54  m_reverseAPIPort = 8888;
56 }
57 
59 {
60  SimpleSerializer s(1);
61 
64  s.writeBool(3, m_dcBlock);
67  s.writeFloat(7, m_lpfBW);
69  s.writeFloat(9, m_lpfFIRBW);
70  s.writeU32(10, m_gain);
71  s.writeBool(11, m_ncoEnable);
72  s.writeS32(12, m_ncoFrequency);
73  s.writeS32(13, (int) m_antennaPath);
74  s.writeS32(14, (int) m_gainMode);
75  s.writeU32(15, m_lnaGain);
76  s.writeU32(16, m_tiaGain);
77  s.writeU32(17, m_pgaGain);
78  s.writeBool(18, m_extClock);
79  s.writeU32(19, m_extClockFreq);
82  s.writeU32(22, m_gpioDir);
83  s.writeU32(23, m_gpioPins);
88  return s.final();
89 }
90 
91 bool LimeSDRInputSettings::deserialize(const QByteArray& data)
92 {
93  SimpleDeserializer d(data);
94 
95  if (!d.isValid())
96  {
98  return false;
99  }
100 
101  if (d.getVersion() == 1)
102  {
103  int intval;
104  uint32_t uintval;
105 
106  d.readS32(1, &m_devSampleRate, 5000000);
107  d.readU32(2, &m_log2HardDecim, 2);
108  d.readBool(3, &m_dcBlock, false);
109  d.readBool(4, &m_iqCorrection, false);
110  d.readU32(5, &m_log2SoftDecim, 0);
111  d.readFloat(7, &m_lpfBW, 1.5e6);
112  d.readBool(8, &m_lpfFIREnable, false);
113  d.readFloat(9, &m_lpfFIRBW, 1.5e6);
114  d.readU32(10, &m_gain, 50);
115  d.readBool(11, &m_ncoEnable, false);
116  d.readS32(12, &m_ncoFrequency, 0);
117  d.readS32(13, &intval, 0);
118  m_antennaPath = (PathRFE) intval;
119  d.readS32(14, &intval, 0);
120  m_gainMode = (GainMode) intval;
121  d.readU32(15, &m_lnaGain, 15);
122  d.readU32(16, &m_tiaGain, 2);
123  d.readU32(17, &m_pgaGain, 16);
124  d.readBool(18, &m_extClock, false);
125  d.readU32(19, &m_extClockFreq, 10000000);
126  d.readBool(20, &m_transverterMode, false);
128  d.readU32(22, &uintval, 0);
129  m_gpioDir = uintval & 0xFF;
130  d.readU32(23, &uintval, 0);
131  m_gpioPins = uintval & 0xFF;
132  d.readBool(24, &m_useReverseAPI, false);
133  d.readString(25, &m_reverseAPIAddress, "127.0.0.1");
134  d.readU32(26, &uintval, 0);
135 
136  if ((uintval > 1023) && (uintval < 65535)) {
137  m_reverseAPIPort = uintval;
138  } else {
139  m_reverseAPIPort = 8888;
140  }
141 
142  d.readU32(27, &uintval, 0);
143  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
144 
145  return true;
146  }
147  else
148  {
149  resetToDefaults();
150  return false;
151  }
152 
153 }
154 
155 
uint8_t m_gpioDir
GPIO pin direction LSB first; 0 input, 1 output.
bool readFloat(quint32 id, float *result, float def=0) const
uint32_t m_tiaGain
Manual TIA gain.
bool readS64(quint32 id, qint64 *result, qint64 def=0) const
bool m_lpfFIREnable
Enable LMS digital lowpass FIR filters.
bool m_extClock
True if external clock source.
void writeFloat(quint32 id, float value)
QByteArray serialize() const
uint32_t m_lnaGain
Manual LAN gain.
int m_ncoFrequency
Actual NCO frequency (the resulting frequency with mixing is displayed)
bool deserialize(const QByteArray &data)
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
uint32_t m_gain
Optimally distributed gain (dB)
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
float m_lpfFIRBW
LMS digital lowpass FIR filters bandwidth (Hz)
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
void writeS32(quint32 id, qint32 value)
bool m_ncoEnable
Enable TSP NCO and mixing.
quint32 getVersion() const
uint32_t m_pgaGain
Manual PGA gain.
float m_lpfBW
LMS amalog lowpass filter bandwidth (Hz)
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
GainMode m_gainMode
Gain mode: auto or manual.
void writeS64(quint32 id, qint64 value)
uint8_t m_gpioPins
GPIO pins to write; LSB first.
uint32_t m_extClockFreq
Frequency (Hz) of external clock source.
void writeString(quint32 id, const QString &value)
const QByteArray & final()