Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
5dec0299
Commit
5dec0299
authored
May 07, 2022
by
Pavel Vainerman
Committed by
Pavel Vainerman
May 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(unet): minor fixes
parent
3b725a99
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
16 deletions
+26
-16
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+19
-10
UNetReceiver.h
extensions/UNetUDP/UNetReceiver.h
+1
-1
unet-udp-tester.cc
extensions/UNetUDP/unet-udp-tester.cc
+6
-5
No files found.
extensions/UNetUDP/UNetReceiver.cc
View file @
5dec0299
...
@@ -512,7 +512,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
...
@@ -512,7 +512,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UNetReceiver
::
checkConnection
()
bool
UNetReceiver
::
checkConnection
()
{
{
bool
tout
=
false
;
bool
tout
=
false
;
...
@@ -530,12 +530,21 @@ void UNetReceiver::checkConnection()
...
@@ -530,12 +530,21 @@ void UNetReceiver::checkConnection()
if
(
w
)
if
(
w
)
{
{
if
(
tout
)
try
slEvent
(
w
,
evTimeout
);
{
else
if
(
tout
)
slEvent
(
w
,
evOK
);
slEvent
(
w
,
evTimeout
);
else
slEvent
(
w
,
evOK
);
}
catch
(
std
::
exception
&
ex
)
{
unetcrit
<<
myname
<<
"(checkConnection): exception: "
<<
ex
.
what
()
<<
endl
;
}
}
}
}
}
return
!
tout
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UNetReceiver
::
updateEvent
(
ev
::
periodic
&
tm
,
int
revents
)
noexcept
void
UNetReceiver
::
updateEvent
(
ev
::
periodic
&
tm
,
int
revents
)
noexcept
...
@@ -552,7 +561,10 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
...
@@ -552,7 +561,10 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
// взводим таймер опять..
// взводим таймер опять..
tm
.
again
();
tm
.
again
();
// собственно обработка события
// смотрим есть ли связь..
bool
recvOk
=
checkConnection
();
// обновление данных в SM
try
try
{
{
update
();
update
();
...
@@ -562,16 +574,13 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
...
@@ -562,16 +574,13 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
unetcrit
<<
myname
<<
"(updateEvent): "
<<
ex
.
what
()
<<
std
::
endl
;
unetcrit
<<
myname
<<
"(updateEvent): "
<<
ex
.
what
()
<<
std
::
endl
;
}
}
// смотрим есть ли связь..
checkConnection
();
if
(
sidRespond
!=
DefaultObjectId
)
if
(
sidRespond
!=
DefaultObjectId
)
{
{
try
try
{
{
if
(
isInitOK
()
)
if
(
isInitOK
()
)
{
{
bool
r
=
respondInvert
?
!
isRecvOK
()
:
isRecvOK
()
;
bool
r
=
respondInvert
?
!
recvOk
:
recvOk
;
shm
->
localSetValue
(
itRespond
,
sidRespond
,
(
r
?
1
:
0
),
shm
->
ID
());
shm
->
localSetValue
(
itRespond
,
sidRespond
,
(
r
?
1
:
0
),
shm
->
ID
());
}
}
}
}
...
...
extensions/UNetUDP/UNetReceiver.h
View file @
5dec0299
...
@@ -189,7 +189,7 @@ namespace uniset
...
@@ -189,7 +189,7 @@ namespace uniset
void
initIterators
()
noexcept
;
void
initIterators
()
noexcept
;
bool
createConnection
(
bool
throwEx
=
false
);
bool
createConnection
(
bool
throwEx
=
false
);
void
checkConnection
();
bool
checkConnection
();
size_t
rnext
(
size_t
num
);
size_t
rnext
(
size_t
num
);
private
:
private
:
...
...
extensions/UNetUDP/unet-udp-tester.cc
View file @
5dec0299
#include <cstdlib>
#include <cstdlib>
#include <errno.h>
#include <getopt.h>
#include <getopt.h>
#include <cstring>
#include <cstring>
#include <iostream>
#include <iostream>
...
@@ -68,7 +67,7 @@ int main(int argc, char* argv[])
...
@@ -68,7 +67,7 @@ int main(int argc, char* argv[])
int
verb
=
0
;
int
verb
=
0
;
std
::
string
addr
=
""
;
std
::
string
addr
=
""
;
int
port
=
0
;
int
port
=
0
;
int
usecpause
=
200000
0
;
int
usecpause
=
200000
;
timeout_t
tout
=
UniSetTimer
::
WaitUpTime
;
timeout_t
tout
=
UniSetTimer
::
WaitUpTime
;
bool
broadcast
=
true
;
bool
broadcast
=
true
;
int
procID
=
1
;
int
procID
=
1
;
...
@@ -108,7 +107,7 @@ int main(int argc, char* argv[])
...
@@ -108,7 +107,7 @@ int main(int argc, char* argv[])
cout
<<
"[-y|--prof] num - Print receive statistics every NUM packets (for -r only)"
<<
endl
;
cout
<<
"[-y|--prof] num - Print receive statistics every NUM packets (for -r only)"
<<
endl
;
cout
<<
"[-a|--a-data] id1=val1,id2=val2,... - Analog data. Send: id1=id1,id2=id2,.. for analog sensors"
<<
endl
;
cout
<<
"[-a|--a-data] id1=val1,id2=val2,... - Analog data. Send: id1=id1,id2=id2,.. for analog sensors"
<<
endl
;
cout
<<
"[-i|--d-data] id1=val1,id2=val2,... - Digital data. Send: id1=id1,id2=id2,.. for digital sensors"
<<
endl
;
cout
<<
"[-i|--d-data] id1=val1,id2=val2,... - Digital data. Send: id1=id1,id2=id2,.. for digital sensors"
<<
endl
;
cout
<<
"[-u|--pack-num] num - first packet numb
rt
(default: 1)"
<<
endl
;
cout
<<
"[-u|--pack-num] num - first packet numb
er
(default: 1)"
<<
endl
;
cout
<<
endl
;
cout
<<
endl
;
return
0
;
return
0
;
...
@@ -255,7 +254,7 @@ int main(int argc, char* argv[])
...
@@ -255,7 +254,7 @@ int main(int argc, char* argv[])
continue
;
continue
;
}
}
size_t
ret
=
udp
.
receiveBytes
(
&
pack
,
sizeof
(
pack
)
);
size_t
ret
=
udp
.
receiveBytes
(
&
pack
,
sizeof
(
pack
));
if
(
ret
<
0
)
if
(
ret
<
0
)
{
{
...
@@ -281,7 +280,9 @@ int main(int argc, char* argv[])
...
@@ -281,7 +280,9 @@ int main(int argc, char* argv[])
{
{
if
(
prev_num
!=
(
pack
.
header
.
num
-
1
)
)
if
(
prev_num
!=
(
pack
.
header
.
num
-
1
)
)
cerr
<<
"WARNING! Incorrect sequence of packets! current="
<<
pack
.
header
.
num
cerr
<<
"WARNING! Incorrect sequence of packets! current="
<<
pack
.
header
.
num
<<
" prev="
<<
prev_num
<<
endl
;
<<
" prev="
<<
prev_num
<<
" lost: "
<<
std
::
labs
(
pack
.
header
.
num
-
prev_num
)
<<
endl
;
prev_num
=
pack
.
header
.
num
;
prev_num
=
pack
.
header
.
num
;
}
}
...
...
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