2015-01-20 13:14:51 +00:00
|
|
|
##
|
|
|
|
# Reset the target machine via softreset
|
|
|
|
#
|
|
|
|
# \param --power-on-softreset-host softreset host
|
|
|
|
# \param --power-on-softreset-port softreset port
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
proc power_on_softreset_host { } {
|
|
|
|
return [get_cmd_arg_first --power-on-softreset-host ""]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
proc power_on_softreset_port { } {
|
|
|
|
return [get_cmd_arg_first --power-on-softreset-port ""]
|
|
|
|
}
|
|
|
|
|
2015-05-13 11:56:40 +00:00
|
|
|
proc power_on_softreset_on { } {
|
|
|
|
return [get_cmd_arg_first --power-on-softreset-on ""]
|
|
|
|
}
|
|
|
|
|
|
|
|
proc power_on_softreset_off { } {
|
|
|
|
return [get_cmd_arg_first --power-on-softreset-off ""]
|
|
|
|
}
|
2015-01-20 13:14:51 +00:00
|
|
|
|
|
|
|
proc run_power_on { } {
|
|
|
|
set host [power_on_softreset_host]
|
|
|
|
set port [power_on_softreset_port]
|
2015-05-13 11:56:40 +00:00
|
|
|
set relay_on [power_on_softreset_on]
|
|
|
|
set relay_off [power_on_softreset_off]
|
2015-01-20 13:14:51 +00:00
|
|
|
|
|
|
|
if {[string equal $host ""]} {
|
|
|
|
puts "Aborting, softreset host not set."
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[string equal $port ""]} {
|
|
|
|
puts "Aborting, softreset port not set."
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
|
2015-05-13 11:56:40 +00:00
|
|
|
if {[string equal $relay_on ""]} {
|
|
|
|
puts "Aborting, softreset 'on' not set."
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[string equal $relay_off ""]} {
|
|
|
|
puts "Aborting, softreset 'off' not set."
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
|
2018-06-19 17:55:04 +00:00
|
|
|
set telnet [installed_command telnet]
|
2015-01-20 13:14:51 +00:00
|
|
|
|
|
|
|
spawn $telnet $host $port
|
|
|
|
set connection_id $spawn_id
|
|
|
|
|
2015-05-13 11:56:40 +00:00
|
|
|
send -i $connection_id "$relay_on\n"
|
2015-01-20 13:14:51 +00:00
|
|
|
sleep 1
|
2015-05-13 11:56:40 +00:00
|
|
|
send -i $connection_id "$relay_off\n"
|
2017-08-07 14:30:38 +00:00
|
|
|
sleep 1
|
|
|
|
close -i $connection_id
|
|
|
|
lassign [wait] pid spawnid os_error_flag value
|
|
|
|
|
|
|
|
if {$value} {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
2015-01-20 13:14:51 +00:00
|
|
|
}
|