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
dd5e3175
Commit
dd5e3175
authored
Aug 20, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(modbudtcptester): добавил функцию check - проверка соединения..
parent
0911007f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
+29
-6
mbtcptester.cc
Utilities/MBTester/mbtcptester.cc
+22
-5
libuniset2.spec
conf/libuniset2.spec
+4
-1
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+3
-0
No files found.
Utilities/MBTester/mbtcptester.cc
View file @
dd5e3175
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
#include <string>
#include <getopt.h>
#include "Debug.h"
...
...
@@ -29,6 +28,7 @@ static struct option longopts[] =
{
"persistent-connection"
,
no_argument
,
0
,
'o'
},
{
"num-cycles"
,
required_argument
,
0
,
'l'
},
{
"sleep-msec"
,
required_argument
,
0
,
's'
},
{
"check"
,
no_argument
,
0
,
'n'
},
{
NULL
,
0
,
0
,
0
}
};
...
...
@@ -60,6 +60,7 @@ static void print_help()
printf
(
"[-l|--num-cycles] num - Number of cycles of exchange. Default: -1 - infinitely.
\n
"
);
printf
(
"[-v|--verbose] - Print all messages to stdout
\n
"
);
printf
(
"[-s|--sleep-msec] - send pause. Default: 200 msec
\n
"
);
printf
(
"[-n|--check] - Check connection for (-i)ip (-p)port
\n
"
);
}
// --------------------------------------------------------------------------
enum
Command
...
...
@@ -75,12 +76,11 @@ enum Command
cmdWrite06
,
cmdWrite0F
,
cmdWrite10
,
cmdDiag
cmdDiag
,
cmdCheck
};
// --------------------------------------------------------------------------
static
char
*
checkArg
(
int
ind
,
int
argc
,
char
*
argv
[]
);
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
// std::ios::sync_with_stdio(false);
...
...
@@ -121,7 +121,7 @@ int main( int argc, char** argv )
try
{
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hva:w:z:r:x:c:b:d:s:t:p:i:ol:d:e:u:"
,
longopts
,
&
optindex
))
!=
-
1
)
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hv
n
a:w:z:r:x:c:b:d:s:t:p:i:ol:d:e:u:"
,
longopts
,
&
optindex
))
!=
-
1
)
{
switch
(
opt
)
{
...
...
@@ -137,6 +137,7 @@ int main( int argc, char** argv )
if
(
cmd
==
cmdNOP
)
cmd
=
cmdRead02
;
case
'r'
:
if
(
cmd
==
cmdNOP
)
cmd
=
cmdRead03
;
...
...
@@ -162,6 +163,10 @@ int main( int argc, char** argv )
}
break
;
case
'n'
:
cmd
=
cmdCheck
;
break
;
case
'e'
:
{
if
(
cmd
==
cmdNOP
)
...
...
@@ -601,6 +606,13 @@ int main( int argc, char** argv )
}
}
break
;
case
cmdCheck
:
{
bool
res
=
ModbusTCPMaster
::
checkConnection
(
iaddr
,
port
,
tout
);
cout
<<
iaddr
<<
":"
<<
port
<<
" connection "
<<
(
res
?
"OK"
:
"FAIL"
)
<<
endl
;
}
break
;
case
cmdNOP
:
default:
...
...
@@ -662,3 +674,8 @@ char* checkArg( int i, int argc, char* argv[] )
return
0
;
}
// --------------------------------------------------------------------------
void
ping
(
const
std
::
string
&
iaddr
,
int
port
)
{
cerr
<<
"ping2: check connection "
<<
ModbusTCPMaster
::
checkConnection
(
iaddr
,
port
,
1000
)
<<
endl
;
}
// --------------------------------------------------------------------------
conf/libuniset2.spec
View file @
dd5e3175
...
...
@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.1
Release: alt1
5.3
Release: alt1
6
Summary: UniSet - library for building distributed industrial control systems
...
...
@@ -456,6 +456,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Thu Aug 20 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt16
- (modbustcptest): add 'check' for connection
* Tue Aug 18 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt15.3
- minor build
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
dd5e3175
...
...
@@ -41,7 +41,10 @@ int ModbusTCPMaster::getNextData( unsigned char* buf, int len )
void
ModbusTCPMaster
::
setChannelTimeout
(
timeout_t
msec
)
{
if
(
tcp
)
{
tcp
->
setTimeout
(
msec
);
tcp
->
setKeepAliveParams
((
msec
>
1000
?
msec
/
1000
:
1
));
}
}
// -------------------------------------------------------------------------
mbErrCode
ModbusTCPMaster
::
sendData
(
unsigned
char
*
buf
,
int
len
)
...
...
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