-
Notifications
You must be signed in to change notification settings - Fork 0
/
porthid.cpp
54 lines (36 loc) · 1.21 KB
/
porthid.cpp
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
#include "porthid.h"
PortHid::PortHid(Configuration* config)
: PortBase(config)
{
isRunning = false;
hidDevice = 0;
}
void PortHid::run(){
if(isRunning) return;
hidDevice = new HidDevice();
if(hidDevice->connect("vid_"+config->get("_setup_","vid")+"&"+"pid_"+config->get("_setup_","pid"))){
isRunning = true;
unsigned char in_report_id = config->get("_setup_","in_report_id","0").toInt();
int in_endpoint_size = config->get("_setup_","in_endpoint_size","64").toInt();
dataBytes.resize(in_endpoint_size +1);
while(isRunning){
//read
hidDevice->read(in_report_id,dataBytes);
emit newData(dataBytes);
emit packetSeparator();
qApp->processEvents();
}
}else{
QMessageBox::critical(0,"","Could not open USB HID with VID="+config->get("_setup_","vid")+" PID="+config->get("_setup_","pid")+"\nMake sure the device is attached.");
};
isRunning = false;
delete hidDevice;
emit stopped();
}
void PortHid::send(const QString & str){
}
void PortHid::requestToStop(){
isRunning = false;
}
PortHid::~PortHid(){
}