-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathportthread.cpp
More file actions
64 lines (56 loc) · 1.74 KB
/
Copy pathportthread.cpp
File metadata and controls
64 lines (56 loc) · 1.74 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
54
55
56
57
58
59
60
61
62
#include "portthread.h"
#include "QMessageBox"
PortThread::PortThread(QObject *parent) :
QThread(parent)
{
serialPortInfoList=QSerialPortInfo::availablePorts();
QSerialPortInfo *q2=new QSerialPortInfo();
ListPort=new QStringList();
length=serialPortInfoList.length();
setParent(0);
moveToThread(this);
runable=true;
}
void PortThread::run()
{
bool b;
QString name;
int i=0;
while (true)
{
if (runable)
{
b=false;
QThread::msleep(500);
serialPortInfoList=QSerialPortInfo::availablePorts();
//if (length!=serialPortInfoList.length() || i==0)
//{
foreach (const QSerialPortInfo &serialPortInfo, serialPortInfoList)
{
if (serialPortInfo.manufacturer()=="www.airboxlab.com" || serialPortInfo.manufacturer()=="getalima.com" || serialPortInfo.manufacturer()=="http://getalima.com/" || serialPortInfo.manufacturer()=="http://www.airboxlab.com/" )
{
b=true;
name=*(new QString(serialPortInfo.portName()));
}
/* If we need a list of the available port
if (serialPortInfo.portName()!="Bluetooth-Incoming-Port" && serialPortInfo.portName()!="Bluetooth-Modem")
{
ListPort->append(*(new QString(serialPortInfo.manufacturer())));
}
*/
}
//length=serialPortInfoList.length();
emit isPlugged(b);
emit updateName(name);
ListPort->clear();
//}
}
else QThread::msleep(500);
i=1;
}
exec();
}
void PortThread::ProcessingConf(bool b)
{
runable=b;
}