Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gamera_videos_no_ui
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liusq
gamera_videos_no_ui
Commits
de180a5b
Commit
de180a5b
authored
Oct 10, 2024
by
郭峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-1007488' into 'release'
修改命令bug1 See merge request
!39
parents
dc686e8c
7a9cb116
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
15 deletions
+28
-15
VidesData.h
+28
-15
No files found.
VidesData.h
View file @
de180a5b
...
@@ -484,6 +484,8 @@ inline bool GetNetworkInfoByQNetworkInterface(QString &mac, QString &subnetMask,
...
@@ -484,6 +484,8 @@ inline bool GetNetworkInfoByQNetworkInterface(QString &mac, QString &subnetMask,
}
}
inline
bool
pingAddress
(
const
QString
&
address
)
{
inline
bool
pingAddress
(
const
QString
&
address
)
{
QProcess
cmd
;
#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
// Windows 指令 "ping IP -n 1 -w 超时(ms)"
// Windows 指令 "ping IP -n 1 -w 超时(ms)"
QString
cmdstr
=
QString
(
"ping %1 -n 1 -w %2"
)
QString
cmdstr
=
QString
(
"ping %1 -n 1 -w %2"
)
...
@@ -494,27 +496,38 @@ inline bool pingAddress(const QString &address) {
...
@@ -494,27 +496,38 @@ inline bool pingAddress(const QString &address) {
.
arg
(
address
);
.
arg
(
address
);
#endif
#endif
QProcess
cmd
;
// 启动进程
cmd
.
start
(
cmdstr
);
cmd
.
start
(
cmdstr
);
cmd
.
waitForReadyRead
(
1000
);
cmd
.
waitForFinished
(
1000
);
QString
res
=
QString
::
fromLocal8Bit
(
cmd
.
readAll
());
// 等待进程准备好读取
qInfo
()
<<
res
;
if
(
!
cmd
.
waitForStarted
())
{
qWarning
()
<<
"Failed to start 'ping' process for"
<<
address
;
return
false
;
}
#ifdef Q_OS_WIN
// 等待进程完成
if
(
res
.
indexOf
(
"TTL"
)
==
-
1
)
if
(
!
cmd
.
waitForFinished
(
3000
))
{
// 增加超时时间
#else
cmd
.
kill
();
if
(
!
res
.
contains
(
"1 packets transmitted, 1 received"
))
qWarning
()
<<
"Ping process timed out for"
<<
address
;
#endif
{
qInfo
()
<<
address
<<
QString
::
fromLocal8Bit
(
"ping不通"
);
return
false
;
return
false
;
}
}
else
{
// 读取输出
qInfo
()
<<
address
<<
QString
::
fromLocal8Bit
(
"ping通"
);
QByteArray
output
=
cmd
.
readAllStandardOutput
();
QByteArray
errorOutput
=
cmd
.
readAllStandardError
();
int
exitCode
=
cmd
.
exitCode
();
qInfo
()
<<
"Ping Output for"
<<
address
<<
":"
<<
QString
::
fromUtf8
(
output
);
qInfo
()
<<
"Ping Error Output for"
<<
address
<<
":"
<<
QString
::
fromUtf8
(
errorOutput
);
qInfo
()
<<
"Ping Exit Code for"
<<
address
<<
":"
<<
exitCode
;
// 判断 Ping 是否成功
if
(
exitCode
==
0
)
{
qInfo
()
<<
address
<<
"ping通"
;
return
true
;
return
true
;
}
else
{
qInfo
()
<<
address
<<
"ping不通"
;
return
false
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment