-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
77 lines (64 loc) · 1.48 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <QCoreApplication>
#include <datafifo.h>
#include <QDebug>
#include <QIODevice>
#include <QDataStream>
#include "mylog.h"
#include <QMap>
#include "rtkprocess.h"
#include <QString>
#include "pthread.h"
#include <unistd.h>
#include "gemho_rtk.h"
#include "bsp_thr.h"
#include <QThread>
#include <QSerialPort>
class processThread: public QThread
{
public:
processThread(void *handle);
void run(); //声明继承于QThread虚函数 run()
private:
void *m_handle;
};
processThread::processThread(void *handle)
{
m_handle = handle;
}
void processThread::run()
{
gemhoRtkSendInit(m_handle);
while(1)
{
gemhoRtkProcess(m_handle);
QCoreApplication::processEvents();
usleep(100*1000);
}
}
void *process_main(void *args)
{
void *handle = gemhoRtkStart();
traceclose();
// traceopen(".//debug.txt");
processThread proThread(handle);
proThread.start();
while(1)
{
QString str;
QTextStream in(stdin);
in >> str;
if(str == "quit")
break;
}
gemhoRtkStop(handle);
exit(0);
return NULL;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
log_init(QCoreApplication::applicationDirPath()+ "/log4j.properties");
BSP_ThrHndl mainThread;
BSP_thrCreate(&mainThread, process_main, BSP_THR_PRI_DEFAULT, BSP_THR_STACK_SIZE_DEFAULT, NULL);
return a.exec();
}