-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPCMdekoder.cpp
More file actions
54 lines (41 loc) · 1.02 KB
/
PCMdekoder.cpp
File metadata and controls
54 lines (41 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "PCMdekoder.h"
PCMdekoder::PCMdekoder() {
Set_portname("/dev/ttyUSB0");
stop_running = false;
}
PCMdekoder::~PCMdekoder() {
}
bool PCMdekoder::init(){
m_status.invalidPCMwords = 0;
m_status.validPCMwords = 0;
// prepare serialport
source = new serialport();
if (source->init(m_portname.toAscii().data(), m_baudrate, 1)) {
return true;
} else {
source->uninit();
delete source;
return false;
}
}
void PCMdekoder::uninit(){
stop_running = true;
usleep(10000);
while (this->isRunning()){
qDebug() << "PCMdekoder: Stopping serial thread...";
usleep(10000);
}
source->uninit();
delete source;
}
void PCMdekoder::run(){
QString PCM = QString("PCM");
qDebug() << "PCMdekoder: Dekoder-Thread called on"<<m_portname<<"with thread ID"<<currentThreadId();
//exec();//normal in qthreads to enter qt-command queue
while ( !stop_running ) {
source->readPCMword(&m_lastValue);
m_status.invalidPCMwords = source->m_invalid;
m_status.validPCMwords = source->m_valid;
emit newData(PCM,m_lastValue);
}
}