XPS-Q8
Tcl Manual
# in the telnet window when using APIs
# TCLScriptExecuteAndWait or
# TCLScriptExecuteAndWait
puts
$telnetOut "$APIName ERROR => $code : TCP timeout"
# Force transfer to channel’s output buffer
flush
$telnetOut
# in the web terminal when using API
# TclScriptExecuteAndWait
set
tcl_argv(
0
) "$APIName ERROR => $code : TCP timeout"
}
# Close TCP socket
set
code2 [
catch
"TCP_CloseSocket $socketID"]
return
}
##########################################
#
Main process #
##########################################
# 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
}
# Open socket
set
TimeOut
60
set
groupName "SingleAxis1"
set
code [catch "
OpenConnection
$TimeOut socketID"]
if
{$code !=
0
} {
puts
$telnetOut "
OpenConnection
failed => $code"
# Force transfer to channel’s output buffer
flush
$telnetOut
}
else
{
# Get firmware version
set
code [catch "
GroupInitialize
$socketID $groupName"]
if
{$code !=
0
} {
# Get error description
DisplayErrorAndClose
$socketID $code "GroupInitialize"
$telnetOut
}
# Close TCP socket
set
code [catch "TCP_CloseSocket $socketID"]
if
{$code !=
0
} {
puts
$telnetOut "TCP socket $socketID failed => $code"
# Force transfer to channel’s output buffer
flush
$telnetOut
}
EDH0307En1041 — 10/17
21