genode/tool/run/power_on/softreset

70 lines
1.4 KiB
Plaintext
Raw Normal View History

##
# 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 ""]
}
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 ""]
}
proc run_power_on { } {
set host [power_on_softreset_host]
set port [power_on_softreset_port]
set relay_on [power_on_softreset_on]
set relay_off [power_on_softreset_off]
if {[string equal $host ""]} {
puts "Aborting, softreset host not set."
exit -1
}
if {[string equal $port ""]} {
puts "Aborting, softreset port not set."
exit -1
}
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
}
set telnet [installed_command telnet]
spawn $telnet $host $port
set connection_id $spawn_id
send -i $connection_id "$relay_on\n"
sleep 1
send -i $connection_id "$relay_off\n"
sleep 1
close -i $connection_id
lassign [wait] pid spawnid os_error_flag value
if {$value} {
return false
}
return true
}