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
ccbdc8a8
Commit
ccbdc8a8
authored
May 13, 2011
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил в утилиты тестирования возможность задать количество циклов обмена.
До этого была "безконечно" пока не прервёшь программу.
parent
8171aa11
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
10 deletions
+77
-10
mbrtutester.cc
Utilities/MBTester/mbrtutester.cc
+24
-5
mbtcptester.cc
Utilities/MBTester/mbtcptester.cc
+21
-2
unet2-tester.cc
extensions/UNet2/unet2-tester.cc
+32
-3
No files found.
Utilities/MBTester/mbrtutester.cc
View file @
ccbdc8a8
...
...
@@ -23,13 +23,14 @@ static struct option longopts[] = {
// { "writefile15", required_argument, 0, 'p' },
{
"filetransfer66"
,
required_argument
,
0
,
'u'
},
{
"timeout"
,
required_argument
,
0
,
't'
},
{
"autodetect-slave"
,
no_argument
,
0
,
'
l
'
},
{
"autodetect-slave"
,
no_argument
,
0
,
'
q
'
},
{
"autodetect-speed"
,
required_argument
,
0
,
'n'
},
{
"device"
,
required_argument
,
0
,
'd'
},
{
"verbose"
,
no_argument
,
0
,
'v'
},
{
"myaddr"
,
required_argument
,
0
,
'a'
},
{
"speed"
,
required_argument
,
0
,
's'
},
{
"use485F"
,
no_argument
,
0
,
'y'
},
{
"num-cycles"
,
required_argument
,
0
,
'q'
},
{
NULL
,
0
,
0
,
0
}
};
// --------------------------------------------------------------------------
...
...
@@ -61,6 +62,7 @@ static void print_help()
printf
(
"[-a|--myaddr] addr - Modbus address for master. Default: 0x01.
\n
"
);
printf
(
"[-s|--speed] speed - 9600,14400,19200,38400,57600,115200. Default: 38400.
\n
"
);
printf
(
"[-t|--timeout] msec - Timeout. Default: 2000.
\n
"
);
printf
(
"[-l|--num-cycles] num - Number of cycles of exchange. Default: -1 - infinitely.
\n
"
);
printf
(
"[-v|--verbose] - Print all messages to stdout
\n
"
);
}
// --------------------------------------------------------------------------
...
...
@@ -105,10 +107,11 @@ int main( int argc, char **argv )
DebugStream
dlog
;
string
tofile
(
""
);
int
use485
=
0
;
int
ncycles
=
-
1
;
try
{
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hva:w:z:m:r:x:c:b:d:s:t:
ln:u:y
"
,
longopts
,
&
optindex
))
!=
-
1
)
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hva:w:z:m:r:x:c:b:d:s:t:
qn:u:yl:
"
,
longopts
,
&
optindex
))
!=
-
1
)
{
switch
(
opt
)
{
...
...
@@ -255,7 +258,7 @@ int main( int argc, char **argv )
verb
=
1
;
break
;
case
'
l
'
:
case
'
q
'
:
{
if
(
cmd
==
cmdNOP
)
cmd
=
cmdDetectSlave
;
...
...
@@ -296,6 +299,10 @@ int main( int argc, char **argv )
fn
=
(
ModbusRTU
::
SlaveFunctionCode
)
UniSetTypes
::
uni_atoi
(
argv
[
optind
+
1
]);
}
break
;
case
'l'
:
ncycles
=
uni_atoi
(
optarg
);
break
;
case
'?'
:
default:
...
...
@@ -321,7 +328,11 @@ int main( int argc, char **argv )
mb
.
setSpeed
(
speed
);
mb
.
setLog
(
dlog
);
while
(
1
)
int
nc
=
1
;
if
(
ncycles
>
0
)
nc
=
ncycles
;
while
(
nc
)
{
try
{
...
...
@@ -578,7 +589,15 @@ int main( int argc, char **argv )
throw
ex
;
cout
<<
"timeout..."
<<
endl
;
}
}
if
(
ncycles
>
0
)
{
nc
--
;
if
(
nc
<=
0
)
break
;
}
msleep
(
200
);
}
}
...
...
Utilities/MBTester/mbtcptester.cc
View file @
ccbdc8a8
...
...
@@ -23,6 +23,7 @@ static struct option longopts[] = {
{
"myaddr"
,
required_argument
,
0
,
'a'
},
{
"port"
,
required_argument
,
0
,
'p'
},
{
"persistent-connection"
,
no_argument
,
0
,
'o'
},
{
"num-cycles"
,
required_argument
,
0
,
'l'
},
{
NULL
,
0
,
0
,
0
}
};
// --------------------------------------------------------------------------
...
...
@@ -42,6 +43,7 @@ static void print_help()
printf
(
"[-p|--port] port - Modbus server port. Default: 502.
\n
"
);
printf
(
"[-t|--timeout] msec - Timeout. Default: 2000.
\n
"
);
printf
(
"[-o|--persistent-connection] - Use persistent-connection.
\n
"
);
printf
(
"[-l|--num-cycles] num - Number of cycles of exchange. Default: -1 - infinitely.
\n
"
);
printf
(
"[-v|--verbose] - Print all messages to stdout
\n
"
);
}
// --------------------------------------------------------------------------
...
...
@@ -77,10 +79,11 @@ int main( int argc, char **argv )
ModbusRTU
::
ModbusAddr
slaveaddr
=
0x00
;
int
tout
=
2000
;
DebugStream
dlog
;
int
ncycles
=
-
1
;
try
{
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hva:w:z:r:x:c:b:d:s:t:p:i:o"
,
longopts
,
&
optindex
))
!=
-
1
)
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hva:w:z:r:x:c:b:d:s:t:p:i:o
l:
"
,
longopts
,
&
optindex
))
!=
-
1
)
{
switch
(
opt
)
{
...
...
@@ -182,6 +185,10 @@ int main( int argc, char **argv )
persist
=
true
;
break
;
case
'l'
:
ncycles
=
uni_atoi
(
optarg
);
break
;
case
'?'
:
default:
printf
(
"? argumnet
\n
"
);
...
...
@@ -216,7 +223,11 @@ int main( int argc, char **argv )
if
(
count
>
ModbusRTU
::
MAXDATALEN
&&
verb
)
cout
<<
"Too long packet! Max count="
<<
ModbusRTU
::
MAXDATALEN
<<
" (ignore...)"
<<
endl
;
while
(
1
)
int
nc
=
1
;
if
(
ncycles
>
0
)
nc
=
ncycles
;
while
(
nc
)
{
try
{
...
...
@@ -406,7 +417,15 @@ int main( int argc, char **argv )
cout
<<
"timeout..."
<<
endl
;
}
if
(
ncycles
>
0
)
{
nc
--
;
if
(
nc
<=
0
)
break
;
}
msleep
(
200
);
}
// end of while
mb
.
disconnect
();
...
...
extensions/UNet2/unet2-tester.cc
View file @
ccbdc8a8
...
...
@@ -19,6 +19,7 @@ static struct option longopts[] = {
{
"show-data"
,
no_argument
,
0
,
'd'
},
{
"check-lost"
,
no_argument
,
0
,
'l'
},
{
"verbode"
,
required_argument
,
0
,
'v'
},
{
"num-cycles"
,
required_argument
,
0
,
'z'
},
{
NULL
,
0
,
0
,
0
}
};
// --------------------------------------------------------------------------
...
...
@@ -62,8 +63,9 @@ int main(int argc, char* argv[])
size_t
count
=
50
;
bool
lost
=
false
;
bool
show
=
false
;
int
ncycles
=
-
1
;
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hs:c:r:p:n:t:x:blvd"
,
longopts
,
&
optindex
))
!=
-
1
)
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hs:c:r:p:n:t:x:blvd
z:
"
,
longopts
,
&
optindex
))
!=
-
1
)
{
switch
(
opt
)
{
...
...
@@ -80,6 +82,7 @@ int main(int argc, char* argv[])
cout
<<
"[-l|--check-lost] - Check the lost packets."
<<
endl
;
cout
<<
"[-v|--verbose] - verbose mode."
<<
endl
;
cout
<<
"[-d|--show-data] - show receive data."
<<
endl
;
cout
<<
"[-z|--num-cycles] num - Number of cycles of exchange. Default: -1 - infinitely."
<<
endl
;
cout
<<
endl
;
return
0
;
...
...
@@ -129,6 +132,10 @@ int main(int argc, char* argv[])
verb
=
1
;
break
;
case
'z'
:
ncycles
=
UniSetTypes
::
uni_atoi
(
optarg
);
break
;
case
'?'
:
default:
cerr
<<
"? argumnet"
<<
endl
;
...
...
@@ -184,7 +191,11 @@ int main(int argc, char* argv[])
UniSetUDP
::
UDPPacket
buf
;
unsigned
long
prev_num
=
1
;
while
(
1
)
int
nc
=
1
;
if
(
ncycles
>
0
)
nc
=
ncycles
;
while
(
nc
)
{
try
{
...
...
@@ -227,6 +238,13 @@ int main(int argc, char* argv[])
{
cerr
<<
"(recv): catch ..."
<<
endl
;
}
if
(
ncycles
>
0
)
{
nc
--
;
if
(
nc
<=
0
)
break
;
}
}
}
break
;
...
...
@@ -256,8 +274,12 @@ int main(int argc, char* argv[])
unsigned
long
packetnum
=
0
;
UniSetUDP
::
UDPPacket
s_buf
;
int
nc
=
1
;
if
(
ncycles
>
0
)
nc
=
ncycles
;
while
(
1
)
while
(
nc
)
{
mypack
.
num
=
packetnum
++
;
if
(
packetnum
>
UniSetUDP
::
MaxPacketNum
)
...
...
@@ -287,6 +309,13 @@ int main(int argc, char* argv[])
cerr
<<
"(send): catch ..."
<<
endl
;
}
if
(
ncycles
>
0
)
{
nc
--
;
if
(
nc
<=
0
)
break
;
}
usleep
(
usecpause
);
}
}
...
...
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