-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
122 lines (92 loc) · 2.87 KB
/
Copy pathmain.cpp
File metadata and controls
122 lines (92 loc) · 2.87 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <QCoreApplication>
#include <QSerialPort>
#include <iostream>
//#include <Windows.h>
#include <QDateTime>
#include "tcpclinet.h"
#include "tcpserver.h"
#include "uart2net.h"
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// FUN1: 写一个配置示例
//UART2NET::write_an_example();
// FUN2: 读配置示例
//UART2NET::UART2NETCONFIG config;
//UART2NET::read_uart2net_config(config);
// FUN3: 创建服务器端示例
UART2NET uart2net;
//uart2net.write_uart2net_iniconfig();
int res = uart2net.read_uart2net_iniconfig();
if(res != UART2NET_SUCCESS)
{
fprintf(stderr, "Config File Error %d\n", res);
}
else
uart2net.run_uart2net();
//EXFunctions *exfuns = new EXFunctions;
// exfuns->connect_main(1);
//exfuns->start();
//exfuns.connect_main(1);
//cout << "继续" << endl;
//QEventLoop loop;
/*
SerialPort sp;
int res = sp.run("COM5", 9600);
if(res == 1)
std::cout << "success" << std::endl;
else {
std::cout << "failed" << std::endl;
}
QByteArray ba;
ba.resize(1);
ba[0] = 0x01;
for(int i = 0;i < 10; i++)
{
ba[0] = i;
sp.send(ba);
//loop.processEvents();
Sleep(100);
}
system("pause");
sp.close();
//system("pause");
//sp.close();
//UART2NET uart2net;
*/
/*
TcpServer tcpserver;
int err = tcpserver.run(8888);
if(err == 0)
std::cout << "open failed" << std::endl;
else
std::cout << "open success" << std::endl;
*/
//TcpClinet tcpclient;
//int err = tcpclient.run("10.17.37.19", 8888);
//std::cout << err << std::endl;
//if(err > 0)
// std::cout << "open success" << std::endl;
//Sleep(5000);
//tcpclient.close();
//writeUART2NETConfig("D:\\", "test.xml",
// true,
// "COM1", 9600, "10.17.37.19", 8888);
//int isServer, btl, port;
//QString portNum, hostip;
//readUART2NETConfig("D:\\", "test.xml", isServer, portNum, btl, hostip, port);
//UART2NET uart2net;
//uart2net.run_server("COM4", 9600, 8888);
//uart2net.run_client("COM4", 9600, "10.17.37.19", 8888);
//Sleep(5000);
//uart2net.close();
//QObject::connect(&a, SIGNAL(aboutToQuit()), &uart2net, SLOT(uart2net_safe_quit()));
//QDateTime current_time = QDateTime::currentDateTime();
//QString strCUrrentTime = current_time.toString("[yyyy-MM-dd-hh-mm-ss]:");
//printf("%s\n", current_time.toString("[yyyy-MM-dd-hh-mm-ss]:").toStdString().c_str());
//printf("%s\n", current_time.toString("[yyyy-MM-dd hh:mm:ss.zzz]:").toStdString().c_str());
//UART2NET uart2net;
//uart2net.create_log();
return a.exec();
}