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
PerseusThread Class Reference

#include <perseusthread.h>

Inherits QThread.

+ Collaboration diagram for PerseusThread:

Public Member Functions

 PerseusThread (perseus_descr *dev, SampleSinkFifo *sampleFifo, QObject *parent=0)
 
 ~PerseusThread ()
 
void startWork ()
 
void stopWork ()
 
void setLog2Decimation (unsigned int log2_decim)
 

Private Member Functions

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

Static Private Member Functions

static int rx_callback (void *buf, int buf_size, void *extra)
 

Private Attributes

QMutex m_startWaitMutex
 
QWaitCondition m_startWaiter
 
volatile bool m_running
 
perseus_descr * m_dev
 
qint32 m_buf [2 *PERSEUS_NBSAMPLES]
 
SampleVector m_convertBuffer
 
SampleSinkFifom_sampleFifo
 
unsigned int m_log2Decim
 
Decimators< qint32, TripleByteLE< qint32 >, SDR_RX_SAMP_SZ, 24 > m_decimators32
 
Decimators< qint32, TripleByteLE< qint64 >, SDR_RX_SAMP_SZ, 24 > m_decimators64
 

Static Private Attributes

static PerseusThreadm_this = 0
 

Detailed Description

Definition at line 32 of file perseusthread.h.

Constructor & Destructor Documentation

◆ PerseusThread()

PerseusThread::PerseusThread ( perseus_descr *  dev,
SampleSinkFifo sampleFifo,
QObject *  parent = 0 
)

Definition at line 24 of file perseusthread.cpp.

References m_buf, m_this, and PERSEUS_NBSAMPLES.

24  :
25  QThread(parent),
26  m_running(false),
27  m_dev(dev),
29  m_sampleFifo(sampleFifo),
30  m_log2Decim(0)
31 {
32  m_this = this;
33  std::fill(m_buf, m_buf + 2*PERSEUS_NBSAMPLES, 0);
34 }
volatile bool m_running
Definition: perseusthread.h:46
static PerseusThread * m_this
Definition: perseusthread.h:54
perseus_descr * m_dev
Definition: perseusthread.h:48
unsigned int m_log2Decim
Definition: perseusthread.h:53
SampleSinkFifo * m_sampleFifo
Definition: perseusthread.h:51
#define PERSEUS_NBSAMPLES
Definition: perseusthread.h:29
qint32 m_buf[2 *PERSEUS_NBSAMPLES]
Definition: perseusthread.h:49
SampleVector m_convertBuffer
Definition: perseusthread.h:50

◆ ~PerseusThread()

PerseusThread::~PerseusThread ( )

Definition at line 36 of file perseusthread.cpp.

References m_this, and stopWork().

37 {
38  stopWork();
39  m_this = 0;
40 }
static PerseusThread * m_this
Definition: perseusthread.h:54
+ Here is the call graph for this function:

Member Function Documentation

◆ callback()

void PerseusThread::callback ( const uint8_t buf,
qint32  len 
)
private

Definition at line 93 of file perseusthread.cpp.

References Decimators< StorageType, T, SdrBits, InputBits >::decimate1(), Decimators< StorageType, T, SdrBits, InputBits >::decimate2_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate4_cen(), m_convertBuffer, m_decimators32, m_decimators64, m_log2Decim, m_sampleFifo, and SampleSinkFifo::write().

Referenced by rx_callback().

94 {
95  SampleVector::iterator it = m_convertBuffer.begin();
96 
97  switch (m_log2Decim)
98  {
99  case 0:
101  break;
102  case 1:
104  break;
105  case 2:
107  break;
108  default:
109  break;
110  }
111 
112  m_sampleFifo->write(m_convertBuffer.begin(), it);
113 }
Decimators< qint32, TripleByteLE< qint64 >, SDR_RX_SAMP_SZ, 24 > m_decimators64
Definition: perseusthread.h:57
void decimate2_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:554
uint write(const quint8 *data, uint count)
unsigned int m_log2Decim
Definition: perseusthread.h:53
void decimate4_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:782
Decimators< qint32, TripleByteLE< qint32 >, SDR_RX_SAMP_SZ, 24 > m_decimators32
Definition: perseusthread.h:56
SampleSinkFifo * m_sampleFifo
Definition: perseusthread.h:51
void decimate1(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:462
SampleVector m_convertBuffer
Definition: perseusthread.h:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

void PerseusThread::run ( )
private

Definition at line 64 of file perseusthread.cpp.

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

65 {
66  m_running = true;
67  m_startWaiter.wakeAll();
68 
69  int rc = perseus_start_async_input(m_dev, PERSEUS_BLOCKSIZE, rx_callback, 0);
70 
71  if (rc < 0) {
72  qCritical("PerseusThread::run: failed to start Perseus Rx: %s", perseus_errorstr());
73  }
74  else
75  {
76  qDebug("PerseusThread::run: start Perseus Rx");
77  while (m_running) {
78  sleep(1);
79  }
80  }
81 
82  rc = perseus_stop_async_input(m_dev);
83 
84  if (rc < 0) {
85  qCritical("PerseusThread::run: failed to stop Perseus Rx: %s", perseus_errorstr());
86  } else {
87  qDebug("PerseusThread::run: stopped Perseus Rx");
88  }
89 
90  m_running = false;
91 }
volatile bool m_running
Definition: perseusthread.h:46
#define PERSEUS_BLOCKSIZE
Definition: perseusthread.h:30
QWaitCondition m_startWaiter
Definition: perseusthread.h:45
perseus_descr * m_dev
Definition: perseusthread.h:48
static int rx_callback(void *buf, int buf_size, void *extra)
+ Here is the call graph for this function:

◆ rx_callback()

int PerseusThread::rx_callback ( void *  buf,
int  buf_size,
void *  extra 
)
staticprivate

Definition at line 115 of file perseusthread.cpp.

References callback(), and m_this.

Referenced by run().

116 {
117  (void) extra;
118  qint32 nbIAndQ = buf_size / 3; // 3 bytes per I or Q
119  m_this->callback((uint8_t*) buf, nbIAndQ);
120  return 0;
121 }
static PerseusThread * m_this
Definition: perseusthread.h:54
unsigned char uint8_t
Definition: rtptypes_win.h:42
void callback(const uint8_t *buf, qint32 len)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLog2Decimation()

void PerseusThread::setLog2Decimation ( unsigned int  log2_decim)

Definition at line 59 of file perseusthread.cpp.

References m_log2Decim.

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

60 {
61  m_log2Decim = log2_decim;
62 }
unsigned int m_log2Decim
Definition: perseusthread.h:53
+ Here is the caller graph for this function:

◆ startWork()

void PerseusThread::startWork ( )

Definition at line 42 of file perseusthread.cpp.

References m_running, m_startWaiter, and m_startWaitMutex.

Referenced by PerseusInput::start().

43 {
44  qDebug("PerseusThread::startWork");
45  m_startWaitMutex.lock();
46  start();
47  while(!m_running)
48  m_startWaiter.wait(&m_startWaitMutex, 100);
49  m_startWaitMutex.unlock();
50 }
volatile bool m_running
Definition: perseusthread.h:46
QWaitCondition m_startWaiter
Definition: perseusthread.h:45
QMutex m_startWaitMutex
Definition: perseusthread.h:44
+ Here is the caller graph for this function:

◆ stopWork()

void PerseusThread::stopWork ( )

Definition at line 52 of file perseusthread.cpp.

References m_running.

Referenced by PerseusInput::stop(), and ~PerseusThread().

53 {
54  qDebug("PerseusThread::stopWork");
55  m_running = false;
56  wait();
57 }
volatile bool m_running
Definition: perseusthread.h:46
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_buf

qint32 PerseusThread::m_buf[2 *PERSEUS_NBSAMPLES]
private

Definition at line 49 of file perseusthread.h.

Referenced by PerseusThread().

◆ m_convertBuffer

SampleVector PerseusThread::m_convertBuffer
private

Definition at line 50 of file perseusthread.h.

Referenced by callback().

◆ m_decimators32

Decimators<qint32, TripleByteLE<qint32>, SDR_RX_SAMP_SZ, 24> PerseusThread::m_decimators32
private

Definition at line 56 of file perseusthread.h.

Referenced by callback().

◆ m_decimators64

Decimators<qint32, TripleByteLE<qint64>, SDR_RX_SAMP_SZ, 24> PerseusThread::m_decimators64
private

Definition at line 57 of file perseusthread.h.

Referenced by callback().

◆ m_dev

perseus_descr* PerseusThread::m_dev
private

Definition at line 48 of file perseusthread.h.

Referenced by run().

◆ m_log2Decim

unsigned int PerseusThread::m_log2Decim
private

Definition at line 53 of file perseusthread.h.

Referenced by callback(), and setLog2Decimation().

◆ m_running

volatile bool PerseusThread::m_running
private

Definition at line 46 of file perseusthread.h.

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

◆ m_sampleFifo

SampleSinkFifo* PerseusThread::m_sampleFifo
private

Definition at line 51 of file perseusthread.h.

Referenced by callback().

◆ m_startWaiter

QWaitCondition PerseusThread::m_startWaiter
private

Definition at line 45 of file perseusthread.h.

Referenced by run(), and startWork().

◆ m_startWaitMutex

QMutex PerseusThread::m_startWaitMutex
private

Definition at line 44 of file perseusthread.h.

Referenced by startWork().

◆ m_this

PerseusThread * PerseusThread::m_this = 0
staticprivate

Definition at line 54 of file perseusthread.h.

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


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