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
a4348ede
Commit
a4348ede
authored
May 07, 2022
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(unet): minor fixes
parent
50b91c73
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 @
a4348ede
...
...
@@ -512,7 +512,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
}
}
// -----------------------------------------------------------------------------
void
UNetReceiver
::
checkConnection
()
bool
UNetReceiver
::
checkConnection
()
{
bool
tout
=
false
;
...
...
@@ -530,12 +530,21 @@ void UNetReceiver::checkConnection()
if
(
w
)
{
if
(
tout
)
slEvent
(
w
,
evTimeout
);
else
slEvent
(
w
,
evOK
);
try
{
if
(
tout
)
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
...
...
@@ -552,7 +561,10 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
// взводим таймер опять..
tm
.
again
();
// собственно обработка события
// смотрим есть ли связь..
bool
recvOk
=
checkConnection
();
// обновление данных в SM
try
{
update
();
...
...
@@ -562,16 +574,13 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
unetcrit
<<
myname
<<
"(updateEvent): "
<<
ex
.
what
()
<<
std
::
endl
;
}
// смотрим есть ли связь..
checkConnection
();
if
(
sidRespond
!=
DefaultObjectId
)
{
try
{
if
(
isInitOK
()
)
{
bool
r
=
respondInvert
?
!
isRecvOK
()
:
isRecvOK
()
;
bool
r
=
respondInvert
?
!
recvOk
:
recvOk
;
shm
->
localSetValue
(
itRespond
,
sidRespond
,
(
r
?
1
:
0
),
shm
->
ID
());
}
}
...
...
extensions/UNetUDP/UNetReceiver.h
View file @
a4348ede
...
...
@@ -189,7 +189,7 @@ namespace uniset
void
initIterators
()
noexcept
;
bool
createConnection
(
bool
throwEx
=
false
);
void
checkConnection
();
bool
checkConnection
();
size_t
rnext
(
size_t
num
);
private
:
...
...
extensions/UNetUDP/unet-udp-tester.cc
View file @
a4348ede
#include <cstdlib>
#include <errno.h>
#include <getopt.h>
#include <cstring>
#include <iostream>
...
...
@@ -68,7 +67,7 @@ int main(int argc, char* argv[])
int
verb
=
0
;
std
::
string
addr
=
""
;
int
port
=
0
;
int
usecpause
=
200000
0
;
int
usecpause
=
200000
;
timeout_t
tout
=
UniSetTimer
::
WaitUpTime
;
bool
broadcast
=
true
;
int
procID
=
1
;
...
...
@@ -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
<<
"[-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
<<
"[-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
;
return
0
;
...
...
@@ -255,7 +254,7 @@ int main(int argc, char* argv[])
continue
;
}
size_t
ret
=
udp
.
receiveBytes
(
&
pack
,
sizeof
(
pack
)
);
size_t
ret
=
udp
.
receiveBytes
(
&
pack
,
sizeof
(
pack
));
if
(
ret
<
0
)
{
...
...
@@ -281,7 +280,9 @@ int main(int argc, char* argv[])
{
if
(
prev_num
!=
(
pack
.
header
.
num
-
1
)
)
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
;
}
...
...
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