genode/tool/run/power_on/netio

57 lines
1.4 KiB
Plaintext
Raw Normal View History

##
# Reset the target machine via NETIO4/NETIO230 powerplug by Koukaam
#
# \param --power-on-netio-host network address of device
# \param --power-on-netio-user user for device
# \param --power-on-netio-password password for device
# \param --power-on-netio-port target port of device
#
source [genode_dir]/tool/run/power_netio.inc
proc power_on_netio_host { } {
return [get_cmd_arg_first --power-on-netio-host 1]
}
proc power_on_netio_user { } {
return [get_cmd_arg_first --power-on-netio-user 1]
}
proc power_on_netio_password { } {
return [get_cmd_arg_first --power-on-netio-password 1]
}
proc power_on_netio_port { } {
return [get_cmd_arg_first --power-on-netio-port 1]
}
proc run_power_on { } {
set host [power_on_netio_host]
set user_name [power_on_netio_user]
set password [power_on_netio_password]
set power_port [power_on_netio_port]
set connection_id [power_netio_connect $host $user_name $password]
send -i $connection_id "port $power_port\n"
expect -i $connection_id -re {250 [0-9]+.*\n}
regexp -all {[0-9]+} $expect_out(0,string) power_status
if {!$power_status} {
puts "port $power_port is off - switching it on"
send -i $connection_id "port $power_port 1\n"
expect -i $connection_id "250 OK"
} else {
puts "port $power_port is on - reset port"
send -i $connection_id "port $power_port int\n"
expect -i $connection_id "250 OK"
}
return true
}