Roman Iten 5ebcf36d69 tool/run: introduce '[have_]cmd_arg'-procs
Renaming 'get_cmd_switch' and 'get_cmd_arg' to 'have_cmd_arg' and
'cmd_arg' respectively blends in nicely with the now omnipresent pattern
with 'have_[spec|board|installed|include]'.

This commit deprecates 'get_cmd_switch' and 'get_cmd_arg', which will be
removed in a later commit.

Issue #5432
2025-02-24 16:39:20 +01:00

57 lines
1.4 KiB
Plaintext

##
# 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 [cmd_arg_first --power-on-netio-host 1]
}
proc power_on_netio_user { } {
return [cmd_arg_first --power-on-netio-user 1]
}
proc power_on_netio_password { } {
return [cmd_arg_first --power-on-netio-password 1]
}
proc power_on_netio_port { } {
return [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
}