annotate packages/hal/synth/arch/current/host/console.tcl @ 2863:7d8c61e6225c default tip

* Added execute permissions to files missed in conversion from CVS
author alexs
date Thu, 26 Mar 2009 20:39:18 +0000
parents 74dbf4c3f2e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
332
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
1 # {{{ Banner
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
2
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
3 # ============================================================================
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
4 #
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
5 # console.tcl
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
6 #
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
7 # Console output support for the eCos synthetic target I/O auxiliary
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
8 #
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
9 # ============================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
10 # ####ECOSHOSTGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
11 # -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
12 # This file is part of the eCos host tools.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
13 # Copyright (C) 2002 Free Software Foundation, Inc.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
14 #
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
15 # This program is free software; you can redistribute it and/or modify
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
16 # it under the terms of the GNU General Public License as published by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
17 # the Free Software Foundation; either version 2 or (at your option) any
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
18 # later version.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
19 #
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
20 # This program is distributed in the hope that it will be useful, but
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
21 # WITHOUT ANY WARRANTY; without even the implied warranty of
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
23 # General Public License for more details.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
24 #
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
25 # You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
26 # along with this program; if not, write to the
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
27 # Free Software Foundation, Inc., 51 Franklin Street,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
28 # Fifth Floor, Boston, MA 02110-1301, USA.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
29 # -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 332
diff changeset
30 # ####ECOSHOSTGPLCOPYRIGHTEND####
332
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
31 # ============================================================================
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
32 # #####DESCRIPTIONBEGIN####
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
33 #
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
34 # Author(s): bartv
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
35 # Contact(s): bartv
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
36 # Date: 2002/08/07
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
37 # Version: 0.01
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
38 # Description:
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
39 # Implementation of the console device. This script should only ever
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
40 # be run from inside the ecosynth auxiliary.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
41 #
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
42 # ####DESCRIPTIONEND####
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
43 # ============================================================================
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
44
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
45 # }}}
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
46
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
47 # The console device is pretty simple. There can only ever be one
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
48 # instance of the console, and it does not take any initialization
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
49 # data from the target or from command-line arguments. It does
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
50 # look for entries in the target definition file, to set up
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
51 # colours for console output, and to install additional regexp-based
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
52 # filters. The only type of request that can go to the console device
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
53 # is to write some text.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
54
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
55 namespace eval ::console {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
56
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
57 variable _pending_output ""
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
58 variable filter_count 0
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
59 array set filters [list]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
60
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
61 proc instantiate { id name data } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
62 # There is only console so no name is expected, and the target
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
63 # cannot provide any initialization data.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
64 if { ("" != $name) || ("" != $data) } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
65 synth::report_error "The target has passed invalid data when instantiating the console device.\n"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
66 return ""
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
67 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
68
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
69 # There are no command line arguments to be processed and consumed.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
70
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
71 # Look for and consume target definition entries related to the console.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
72 # These are only actually applicable when running in GUI mode, but
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
73 # should always be consumed.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
74 set console_appearance ""
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
75
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
76 if { [synth::tdf_has_device "console"] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
77 if { [synth::tdf_has_option "console" "appearance"] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
78 set console_appearance [synth::tdf_get_option "console" "appearance"]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
79 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
80
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
81 if { [synth::tdf_has_option "console" "filter"] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
82 set tdf_filters [synth::tdf_get_options "console" "filter"]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
83 foreach filter $tdf_filters {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
84 if { 2 > [llength $filter] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
85 set msg "Invalid entry in target definition file $synth::target_definition\n"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
86 append msg " Device console, option filter takes at least two arguments, a name and a regular expression.\n"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
87 synth::report_error $msg
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
88 } else {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
89 # Attempt some minimal validation of the regexp
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
90 set name [lindex $filter 0]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
91 set regexp [lindex $filter 1]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
92 set error ""
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
93 if { [catch { regexp -- $regexp "Hello world\n" } error] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
94 set msg "Invalid entry in target definition file $synth::target_definition\n"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
95 append msg " Device console, filter $name, invalid regular expression\n $error\n"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
96 synth::report_error $msg
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
97 } else {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
98 set ::console::filters($::console::filter_count,name) $name
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
99 set ::console::filters($::console::filter_count,regexp) $regexp
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
100 set ::console::filters($::console::filter_count,appearance) [lrange $filter 2 end]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
101 incr ::console::filter_count
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
102 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
103 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
104 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
105 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
106 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
107
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
108 # If the GUI is enabled then set up a filter for the console, and
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
109 # any additional filters specified in the target definition file
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
110 # for e.g. trace output.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
111 if { $synth::flag_gui } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
112 if { [synth::filter_exists "console" ] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
113 synth::report_warning "The console device script [info script] cannot create a filter for \"console\".\nThis filter already exists.\n"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
114 } elseif { "" == $console_appearance } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
115 synth::filter_add "console"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
116 } else {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
117 array set parsed_options [list]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
118 set message ""
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
119 if { ![synth::filter_parse_options $console_appearance parsed_options message] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
120 synth::report_error \
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
121 "Invalid entry in target definition file $synth::target_definition\
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
122 \n synth_device \"console\", entry \"appearance\"\n$message"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
123 } else {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
124 synth::filter_add_parsed "console" parsed_options
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
125 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
126 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
127
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
128 for { set i 0 } { $i < $::console::filter_count } { incr i } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
129 set name $::console::filters($i,name)
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
130 set appearance $::console::filters($i,appearance)
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
131 array unset parsed_options
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
132 array set parsed_options [list]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
133
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
134 if { [synth::filter_exists $name] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
135 synth::report_warning "The console device script [info script] cannot create a filter for \"$name\".\nThis filter already exists.\n"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
136 } else {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
137 set message ""
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
138 if { ![synth::filter_parse_options $appearance parsed_options message] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
139 synth::report_error \
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
140 "Invalid entry in target definition file $synth::target_definition\
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
141 \n synth_device \"console\", entry filter $name\n$message"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
142 } else {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
143 synth::filter_add_parsed $name parsed_options
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
144 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
145 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
146 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
147 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
148
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
149 # An instantiation function should return a handler for further requests
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
150 # to this device instance.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
151 return console::handle_request
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
152 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
153
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
154 proc handle_request { id reqcode arg1 arg2 reqdata reqlen reply_len } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
155 # Unfortunately the main eCos diagnostic code assumes it is
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
156 # talking to a tty in raw mode, since typically the output
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
157 # will go via the gdb output window. Hence it will have inserted
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
158 # carriage returns which are best filtered out here.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
159 set reqdata [string map {"\r" " "} $reqdata]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
160
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
161 # The output should be processed one line at a time, to make it
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
162 # easier to write the regexp filters.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
163 append console::_pending_output $reqdata
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
164 while { -1 != [string first "\n" $console::_pending_output] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
165 set regexp_matched 0
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
166 set index [string first "\n" $console::_pending_output]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
167 set line [string range $console::_pending_output 0 $index]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
168 set ::console::_pending_output [string range $console::_pending_output [expr $index + 1] end]
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
169
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
170 for { set i 0 } { !$regexp_matched && ($i < $console::filter_count) } { incr i } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
171 if { [regexp -- $console::filters($i,regexp) $line] } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
172 synth::output $line $console::filters($i,name)
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
173 set regexp_matched 1
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
174 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
175 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
176 if { ! $regexp_matched } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
177 synth::output $line "console"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
178 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
179 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
180 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
181
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
182 # Deal with the case where eCos has exited after sending only part
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
183 # of a line, which is still pending. In practice this has no
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
184 # effect at present because the data is still buffered inside
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
185 # eCos.
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
186 proc _flush { arg_list } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
187 if { "" != $console::_pending_output } {
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
188 synth::output "$console::_pending_output\n" "console"
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
189 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
190 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
191 synth::hook_add "ecos_exit" console::_flush
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
192
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
193 }
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
194
7c1c8dc43ba1 Now witness the firepower of this fully armed and operational
bartv
parents:
diff changeset
195 return console::instantiate