29 |
set result -1 |
set result -1 |
30 |
|
|
31 |
if [board_info $arg exists fileid] { |
if [board_info $arg exists fileid] { |
32 |
return [board_info $arg fileid]; |
return [board_info $arg fileid] |
33 |
} |
} |
34 |
|
|
35 |
# get the hostname and port number from the config array |
# get the hostname and port number from the config array |
47 |
} |
} |
48 |
|
|
49 |
if [board_info $arg exists fileid] { |
if [board_info $arg exists fileid] { |
50 |
unset board_info($arg,fileid); |
unset board_info($arg,fileid) |
51 |
} |
} |
52 |
# get the right version of rlogin |
# get the right version of rlogin |
53 |
if ![board_info $arg exists rlogin_prog] { |
if ![board_info $arg exists rlogin_prog] { |
54 |
set RLOGIN rlogin |
set RLOGIN rlogin |
55 |
} else { |
} else { |
56 |
set RLOGIN [board_info $arg rlogin_prog]; |
set RLOGIN [board_info $arg rlogin_prog] |
57 |
} |
} |
58 |
|
|
59 |
# start connection and store the spawn_id |
# start connection and store the spawn_id |
136 |
# |
# |
137 |
proc rlogin_spawn { dest cmdline } { |
proc rlogin_spawn { dest cmdline } { |
138 |
if ![board_info $dest exists shell_prompt] { |
if ![board_info $dest exists shell_prompt] { |
139 |
set shell_prompt "(^|\[\r\n\])\[^\r\n\]*>"; |
set shell_prompt "(^|\[\r\n\])\[^\r\n\]*>" |
140 |
} else { |
} else { |
141 |
set shell_prompt [board_info $dest shell_prompt]; |
set shell_prompt [board_info $dest shell_prompt] |
142 |
} |
} |
143 |
set prefix "" |
set prefix "" |
144 |
set ok 0; |
set ok 0 |
145 |
for {set i 0;} {$i <= 2 && ! $ok} {incr i;} { |
for {set i 0;} {$i <= 2 && ! $ok} {incr i;} { |
146 |
set shell_id [remote_open $dest]; |
set shell_id [remote_open $dest] |
147 |
if { $shell_id != "" && $shell_id > 0 } { |
if { $shell_id != "" && $shell_id > 0 } { |
148 |
remote_send $dest "echo k\r"; |
remote_send $dest "echo k\r" |
149 |
remote_expect $dest 20 { |
remote_expect $dest 20 { |
150 |
-re "\\(gdb\\)" { |
-re "\\(gdb\\)" { |
151 |
set shell_prompt "\\(gdb\\)"; |
set shell_prompt "\\(gdb\\)" |
152 |
# gdb uses 'shell command'. |
# gdb uses 'shell command'. |
153 |
set prefix "shell "; |
set prefix "shell " |
154 |
set ok 1; |
set ok 1 |
155 |
} |
} |
156 |
-re ".*$shell_prompt" { |
-re ".*$shell_prompt" { |
157 |
set ok 1; |
set ok 1 |
158 |
} |
} |
159 |
default { } |
default { } |
160 |
} |
} |
161 |
} |
} |
162 |
if { ! $ok } { |
if { ! $ok } { |
163 |
remote_close $dest; |
remote_close $dest |
164 |
remote_reboot $dest; |
remote_reboot $dest |
165 |
} |
} |
166 |
} |
} |
167 |
if { ! $ok } { |
if { ! $ok } { |
168 |
return "unable to start command" |
return "unable to start command" |
169 |
} else { |
} else { |
170 |
remote_send $dest "${prefix}${cmdline}\n"; |
remote_send $dest "${prefix}${cmdline}\n" |
171 |
return [board_info $dest fileid]; |
return [board_info $dest fileid] |
172 |
} |
} |
173 |
} |
} |