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 | Private Attributes | List of all members
Bladerf1InputThread Class Reference

#include <bladerf1inputthread.h>

Inherits QThread.

+ Collaboration diagram for Bladerf1InputThread:

Public Member Functions

 Bladerf1InputThread (struct bladerf *dev, SampleSinkFifo *sampleFifo, QObject *parent=NULL)
 
 ~Bladerf1InputThread ()
 
void startWork ()
 
void stopWork ()
 
void setLog2Decimation (unsigned int log2_decim)
 
void setFcPos (int fcPos)
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 30 of file bladerf1inputthread.h.

Constructor & Destructor Documentation

◆ Bladerf1InputThread()

Bladerf1InputThread::Bladerf1InputThread ( struct bladerf *  dev,
SampleSinkFifo sampleFifo,
QObject *  parent = NULL 
)

Definition at line 27 of file bladerf1inputthread.cpp.

References BLADERF_BLOCKSIZE, and m_buf.

27  :
28  QThread(parent),
29  m_running(false),
30  m_dev(dev),
32  m_sampleFifo(sampleFifo),
33  m_log2Decim(0),
34  m_fcPos(0)
35 {
36  std::fill(m_buf, m_buf + 2*BLADERF_BLOCKSIZE, 0);
37 }
SampleSinkFifo * m_sampleFifo
struct bladerf * m_dev
#define BLADERF_BLOCKSIZE
qint16 m_buf[2 *BLADERF_BLOCKSIZE]
SampleVector m_convertBuffer

◆ ~Bladerf1InputThread()

Bladerf1InputThread::~Bladerf1InputThread ( )

Definition at line 39 of file bladerf1inputthread.cpp.

References stopWork().

40 {
41  stopWork();
42 }
+ Here is the call graph for this function:

Member Function Documentation

◆ callback()

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

Definition at line 89 of file bladerf1inputthread.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 run().

90 {
91  SampleVector::iterator it = m_convertBuffer.begin();
92 
93  if (m_log2Decim == 0)
94  {
95  m_decimators.decimate1(&it, buf, len);
96  }
97  else
98  {
99  if (m_fcPos == 0) // Infra
100  {
101  switch (m_log2Decim)
102  {
103  case 1:
104  m_decimators.decimate2_inf(&it, buf, len);
105  break;
106  case 2:
107  m_decimators.decimate4_inf(&it, buf, len);
108  break;
109  case 3:
110  m_decimators.decimate8_inf(&it, buf, len);
111  break;
112  case 4:
113  m_decimators.decimate16_inf(&it, buf, len);
114  break;
115  case 5:
116  m_decimators.decimate32_inf(&it, buf, len);
117  break;
118  case 6:
119  m_decimators.decimate64_inf(&it, buf, len);
120  break;
121  default:
122  break;
123  }
124  }
125  else if (m_fcPos == 1) // Supra
126  {
127  switch (m_log2Decim)
128  {
129  case 1:
130  m_decimators.decimate2_sup(&it, buf, len);
131  break;
132  case 2:
133  m_decimators.decimate4_sup(&it, buf, len);
134  break;
135  case 3:
136  m_decimators.decimate8_sup(&it, buf, len);
137  break;
138  case 4:
139  m_decimators.decimate16_sup(&it, buf, len);
140  break;
141  case 5:
142  m_decimators.decimate32_sup(&it, buf, len);
143  break;
144  case 6:
145  m_decimators.decimate64_sup(&it, buf, len);
146  break;
147  default:
148  break;
149  }
150  }
151  else if (m_fcPos == 2) // Center
152  {
153  switch (m_log2Decim)
154  {
155  case 1:
156  m_decimators.decimate2_cen(&it, buf, len);
157  break;
158  case 2:
159  m_decimators.decimate4_cen(&it, buf, len);
160  break;
161  case 3:
162  m_decimators.decimate8_cen(&it, buf, len);
163  break;
164  case 4:
165  m_decimators.decimate16_cen(&it, buf, len);
166  break;
167  case 5:
168  m_decimators.decimate32_cen(&it, buf, len);
169  break;
170  case 6:
171  m_decimators.decimate64_cen(&it, buf, len);
172  break;
173  default:
174  break;
175  }
176  }
177  }
178 
179 
180  m_sampleFifo->write(m_convertBuffer.begin(), it);
181 }
SampleSinkFifo * m_sampleFifo
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
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
void decimate4_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:782
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 12 > m_decimators
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
SampleVector m_convertBuffer
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 Bladerf1InputThread::run ( )
private

Definition at line 69 of file bladerf1inputthread.cpp.

References BLADERF_BLOCKSIZE, callback(), m_buf, m_dev, m_running, and m_startWaiter.

70 {
71  int res;
72 
73  m_running = true;
74  m_startWaiter.wakeAll();
75 
76  while(m_running) {
77  if((res = bladerf_sync_rx(m_dev, m_buf, BLADERF_BLOCKSIZE, NULL, 10000)) < 0) {
78  qCritical("BladerfThread: sync error: %s", strerror(errno));
79  break;
80  }
81 
83  }
84 
85  m_running = false;
86 }
void callback(const qint16 *buf, qint32 len)
QWaitCondition m_startWaiter
struct bladerf * m_dev
#define BLADERF_BLOCKSIZE
qint16 m_buf[2 *BLADERF_BLOCKSIZE]
+ Here is the call graph for this function:

◆ setFcPos()

void Bladerf1InputThread::setFcPos ( int  fcPos)

Definition at line 64 of file bladerf1inputthread.cpp.

References m_fcPos.

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

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

◆ setLog2Decimation()

void Bladerf1InputThread::setLog2Decimation ( unsigned int  log2_decim)

Definition at line 59 of file bladerf1inputthread.cpp.

References m_log2Decim.

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

60 {
61  m_log2Decim = log2_decim;
62 }
+ Here is the caller graph for this function:

◆ startWork()

void Bladerf1InputThread::startWork ( )

Definition at line 44 of file bladerf1inputthread.cpp.

References m_running, m_startWaiter, and m_startWaitMutex.

Referenced by Bladerf1Input::start().

45 {
46  m_startWaitMutex.lock();
47  start();
48  while(!m_running)
49  m_startWaiter.wait(&m_startWaitMutex, 100);
50  m_startWaitMutex.unlock();
51 }
QWaitCondition m_startWaiter
+ Here is the caller graph for this function:

◆ stopWork()

void Bladerf1InputThread::stopWork ( )

Definition at line 53 of file bladerf1inputthread.cpp.

References m_running.

Referenced by Bladerf1Input::stop(), and ~Bladerf1InputThread().

54 {
55  m_running = false;
56  wait();
57 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_buf

qint16 Bladerf1InputThread::m_buf[2 *BLADERF_BLOCKSIZE]
private

Definition at line 48 of file bladerf1inputthread.h.

Referenced by Bladerf1InputThread(), and run().

◆ m_convertBuffer

SampleVector Bladerf1InputThread::m_convertBuffer
private

Definition at line 49 of file bladerf1inputthread.h.

Referenced by callback().

◆ m_decimators

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

Definition at line 55 of file bladerf1inputthread.h.

Referenced by callback().

◆ m_dev

struct bladerf* Bladerf1InputThread::m_dev
private

Definition at line 47 of file bladerf1inputthread.h.

Referenced by run().

◆ m_fcPos

int Bladerf1InputThread::m_fcPos
private

Definition at line 53 of file bladerf1inputthread.h.

Referenced by callback(), and setFcPos().

◆ m_log2Decim

unsigned int Bladerf1InputThread::m_log2Decim
private

Definition at line 52 of file bladerf1inputthread.h.

Referenced by callback(), and setLog2Decimation().

◆ m_running

bool Bladerf1InputThread::m_running
private

Definition at line 45 of file bladerf1inputthread.h.

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

◆ m_sampleFifo

SampleSinkFifo* Bladerf1InputThread::m_sampleFifo
private

Definition at line 50 of file bladerf1inputthread.h.

Referenced by callback().

◆ m_startWaiter

QWaitCondition Bladerf1InputThread::m_startWaiter
private

Definition at line 44 of file bladerf1inputthread.h.

Referenced by run(), and startWork().

◆ m_startWaitMutex

QMutex Bladerf1InputThread::m_startWaitMutex
private

Definition at line 43 of file bladerf1inputthread.h.

Referenced by startWork().


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