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.
xtrxoutputsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2019 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 "../xtrxoutput/xtrxoutputsettings.h"
19 
20 #include "util/simpleserializer.h"
21 
23 {
25 }
26 
28 {
29  m_centerFrequency = 435000*1000;
30  m_devSampleRate = 5e6;
31  m_log2HardInterp = 2;
32  m_log2SoftInterp = 4;
33  m_lpfBW = 4.5e6f;
34  m_gain = 20;
35  m_ncoEnable = true;
36  m_ncoFrequency = 500000;
37  m_antennaPath = XTRX_TX_W;
38  m_extClock = false;
39  m_extClockFreq = 0; // Auto
40  m_pwrmode = 1;
41  m_useReverseAPI = false;
42  m_reverseAPIAddress = "127.0.0.1";
43  m_reverseAPIPort = 8888;
45 }
46 
48 {
49  SimpleSerializer s(1);
50 
54  s.writeFloat(4, m_lpfBW);
55  s.writeU32(5, m_gain);
56  s.writeBool(6, m_ncoEnable);
58  s.writeS32(8, (int) m_antennaPath);
59  s.writeBool(9, m_extClock);
60  s.writeU32(10, m_extClockFreq);
61  s.writeU32(11, m_pwrmode);
66 
67  return s.final();
68 }
69 
70 bool XTRXOutputSettings::deserialize(const QByteArray& data)
71 {
72  SimpleDeserializer d(data);
73 
74  if (!d.isValid())
75  {
77  return false;
78  }
79 
80  if (d.getVersion() == 1)
81  {
82  int intval;
83  uint32_t uintval;
84 
85  d.readDouble(1, &m_devSampleRate, 5e6);
86  d.readU32(2, &m_log2HardInterp, 2);
87  d.readU32(3, &m_log2SoftInterp, 0);
88  d.readFloat(4, &m_lpfBW, 1.5e6);
89  d.readU32(5, &m_gain, 20);
90  d.readBool(6, &m_ncoEnable, true);
91  d.readS32(7, &m_ncoFrequency, 500000);
92  d.readS32(8, &intval, 0);
93  m_antennaPath = (xtrx_antenna_t) intval;
94  d.readBool(9, &m_extClock, false);
95  d.readU32(10, &m_extClockFreq, 0);
96  d.readU32(11, &m_pwrmode, 2);
97  d.readBool(12, &m_useReverseAPI, false);
98  d.readString(13, &m_reverseAPIAddress, "127.0.0.1");
99  d.readU32(14, &uintval, 0);
100 
101  if ((uintval > 1023) && (uintval < 65535)) {
102  m_reverseAPIPort = uintval;
103  } else {
104  m_reverseAPIPort = 8888;
105  }
106 
107  d.readU32(15, &uintval, 0);
108  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
109 
110  return true;
111  }
112  else
113  {
114  resetToDefaults();
115  return false;
116  }
117 
118 }
void writeDouble(quint32 id, double value)
bool readFloat(quint32 id, float *result, float def=0) const
bool m_extClock
True if external clock source.
uint32_t m_gain
Optimally distributed gain (dB)
int m_ncoFrequency
Actual NCO frequency (the resulting frequency with mixing is displayed)
void writeFloat(quint32 id, float value)
xtrx_antenna_t m_antennaPath
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool m_ncoEnable
Enable TSP NCO and mixing.
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
QByteArray serialize() const
uint16_t m_reverseAPIDeviceIndex
uint32_t m_extClockFreq
Frequency (Hz) of external clock source.
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
void writeS32(quint32 id, qint32 value)
quint32 getVersion() const
bool deserialize(const QByteArray &data)
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
float m_lpfBW
LMS analog lowpass filter bandwidth (Hz)
void writeString(quint32 id, const QString &value)
const QByteArray & final()