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.
plutosdrinputsettings.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 "plutosdrinputsettings.h"
19 
20 #include <QtGlobal>
21 #include "util/simpleserializer.h"
22 
23 
25 {
27 }
28 
30 {
31  m_centerFrequency = 435000 * 1000;
33  m_LOppmTenths = 0;
34  m_log2Decim = 0;
35  m_devSampleRate = 2500 * 1000;
36  m_dcBlock = false;
37  m_iqCorrection = false;
38  m_hwBBDCBlock = true;
39  m_hwRFDCBlock = true;
40  m_hwIQCorrection = true;
41  m_lpfBW = 1500000;
42  m_lpfFIREnable = false;
43  m_lpfFIRBW = 500000U;
45  m_lpfFIRGain = 0;
46  m_gain = 40;
49  m_transverterMode = false;
51  m_fileRecordName = "";
52  m_useReverseAPI = false;
53  m_reverseAPIAddress = "127.0.0.1";
54  m_reverseAPIPort = 8888;
56 }
57 
59 {
60  SimpleSerializer s(1);
61 
62  s.writeS32(1, m_LOppmTenths);
63  s.writeS32(2, m_lpfFIRGain);
65  s.writeU32(4, m_log2Decim);
66  s.writeS32(5, m_fcPos);
67  s.writeBool(7, m_dcBlock);
69  s.writeU32(9, m_lpfBW);
71  s.writeU32(11, m_lpfFIRBW);
73  s.writeU32(13, m_gain);
74  s.writeS32(14, (int) m_antennaPath);
75  s.writeS32(15, (int) m_gainMode);
82  s.writeBool(22, m_hwBBDCBlock);
83  s.writeBool(23, m_hwRFDCBlock);
85 
86  return s.final();
87 }
88 
89 bool PlutoSDRInputSettings::deserialize(const QByteArray& data)
90 {
91  SimpleDeserializer d(data);
92 
93  if (!d.isValid())
94  {
96  return false;
97  }
98 
99  if (d.getVersion() == 1)
100  {
101  int intval;
102  uint32_t uintval;
103 
104  d.readS32(1, &m_LOppmTenths, 0);
105  d.readS32(2, &m_lpfFIRGain, 0);
106  d.readU32(3, &uintval, 0);
107  if (uintval > 2) {
108  m_lpfFIRlog2Decim = 2;
109  } else {
110  m_lpfFIRlog2Decim = uintval;
111  }
112  d.readU32(4, &m_log2Decim, 0);
113  d.readS32(5, &intval, 0);
114  if ((intval < 0) || (intval > 2)) {
116  } else {
117  m_fcPos = (fcPos_t) intval;
118  }
119  d.readBool(7, &m_dcBlock, false);
120  d.readBool(8, &m_iqCorrection, false);
121  d.readU32(9, &m_lpfBW, 1500000);
122  d.readBool(10, &m_lpfFIREnable, false);
123  d.readU32(11, &m_lpfFIRBW, 500000U);
124  d.readU64(12, &m_devSampleRate, 1536000U);
125  d.readU32(13, &m_gain, 40);
126  d.readS32(14, &intval, 0);
127  if ((intval >= 0) && (intval < (int) RFPATH_END)) {
128  m_antennaPath = (RFPath) intval;
129  } else {
131  }
132  d.readS32(15, &intval, 0);
133  if ((intval >= 0) && (intval < (int) GAIN_END)) {
134  m_gainMode = (GainMode) intval;
135  } else {
137  }
138  d.readBool(16, &m_transverterMode, false);
140  d.readBool(18, &m_useReverseAPI, false);
141  d.readString(19, &m_reverseAPIAddress, "127.0.0.1");
142  d.readU32(20, &uintval, 0);
143 
144  if ((uintval > 1023) && (uintval < 65535)) {
145  m_reverseAPIPort = uintval;
146  } else {
147  m_reverseAPIPort = 8888;
148  }
149 
150  d.readU32(21, &uintval, 0);
151  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
152 
153  d.readBool(22, &m_hwBBDCBlock, true);
154  d.readBool(23, &m_hwRFDCBlock, true);
155  d.readBool(24, &m_hwIQCorrection, true);
156 
157  return true;
158  }
159  else
160  {
161  resetToDefaults();
162  return false;
163  }
164 }
165 
167 {
168  switch(path)
169  {
170  case RFPATH_A_BAL:
171  s = "A_BALANCED";
172  break;
173  case RFPATH_B_BAL:
174  s = "B_BALANCED";
175  break;
176  case RFPATH_C_BAL:
177  s = "C_BALANCED";
178  break;
179  case RFPATH_A_NEG:
180  s = "A_N";
181  break;
182  case RFPATH_A_POS:
183  s = "A_P";
184  break;
185  case RFPATH_B_NEG:
186  s = "B_N";
187  break;
188  case RFPATH_B_POS:
189  s = "B_P";
190  break;
191  case RFPATH_C_NEG:
192  s = "C_N";
193  break;
194  case RFPATH_C_POS:
195  s = "C_P";
196  break;
197  case RFPATH_TX1MON:
198  s = "TX_MONITOR1";
199  break;
200  case RFPATH_TX2MON:
201  s = "TX_MONITOR2";
202  break;
203  case RFPATH_TX3MON:
204  s = "TX_MONITOR3";
205  break;
206  default:
207  s = "A_BALANCED";
208  break;
209  }
210 }
211 
213 {
214  switch(mode)
215  {
216  case GAIN_MANUAL:
217  s = "manual";
218  break;
219  case GAIN_AGC_SLOW:
220  s = "slow_attack";
221  break;
222  case GAIN_AGC_FAST:
223  s = "fast_attack";
224  break;
225  case GAIN_HYBRID:
226  s = "hybrid";
227  break;
228  default:
229  s = "manual";
230  break;
231  }
232 }
bool m_lpfFIREnable
enable digital lowpass FIR filter
quint32 m_lpfFIRlog2Decim
digital lowpass FIR filter log2 of decimation factor (0..2)
static void translateRFPath(RFPath path, QString &s)
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 m_hwRFDCBlock
Hardware RF DC blocking.
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
bool m_hwIQCorrection
Hardware IQ correction.
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
quint64 m_devSampleRate
Host interface sample rate.
void writeS32(quint32 id, qint32 value)
quint32 m_lpfBW
analog lowpass filter bandwidth (Hz)
quint32 m_gain
"hardware" gain
quint32 getVersion() const
static void translateGainMode(GainMode mod, QString &s)
bool deserialize(const QByteArray &data)
bool readU64(quint32 id, quint64 *result, quint64 def=0) const
void writeU32(quint32 id, quint32 value)
qint32 m_LOppmTenths
XO correction.
void writeBool(quint32 id, bool value)
void writeS64(quint32 id, qint64 value)
bool m_hwBBDCBlock
Hardware baseband DC blocking.
quint32 m_lpfFIRBW
digital lowpass FIR filter bandwidth (Hz)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
int m_lpfFIRGain
digital lowpass FIR filter gain (dB)
void writeU64(quint32 id, quint64 value)