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.
devicelimesdrparam.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 <QDebug>
19 #include "devicelimesdrparam.h"
20 
21 bool DeviceLimeSDRParams::open(lms_info_str_t deviceStr)
22 {
23  getHardwareType((const char *) deviceStr);
24 
25  qDebug("DeviceLimeSDRParams::open: serial: %s type: %d", (const char *) deviceStr, (int) m_type);
26 
27  if (LMS_Open(&m_dev, deviceStr, 0) < 0)
28  {
29  qCritical() << "DeviceLimeSDRParams::open: cannot open device " << deviceStr;
30  return false;
31  }
32 
33  if (LMS_Init(m_dev) < 0)
34  {
35  qCritical() << "DeviceLimeSDRParams::open: cannot init device " << deviceStr;
36  return false;
37  }
38 
39  int n;
40 
41  if ((n = LMS_GetNumChannels(m_dev, LMS_CH_RX)) < 0)
42  {
43  qCritical() << "DeviceLimeSDRParams::open: cannot get the number of Rx channels for device " << deviceStr;
44  return false;
45  }
46  else
47  {
48  m_nbRxChannels = n;
49  qDebug() << "DeviceLimeSDRParams::open: " << n << " Rx channels for device " << deviceStr;
50  }
51 
52  if ((n = LMS_GetNumChannels(m_dev, LMS_CH_TX)) < 0)
53  {
54  qCritical() << "DeviceLimeSDRParams::open: cannot get the number of Tx channels for device " << deviceStr;
55  return false;
56  }
57  else
58  {
59  m_nbTxChannels = n;
60  qDebug() << "DeviceLimeSDRParams::open: " << n << " Tx channels for device " << deviceStr;
61  }
62 
63  if (LMS_GetLPFBWRange(m_dev, LMS_CH_RX, &m_lpfRangeRx) < 0)
64  {
65  qCritical() << "DeviceLimeSDRParams::open: cannot get the Rx LPF range for device " << deviceStr;
66  return false;
67  }
68 
69  if (LMS_GetLPFBWRange(m_dev, LMS_CH_TX, &m_lpfRangeTx) < 0)
70  {
71  qCritical() << "DeviceLimeSDRParams::open: cannot get the Tx LPF range for device " << deviceStr;
72  return false;
73  }
74 
75  if (LMS_GetLOFrequencyRange(m_dev, LMS_CH_RX, &m_loRangeRx) < 0)
76  {
77  qDebug() << "DeviceLimeSDRParams::open: cannot get the Rx LO range for device " << deviceStr;
78  return false;
79  }
80 
81  if (LMS_GetLOFrequencyRange(m_dev, LMS_CH_TX, &m_loRangeTx) < 0)
82  {
83  qCritical() << "DeviceLimeSDRParams::open: cannot get the Tx LO range for device " << deviceStr;
84  return false;
85  }
86 
87  if (LMS_GetSampleRateRange(m_dev, LMS_CH_RX, &m_srRangeRx) < 0)
88  {
89  qCritical() << "DeviceLimeSDRParams::open: cannot get the Rx sample rate range for device " << deviceStr;
90  return false;
91  }
92 
93  if (LMS_GetSampleRateRange(m_dev, LMS_CH_TX, &m_srRangeTx) < 0)
94  {
95  qCritical() << "DeviceLimeSDRParams::open: cannot get the Tx sample rate range for device " << deviceStr;
96  return false;
97  }
98 
99  return true;
100 }
101 
103 {
104  if (m_dev)
105  {
106  LMS_Close(m_dev);
107  m_dev = 0;
108  }
109 }
110 
111 void DeviceLimeSDRParams::getHardwareType(const char *device_str)
112 {
113  QString deviceStr(device_str);
114 
115  if (deviceStr.contains(QString("LimeSDR Mini"))) {
116  m_type = LimeMini;
117  } else if (deviceStr.contains(QString("LimeSDR-USB"))) {
118  m_type = LimeUSB;
119  } else if (deviceStr.contains(QString("media=SPI"))) {
120  m_type = LimeSPI;
121  } else {
123  }
124 }
125 
lms_range_t m_lpfRangeRx
Low pass filter range information (Rx side)
lms_range_t m_srRangeTx
DAC sample rate range.
uint32_t m_nbTxChannels
number of Tx channels (normally 2, we&#39;ll see if we really use it...)
lms_range_t m_srRangeRx
ADC sample rate range.
uint32_t m_nbRxChannels
number of Rx channels (normally 2, we&#39;ll see if we really use it...)
lms_device_t * m_dev
device handle
lms_range_t m_lpfRangeTx
Low pass filter range information (Tx side)
LimeType m_type
Hardware type.
void getHardwareType(const char *device_str)
bool open(lms_info_str_t deviceStr)
lms_range_t m_loRangeTx
LO range for Tx.
lms_range_t m_loRangeRx
LO range for Rx.