-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.cpp
More file actions
39 lines (33 loc) · 660 Bytes
/
core.cpp
File metadata and controls
39 lines (33 loc) · 660 Bytes
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
#include "core.h"
Core::Core()
{
serial = new Serial;
serial->moveToThread(&serialThread);
connect(&serialThread, &QThread::started, serial, &Serial::loop);
serialThread.start();
}
Core::~Core()
{
serial->disableLoop();
serialThread.quit();
serialThread.wait();
delete serial;
}
void Core::loop()
{
while(loopEnabled) {
if (!serial->isEmpty()) {
QByteArray recvData = serial->read();
emit appendReceivedData(recvData);
}
QThread().currentThread()->msleep(1);
}
}
Serial *Core::getSerial()
{
return serial;
}
void Core::disableLoop()
{
loopEnabled = false;
}