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
fa9c2024
Commit
fa9c2024
authored
Oct 10, 2024
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改命令bug
parent
88ad9e2a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
29 deletions
+29
-29
NonConnectedCameraHandle.cpp
+1
-1
VidesData.h
+25
-27
gamera_videos.pro
+3
-1
No files found.
NonConnectedCameraHandle.cpp
View file @
fa9c2024
...
...
@@ -241,7 +241,7 @@ int NonConnectedCameraHandle::sdkDevLoginSyn(QString sDevId, int nDevPort,
return
loginResult
;
}
bool
NonConnectedCameraHandle
::
distributionNetwork
(
QString
&
ip
,
QString
&
sSn
,
int
hDevice
){
if
(
vides_data
::
pingAddress
(
ip
)){
if
(
ip
.
length
()
>
0
&&
vides_data
::
pingAddress
(
ip
)){
qInfo
()
<<
QString
(
"SN(%1): 当前ip已被使用%2"
).
arg
(
sSn
).
arg
(
ip
);
return
false
;
}
...
...
VidesData.h
View file @
fa9c2024
...
...
@@ -442,8 +442,8 @@ inline bool GetNetworkInfoByQNetworkInterface(QString &mac, QString &subnetMask,
QList
<
QNetworkInterface
>
interfaces
=
QNetworkInterface
::
allInterfaces
();
foreach
(
QNetworkInterface
interface
,
interfaces
)
{
if
(
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsUp
)
&&
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsRunning
)
&&
!
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsLoopBack
))
{
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsRunning
)
&&
!
interface
.
flags
().
testFlag
(
QNetworkInterface
::
IsLoopBack
))
{
mac
=
interface
.
hardwareAddress
();
QList
<
QNetworkAddressEntry
>
addressEntries
=
interface
.
addressEntries
();
...
...
@@ -484,40 +484,38 @@ inline bool GetNetworkInfoByQNetworkInterface(QString &mac, QString &subnetMask,
}
inline
bool
pingAddress
(
const
QString
&
address
)
{
QProcess
process
;
QString
program
=
"ping"
;
QStringList
arguments
;
#ifdef Q_OS_WIN
// Windows 下通常不需要 sudo
arguments
<<
"-n"
<<
"1"
<<
address
;
// Windows 指令 "ping IP -n 1 -w 超时(ms)"
QString
cmdstr
=
QString
(
"ping %1 -n 1 -w %2"
)
.
arg
(
address
).
arg
(
1000
);
#else
// 不使用 sudo
arguments
<<
"-c"
<<
"1"
<<
address
;
// Linux 指令 "ping -c 1 IP"
QString
cmdstr
=
QString
(
"ping -c 1 %1"
)
.
arg
(
address
);
#endif
process
.
start
(
program
,
arguments
);
if
(
!
process
.
waitForStarted
())
{
qWarning
()
<<
"Failed to start 'ping' process for"
<<
address
;
return
false
;
}
// 使用较长的超时值,确保进程有足够时间完成
if
(
!
process
.
waitForFinished
(
3000
))
{
process
.
kill
();
// 如果超时,强制终止进程
qWarning
()
<<
"Ping process timed out for"
<<
address
;
return
false
;
}
QProcess
cmd
;
cmd
.
start
(
cmdstr
);
cmd
.
waitForReadyRead
(
1000
);
cmd
.
waitForFinished
(
1000
);
QString
output
(
process
.
readAllStandardOutput
());
q
Debug
()
<<
"Ping Output for"
<<
address
<<
":"
<<
output
;
// 调试输出
QString
res
=
QString
::
fromLocal8Bit
(
cmd
.
readAll
());
q
Info
()
<<
res
;
// 简单的 Ping 成功检查逻辑
#ifdef Q_OS_WIN
return
output
.
contains
(
"TTL="
);
if
(
res
.
indexOf
(
"TTL"
)
==
-
1
)
#else
return
output
.
contains
(
"1 packets transmitted, 1 received"
);
if
(
!
res
.
contains
(
"1 packets transmitted, 1 received"
))
#endif
{
qInfo
()
<<
address
<<
QString
::
fromLocal8Bit
(
"ping不通"
);
return
false
;
}
else
{
qInfo
()
<<
address
<<
QString
::
fromLocal8Bit
(
"ping通"
);
return
true
;
}
}
inline
QString
findReachableIp
()
{
...
...
gamera_videos.pro
View file @
fa9c2024
...
...
@@ -130,7 +130,9 @@ HEADERS += \
AlgorithmTaskManage
.
h
\
BaseAlgorithm
.
h
\
MqttSubscriber
.
h
\
NonConnectedCameraHandle
.
h
NonConnectedCameraHandle
.
h
\
RecognizedInfo
.
h
# Default rules for deployment.
qnx
:
target
.
path
=
/
tmp
/
$$
{
TARGET
}
/
bin
...
...
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