1
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2
# 2001, 2002, 2003 Free Software Foundation, Inc.
4
# This file is part of DejaGnu.
6
# DejaGnu is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# DejaGnu is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with DejaGnu; if not, write to the Free Software Foundation,
18
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
# Connect to DEST using Kermit. Note that we're just using Kermit as a
21
# simple serial or network connect program; we don't actually use Kermit
22
# protocol to do downloads.
24
# Returns -1 if it failed, otherwise it returns the spawn_id.
26
proc kermit_open {dest args} {
30
if [board_info $dest exists name] {
31
set dest [board_info $dest name]
33
if [board_info ${dest} exists serial] {
34
set port [board_info ${dest} serial]
35
set device "-l [board_info ${dest} serial]"
36
if [board_info ${dest} exists baud] {
37
append device " -b [board_info ${dest} baud]"
40
set port [board_info ${dest} netport]
41
set device "-j [board_info ${dest} netport]"
46
verbose "kermit $device"
47
eval spawn kermit $device
49
perror "invalid spawn id from Kermit"
57
-re "Connecting to.*$port.*Type the escape character followed by C to.*options.*\[\r\n\]$" {
58
verbose "Got prompt\n"
63
warning "Never got prompt from Kermit."
72
-re "Connection Closed.*$" {
73
perror "Never connected."
81
warning "Timed out trying to connect."
91
perror "Couldn't connect after $tries tries."
92
if [info exists board_info($dest,fileid)] {
93
unset board_info($dest,fileid)
97
verbose "Kermit connection established with spawn_id $spawn_id."
98
set board_info($dest,fileid) $spawn_id
99
kermit_command $dest "set file type binary" "set transfer display none"
100
if [board_info $dest exists transmit_pause] {
101
kermit_command $dest "set transmit pause [board_info $dest transmit_pause]"
107
# Send a list of commands to the Kermit session connected to DEST.
109
proc kermit_command {dest args} {
110
if [board_info $dest exists name] {
111
set dest [board_info $dest name]
113
set shell_id [board_info $dest fileid]
115
# Sometimes we have to send multiple ^\c sequences. Don't know
118
for {set i 1} {$i <= 5} {incr i} {
119
send -i $shell_id "c"
121
-i $shell_id -re ".*Back at.*ermit.*>.*$" {set i 10}
122
-i $shell_id timeout {
124
warning "Unable to get prompt from kermit."
129
foreach command $args {
131
send -i $shell_id "${command}\r"
133
-i $shell_id -re ".*ermit.*>.*$" { }
134
-i $shell_id timeout {
135
perror "Response failed from Kermit."
140
send -i $shell_id "c\r"
142
-i $shell_id -re ".*other options.\[\r\n\]+" { }
143
-i $shell_id timeout {
144
perror "Unable to resume Kermit connection."
151
# Send STRING to DEST.
153
proc kermit_send {dest string args} {
154
if [board_info $dest exists transmit_pause] {
155
set f [open "/tmp/fff" "w"]
156
puts -nonewline $f "$string"
158
set result [remote_transmit $dest /tmp/fff]
159
remote_file build delete "/tmp/fff"
162
return [standard_send $dest $string]
166
# Transmit FILE directly to DEST as raw data.
167
# No translation is performed.
169
proc kermit_transmit {dest file args} {
170
if [board_info $dest exists transmit_pause] {
171
kermit_command $dest "transmit $file"
174
return [standard_transmit $dest $file]