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

#include <limesdrinputthread.h>

+ Inheritance diagram for LimeSDRInputThread:
+ Collaboration diagram for LimeSDRInputThread:

Public Member Functions

 LimeSDRInputThread (lms_stream_t *stream, SampleSinkFifo *sampleFifo, QObject *parent=0)
 
 ~LimeSDRInputThread ()
 
virtual void startWork ()
 
virtual void stopWork ()
 
virtual void setDeviceSampleRate (int sampleRate)
 
virtual bool isRunning ()
 
void setLog2Decimation (unsigned int log2_decim)
 

Private Member Functions

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

Private Attributes

QMutex m_startWaitMutex
 
QWaitCondition m_startWaiter
 
bool m_running
 
lms_stream_t * m_stream
 
qint16 m_buf [2 *LIMESDR_BLOCKSIZE]
 
SampleVector m_convertBuffer
 
SampleSinkFifom_sampleFifo
 
unsigned int m_log2Decim
 
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 12 > m_decimators
 

Detailed Description

Definition at line 33 of file limesdrinputthread.h.

Constructor & Destructor Documentation

◆ LimeSDRInputThread()

LimeSDRInputThread::LimeSDRInputThread ( lms_stream_t *  stream,
SampleSinkFifo sampleFifo,
QObject *  parent = 0 
)

Definition at line 24 of file limesdrinputthread.cpp.

References LIMESDR_BLOCKSIZE, and m_buf.

24  :
25  QThread(parent),
26  m_running(false),
27  m_stream(stream),
29  m_sampleFifo(sampleFifo),
30  m_log2Decim(0)
31 {
32  std::fill(m_buf, m_buf + 2*LIMESDR_BLOCKSIZE, 0);
33 }
qint16 m_buf[2 *LIMESDR_BLOCKSIZE]
SampleSinkFifo * m_sampleFifo
unsigned int m_log2Decim
SampleVector m_convertBuffer
lms_stream_t * m_stream
#define LIMESDR_BLOCKSIZE

◆ ~LimeSDRInputThread()

LimeSDRInputThread::~LimeSDRInputThread ( )

Definition at line 35 of file limesdrinputthread.cpp.

References stopWork().

36 {
37  stopWork();
38 }
+ Here is the call graph for this function:

Member Function Documentation

◆ callback()

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

Definition at line 104 of file limesdrinputthread.cpp.

References Decimators< StorageType, T, SdrBits, InputBits >::decimate1(), Decimators< StorageType, T, SdrBits, InputBits >::decimate16_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate2_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate32_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate4_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate64_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate8_cen(), m_convertBuffer, m_decimators, m_log2Decim, m_sampleFifo, and SampleSinkFifo::write().

Referenced by run().

105 {
106  SampleVector::iterator it = m_convertBuffer.begin();
107 
108  switch (m_log2Decim)
109  {
110  case 0:
111  m_decimators.decimate1(&it, buf, len);
112  break;
113  case 1:
114  m_decimators.decimate2_cen(&it, buf, len);
115  break;
116  case 2:
117  m_decimators.decimate4_cen(&it, buf, len);
118  break;
119  case 3:
120  m_decimators.decimate8_cen(&it, buf, len);
121  break;
122  case 4:
123  m_decimators.decimate16_cen(&it, buf, len);
124  break;
125  case 5:
126  m_decimators.decimate32_cen(&it, buf, len);
127  break;
128  case 6:
129  m_decimators.decimate64_cen(&it, buf, len);
130  break;
131  default:
132  break;
133  }
134 
135  m_sampleFifo->write(m_convertBuffer.begin(), it);
136 }
void decimate64_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:3040
void decimate2_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:554
uint write(const quint8 *data, uint count)
void decimate8_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1057
SampleSinkFifo * m_sampleFifo
void decimate4_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:782
unsigned int m_log2Decim
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 12 > m_decimators
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:

◆ isRunning()

virtual bool LimeSDRInputThread::isRunning ( )
inlinevirtual

Implements DeviceLimeSDRShared::ThreadInterface.

Definition at line 44 of file limesdrinputthread.h.

References m_running, and setLog2Decimation().

Referenced by LimeSDRInput::applySettings().

44 { return m_running; }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

void LimeSDRInputThread::run ( )
private

Definition at line 78 of file limesdrinputthread.cpp.

References callback(), LIMESDR_BLOCKSIZE, m_buf, m_running, m_startWaiter, and m_stream.

79 {
80  int res;
81 
82  lms_stream_meta_t metadata; //Use metadata for additional control over sample receive function behaviour
83  metadata.flushPartialPacket = false; //Do not discard data remainder when read size differs from packet size
84  metadata.waitForTimestamp = false; //Do not wait for specific timestamps
85 
86  m_running = true;
87  m_startWaiter.wakeAll();
88 
89  while (m_running)
90  {
91  if ((res = LMS_RecvStream(m_stream, (void *) m_buf, LIMESDR_BLOCKSIZE, &metadata, 1000)) < 0)
92  {
93  qCritical("LimeSDRInputThread::run read error: %s", strerror(errno));
94  break;
95  }
96 
97  callback(m_buf, 2 * res);
98  }
99 
100  m_running = false;
101 }
QWaitCondition m_startWaiter
qint16 m_buf[2 *LIMESDR_BLOCKSIZE]
lms_stream_t * m_stream
void callback(const qint16 *buf, qint32 len)
#define LIMESDR_BLOCKSIZE
+ Here is the call graph for this function:

◆ setDeviceSampleRate()

virtual void LimeSDRInputThread::setDeviceSampleRate ( int  sampleRate)
inlinevirtual

Implements DeviceLimeSDRShared::ThreadInterface.

Definition at line 43 of file limesdrinputthread.h.

43 { (void) sampleRate; }

◆ setLog2Decimation()

void LimeSDRInputThread::setLog2Decimation ( unsigned int  log2_decim)

Definition at line 73 of file limesdrinputthread.cpp.

References m_log2Decim.

Referenced by LimeSDRInput::applySettings(), isRunning(), and LimeSDRInput::start().

74 {
75  m_log2Decim = log2_decim;
76 }
unsigned int m_log2Decim
+ Here is the caller graph for this function:

◆ startWork()

void LimeSDRInputThread::startWork ( )
virtual

Implements DeviceLimeSDRShared::ThreadInterface.

Definition at line 40 of file limesdrinputthread.cpp.

References m_running, m_startWaiter, m_startWaitMutex, and m_stream.

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

41 {
42  if (m_running) return; // return if running already
43 
44  if (LMS_StartStream(m_stream) < 0) {
45  qCritical("LimeSDRInputThread::startWork: could not start stream");
46  } else {
47  usleep(50000);
48  qDebug("LimeSDRInputThread::startWork: stream started");
49  }
50 
51  m_startWaitMutex.lock();
52  start();
53  while(!m_running)
54  m_startWaiter.wait(&m_startWaitMutex, 100);
55  m_startWaitMutex.unlock();
56 }
QWaitCondition m_startWaiter
lms_stream_t * m_stream
+ Here is the caller graph for this function:

◆ stopWork()

void LimeSDRInputThread::stopWork ( )
virtual

Implements DeviceLimeSDRShared::ThreadInterface.

Definition at line 58 of file limesdrinputthread.cpp.

References m_running, and m_stream.

Referenced by LimeSDRInput::applySettings(), LimeSDRInput::stop(), and ~LimeSDRInputThread().

59 {
60  if (!m_running) return; // return if not running
61 
62  m_running = false;
63  wait();
64 
65  if (LMS_StopStream(m_stream) < 0) {
66  qCritical("LimeSDRInputThread::stopWork: could not stop stream");
67  } else {
68  usleep(50000);
69  qDebug("LimeSDRInputThread::stopWork: stream stopped");
70  }
71 }
lms_stream_t * m_stream
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_buf

qint16 LimeSDRInputThread::m_buf[2 *LIMESDR_BLOCKSIZE]
private

Definition at line 53 of file limesdrinputthread.h.

Referenced by LimeSDRInputThread(), and run().

◆ m_convertBuffer

SampleVector LimeSDRInputThread::m_convertBuffer
private

Definition at line 54 of file limesdrinputthread.h.

Referenced by callback().

◆ m_decimators

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

Definition at line 59 of file limesdrinputthread.h.

Referenced by callback().

◆ m_log2Decim

unsigned int LimeSDRInputThread::m_log2Decim
private

Definition at line 57 of file limesdrinputthread.h.

Referenced by callback(), and setLog2Decimation().

◆ m_running

bool LimeSDRInputThread::m_running
private

Definition at line 50 of file limesdrinputthread.h.

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

◆ m_sampleFifo

SampleSinkFifo* LimeSDRInputThread::m_sampleFifo
private

Definition at line 55 of file limesdrinputthread.h.

Referenced by callback().

◆ m_startWaiter

QWaitCondition LimeSDRInputThread::m_startWaiter
private

Definition at line 49 of file limesdrinputthread.h.

Referenced by run(), and startWork().

◆ m_startWaitMutex

QMutex LimeSDRInputThread::m_startWaitMutex
private

Definition at line 48 of file limesdrinputthread.h.

Referenced by startWork().

◆ m_stream

lms_stream_t* LimeSDRInputThread::m_stream
private

Definition at line 52 of file limesdrinputthread.h.

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


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