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.
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
AirspyThread Class Reference

#include <airspythread.h>

Inherits QThread.

+ Collaboration diagram for AirspyThread:

Public Member Functions

 AirspyThread (struct airspy_device *dev, SampleSinkFifo *sampleFifo, QObject *parent=NULL)
 
 ~AirspyThread ()
 
void startWork ()
 
void stopWork ()
 
void setSamplerate (uint32_t samplerate)
 
void setLog2Decimation (unsigned int log2_decim)
 
void setFcPos (int fcPos)
 

Private Member Functions

void run ()
 
void callback (const qint16 *buf, qint32 len)
 

Static Private Member Functions

static int rx_callback (airspy_transfer_t *transfer)
 

Private Attributes

QMutex m_startWaitMutex
 
QWaitCondition m_startWaiter
 
bool m_running
 
struct airspy_device * m_dev
 
qint16 m_buf [2 *AIRSPY_BLOCKSIZE]
 
SampleVector m_convertBuffer
 
SampleSinkFifom_sampleFifo
 
int m_samplerate
 
unsigned int m_log2Decim
 
int m_fcPos
 
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 12 > m_decimators
 

Static Private Attributes

static AirspyThreadm_this = 0
 

Detailed Description

Definition at line 31 of file airspythread.h.

Constructor & Destructor Documentation

◆ AirspyThread()

AirspyThread::AirspyThread ( struct airspy_device *  dev,
SampleSinkFifo sampleFifo,
QObject *  parent = NULL 
)

Definition at line 28 of file airspythread.cpp.

References AIRSPY_BLOCKSIZE, m_buf, and m_this.

28  :
29  QThread(parent),
30  m_running(false),
31  m_dev(dev),
33  m_sampleFifo(sampleFifo),
34  m_samplerate(10),
35  m_log2Decim(0),
36  m_fcPos(0)
37 {
38  m_this = this;
39  std::fill(m_buf, m_buf + 2*AIRSPY_BLOCKSIZE, 0);
40 }
#define AIRSPY_BLOCKSIZE
Definition: airspythread.h:29
qint16 m_buf[2 *AIRSPY_BLOCKSIZE]
Definition: airspythread.h:50
unsigned int m_log2Decim
Definition: airspythread.h:55
static AirspyThread * m_this
Definition: airspythread.h:57
struct airspy_device * m_dev
Definition: airspythread.h:49
SampleSinkFifo * m_sampleFifo
Definition: airspythread.h:52
SampleVector m_convertBuffer
Definition: airspythread.h:51

◆ ~AirspyThread()

AirspyThread::~AirspyThread ( )

Definition at line 42 of file airspythread.cpp.

References m_this, and stopWork().

43 {
44  stopWork();
45  m_this = 0;
46 }
static AirspyThread * m_this
Definition: airspythread.h:57
+ Here is the call graph for this function:

Member Function Documentation

◆ callback()

void AirspyThread::callback ( const qint16 *  buf,
qint32  len 
)
private

Definition at line 115 of file airspythread.cpp.

References Decimators< StorageType, T, SdrBits, InputBits >::decimate1(), Decimators< StorageType, T, SdrBits, InputBits >::decimate16_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate16_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate16_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate2_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate2_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate2_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate32_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate32_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate32_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate4_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate4_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate4_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate64_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate64_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate64_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate8_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate8_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate8_sup(), m_convertBuffer, m_decimators, m_fcPos, m_log2Decim, m_sampleFifo, and SampleSinkFifo::write().

Referenced by rx_callback().

116 {
117  SampleVector::iterator it = m_convertBuffer.begin();
118 
119  if (m_log2Decim == 0)
120  {
121  m_decimators.decimate1(&it, buf, len);
122  }
123  else
124  {
125  if (m_fcPos == 0) // Infra
126  {
127  switch (m_log2Decim)
128  {
129  case 1:
130  m_decimators.decimate2_inf(&it, buf, len);
131  break;
132  case 2:
133  m_decimators.decimate4_inf(&it, buf, len);
134  break;
135  case 3:
136  m_decimators.decimate8_inf(&it, buf, len);
137  break;
138  case 4:
139  m_decimators.decimate16_inf(&it, buf, len);
140  break;
141  case 5:
142  m_decimators.decimate32_inf(&it, buf, len);
143  break;
144  case 6:
145  m_decimators.decimate64_inf(&it, buf, len);
146  break;
147  default:
148  break;
149  }
150  }
151  else if (m_fcPos == 1) // Supra
152  {
153  switch (m_log2Decim)
154  {
155  case 1:
156  m_decimators.decimate2_sup(&it, buf, len);
157  break;
158  case 2:
159  m_decimators.decimate4_sup(&it, buf, len);
160  break;
161  case 3:
162  m_decimators.decimate8_sup(&it, buf, len);
163  break;
164  case 4:
165  m_decimators.decimate16_sup(&it, buf, len);
166  break;
167  case 5:
168  m_decimators.decimate32_sup(&it, buf, len);
169  break;
170  case 6:
171  m_decimators.decimate64_sup(&it, buf, len);
172  break;
173  default:
174  break;
175  }
176  }
177  else if (m_fcPos == 2) // Center
178  {
179  switch (m_log2Decim)
180  {
181  case 1:
182  m_decimators.decimate2_cen(&it, buf, len);
183  break;
184  case 2:
185  m_decimators.decimate4_cen(&it, buf, len);
186  break;
187  case 3:
188  m_decimators.decimate8_cen(&it, buf, len);
189  break;
190  case 4:
191  m_decimators.decimate16_cen(&it, buf, len);
192  break;
193  case 5:
194  m_decimators.decimate32_cen(&it, buf, len);
195  break;
196  case 6:
197  m_decimators.decimate64_cen(&it, buf, len);
198  break;
199  default:
200  break;
201  }
202  }
203  }
204 
205  m_sampleFifo->write(m_convertBuffer.begin(), it);
206 }
void decimate2_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:498
void decimate64_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:2975
unsigned int m_log2Decim
Definition: airspythread.h:55
void decimate64_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:3040
void decimate2_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:526
void decimate2_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:554
uint write(const quint8 *data, uint count)
void decimate8_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:941
void decimate64_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:2418
void decimate32_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1592
void decimate32_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1902
void decimate4_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:682
void decimate8_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1057
void decimate8_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:825
void decimate16_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1300
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 12 > m_decimators
Definition: airspythread.h:59
void decimate4_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:782
SampleSinkFifo * m_sampleFifo
Definition: airspythread.h:52
SampleVector m_convertBuffer
Definition: airspythread.h:51
void decimate4_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:582
void decimate16_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1117
void decimate16_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1483
void decimate32_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:2212
void decimate1(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:462
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

void AirspyThread::run ( )
private

Definition at line 79 of file airspythread.cpp.

References m_dev, m_running, m_startWaiter, and rx_callback().

80 {
81  airspy_error rc;
82 
83  m_running = true;
84  m_startWaiter.wakeAll();
85 
86  rc = (airspy_error) airspy_start_rx(m_dev, rx_callback, NULL);
87 
88  if (rc != AIRSPY_SUCCESS)
89  {
90  qCritical("AirspyThread::run: failed to start Airspy Rx: %s", airspy_error_name(rc));
91  }
92  else
93  {
94  while ((m_running) && (airspy_is_streaming(m_dev) == AIRSPY_TRUE))
95  {
96  sleep(1);
97  }
98  }
99 
100  rc = (airspy_error) airspy_stop_rx(m_dev);
101 
102  if (rc == AIRSPY_SUCCESS)
103  {
104  qDebug("AirspyThread::run: stopped Airspy Rx");
105  }
106  else
107  {
108  qDebug("AirspyThread::run: failed to stop Airspy Rx: %s", airspy_error_name(rc));
109  }
110 
111  m_running = false;
112 }
static int rx_callback(airspy_transfer_t *transfer)
struct airspy_device * m_dev
Definition: airspythread.h:49
QWaitCondition m_startWaiter
Definition: airspythread.h:46
+ Here is the call graph for this function:

◆ rx_callback()

int AirspyThread::rx_callback ( airspy_transfer_t *  transfer)
staticprivate

Definition at line 209 of file airspythread.cpp.

References callback(), and m_this.

Referenced by run().

210 {
211  qint32 bytes_to_write = transfer->sample_count * sizeof(qint16);
212  m_this->callback((qint16 *) transfer->samples, bytes_to_write);
213  return 0;
214 }
static AirspyThread * m_this
Definition: airspythread.h:57
void callback(const qint16 *buf, qint32 len)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFcPos()

void AirspyThread::setFcPos ( int  fcPos)

Definition at line 74 of file airspythread.cpp.

References m_fcPos.

Referenced by AirspyInput::applySettings(), and AirspyInput::start().

75 {
76  m_fcPos = fcPos;
77 }
+ Here is the caller graph for this function:

◆ setLog2Decimation()

void AirspyThread::setLog2Decimation ( unsigned int  log2_decim)

Definition at line 69 of file airspythread.cpp.

References m_log2Decim.

Referenced by AirspyInput::applySettings(), and AirspyInput::start().

70 {
71  m_log2Decim = log2_decim;
72 }
unsigned int m_log2Decim
Definition: airspythread.h:55
+ Here is the caller graph for this function:

◆ setSamplerate()

void AirspyThread::setSamplerate ( uint32_t  samplerate)

Definition at line 64 of file airspythread.cpp.

References m_samplerate.

Referenced by AirspyInput::applySettings(), and AirspyInput::start().

65 {
66  m_samplerate = samplerate;
67 }
+ Here is the caller graph for this function:

◆ startWork()

void AirspyThread::startWork ( )

Definition at line 48 of file airspythread.cpp.

References m_running, m_startWaiter, and m_startWaitMutex.

Referenced by AirspyInput::start().

49 {
50  m_startWaitMutex.lock();
51  start();
52  while(!m_running)
53  m_startWaiter.wait(&m_startWaitMutex, 100);
54  m_startWaitMutex.unlock();
55 }
QMutex m_startWaitMutex
Definition: airspythread.h:45
QWaitCondition m_startWaiter
Definition: airspythread.h:46
+ Here is the caller graph for this function:

◆ stopWork()

void AirspyThread::stopWork ( )

Definition at line 57 of file airspythread.cpp.

References m_running.

Referenced by AirspyInput::stop(), and ~AirspyThread().

58 {
59  qDebug("AirspyThread::stopWork");
60  m_running = false;
61  wait();
62 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_buf

qint16 AirspyThread::m_buf[2 *AIRSPY_BLOCKSIZE]
private

Definition at line 50 of file airspythread.h.

Referenced by AirspyThread().

◆ m_convertBuffer

SampleVector AirspyThread::m_convertBuffer
private

Definition at line 51 of file airspythread.h.

Referenced by callback().

◆ m_decimators

Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> AirspyThread::m_decimators
private

Definition at line 59 of file airspythread.h.

Referenced by callback().

◆ m_dev

struct airspy_device* AirspyThread::m_dev
private

Definition at line 49 of file airspythread.h.

Referenced by run().

◆ m_fcPos

int AirspyThread::m_fcPos
private

Definition at line 56 of file airspythread.h.

Referenced by callback(), and setFcPos().

◆ m_log2Decim

unsigned int AirspyThread::m_log2Decim
private

Definition at line 55 of file airspythread.h.

Referenced by callback(), and setLog2Decimation().

◆ m_running

bool AirspyThread::m_running
private

Definition at line 47 of file airspythread.h.

Referenced by run(), startWork(), and stopWork().

◆ m_sampleFifo

SampleSinkFifo* AirspyThread::m_sampleFifo
private

Definition at line 52 of file airspythread.h.

Referenced by callback().

◆ m_samplerate

int AirspyThread::m_samplerate
private

Definition at line 54 of file airspythread.h.

Referenced by setSamplerate().

◆ m_startWaiter

QWaitCondition AirspyThread::m_startWaiter
private

Definition at line 46 of file airspythread.h.

Referenced by run(), and startWork().

◆ m_startWaitMutex

QMutex AirspyThread::m_startWaitMutex
private

Definition at line 45 of file airspythread.h.

Referenced by startWork().

◆ m_this

AirspyThread * AirspyThread::m_this = 0
staticprivate

Definition at line 57 of file airspythread.h.

Referenced by AirspyThread(), rx_callback(), and ~AirspyThread().


The documentation for this class was generated from the following files: