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.
perseusthread.h
Go to the documentation of this file.
1 // Copyright (C) 2018 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 #ifndef PLUGINS_SAMPLESOURCE_PERSEUS_PERSEUSTHREAD_H_
19 #define PLUGINS_SAMPLESOURCE_PERSEUS_PERSEUSTHREAD_H_
20 
21 #include <QThread>
22 #include <QMutex>
23 #include <QWaitCondition>
24 #include "perseus-sdr.h"
25 
26 #include "dsp/samplesinkfifo.h"
27 #include "dsp/decimators.h"
28 
29 #define PERSEUS_NBSAMPLES 2048 // Number of I/Q samples in each callback from Perseus
30 #define PERSEUS_BLOCKSIZE 6*PERSEUS_NBSAMPLES // Perseus sends 2*3 bytes samples
31 
32 class PerseusThread : public QThread {
33  Q_OBJECT
34 
35 public:
36  PerseusThread(perseus_descr* dev, SampleSinkFifo* sampleFifo, QObject* parent = 0);
38 
39  void startWork();
40  void stopWork();
41  void setLog2Decimation(unsigned int log2_decim);
42 
43 private:
45  QWaitCondition m_startWaiter;
46  volatile bool m_running;
47 
48  perseus_descr* m_dev;
52 
53  unsigned int m_log2Decim;
55 
56  Decimators<qint32, TripleByteLE<qint32>, SDR_RX_SAMP_SZ, 24> m_decimators32; // for no decimation (accumulator is int32)
57  Decimators<qint32, TripleByteLE<qint64>, SDR_RX_SAMP_SZ, 24> m_decimators64; // for actual decimation (accumulator is int64)
58 
59  void run();
60  void callback(const uint8_t* buf, qint32 len); // inner call back
61  static int rx_callback(void *buf, int buf_size, void *extra); // call back from Perseus
62 };
63 
64 #endif /* PLUGINS_SAMPLESOURCE_PERSEUS_PERSEUSTHREAD_H_ */
std::vector< Sample > SampleVector
Definition: dsptypes.h:96
volatile bool m_running
Definition: perseusthread.h:46
Decimators< qint32, TripleByteLE< qint64 >, SDR_RX_SAMP_SZ, 24 > m_decimators64
Definition: perseusthread.h:57
QWaitCondition m_startWaiter
Definition: perseusthread.h:45
static PerseusThread * m_this
Definition: perseusthread.h:54
perseus_descr * m_dev
Definition: perseusthread.h:48
void setLog2Decimation(unsigned int log2_decim)
#define SDR_RX_SAMP_SZ
Definition: dsptypes.h:32
unsigned int m_log2Decim
Definition: perseusthread.h:53
PerseusThread(perseus_descr *dev, SampleSinkFifo *sampleFifo, QObject *parent=0)
unsigned char uint8_t
Definition: rtptypes_win.h:42
void callback(const uint8_t *buf, qint32 len)
Decimators< qint32, TripleByteLE< qint32 >, SDR_RX_SAMP_SZ, 24 > m_decimators32
Definition: perseusthread.h:56
QMutex m_startWaitMutex
Definition: perseusthread.h:44
static int rx_callback(void *buf, int buf_size, void *extra)
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