blob: 29743ad2d4c066c8a26665ba972a8094bd17d413 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/usr/bin/expect
#
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
set prompt "CrOS>"
set device "/dev/ttyUSB1"
set timeout -1
proc do_line { text } {
global prompt
set chars [split $text ""]
if { [lindex $chars 0] == "#" } { return }
for {set index 0} {$index < [llength $chars]} {incr index 1} {
set char [lindex $chars $index]
send -- $char
expect {
-ex $char {}
timeout { abort }
}
}
send "\r"
expect {
"$prompt" {}
timeout { abort }
}
}
send_user "SPAWNING /dev/ttyUSB CONSOLE SESSION....\n"
set port [open $device "r+"]
spawn -open $port
fconfigure $port -mode 115200,n,8,1
send "\r"
expect {
"Hit any key to stop autoboot:" {
send "\r"
expect "$prompt" {}
}
"$prompt" {}
}
set text_file [lindex $argv 0]
set data_source [open $text_file "r"]
set timeout 1
while {[gets $data_source line] != -1} {
do_line $line
}
interact {
\001 exit
}
send_user "\r"
|