XPS-Q8
Tcl Manual
Please see the sections:
4 Principle of a Tcl script redirection to a telnet session.
6 Proposed function for error handling.
7.13.3
TCL Code
# Set channel’s name to be used for telnet.
# In this example we assume it is passed to the script as the
# first argument, if not specified output to stdio.
# Open the channel for read mode and get its id,
# this is the id that will be passed to puts function.
if
{$tcl_argv(
0
) !=
0
} {
set
telnetOut [ open "/dev/$tcl_argv(
0
)" r+]
}
else
{
set
telnetOut stdout
}
# Initialization
set
TimeOut
20
set
code
0
set
group "SINGLE_AXIS"
# Open TCP socket
set
code [
catch
"
OpenConnection
$TimeOut socketID"]
if
{$code !=
0
} {
puts
$telnetOut "OpenConnection failed => $code"
flush
$telnetOut
}
else
{
# Recover the input arguments entered by the user
# In this case argument 0 is used for Telnet channel identifier
if
{$tcl_argc ==
4
} {
set
startpos $tcl_argv(
1
)
set
endpos $tcl_argv(
2
)
set
cycles $tcl_argv(
3
)
}
else
{
puts
$telnetOut "Wrong number of parameters, argument
1, 2 and 3 are needed"
flush
$telnetOut
set
code [
catch
"
TCP_CloseSocket
$socketID"]
return
}
# Kill group
set
code [
catch
"
GroupKill
$socketID $group"]
if
{$code !=
0
} {
DisplayErrorAndClose
$socketID $code "GroupKill" $telnetOut
return
EDH0307En1041 — 10/17
57