Mercurial > ecos-v3_0-branch
annotate packages/hal/synth/arch/current/host/console.tcl @ 332:7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
synthetic target.
| author | bartv |
|---|---|
| date | Sun, 15 Sep 2002 17:48:26 +0000 |
| parents | |
| children | 74dbf4c3f2e1 |
| 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 # ============================================================================ |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
10 # ####COPYRIGHTBEGIN#### |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
11 # |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
12 # ---------------------------------------------------------------------------- |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
13 # Copyright (C) 2002 Bart Veer |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
14 # |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
15 # This file is part of the eCos host tools. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
16 # |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
17 # This program is free software; you can redistribute it and/or modify it |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
18 # under the terms of the GNU General Public License as published by the Free |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
19 # Software Foundation; either version 2 of the License, or (at your option) |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
20 # any later version. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
21 # |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
22 # This program is distributed in the hope that it will be useful, but WITHOUT |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
23 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
24 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
25 # more details. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
26 # |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
27 # You should have received a copy of the GNU General Public License along with |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
28 # this program; if not, write to the Free Software Foundation, Inc., |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
29 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
30 # |
|
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 # |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
33 # ####COPYRIGHTEND#### |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
34 # ============================================================================ |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
35 # #####DESCRIPTIONBEGIN#### |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
36 # |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
37 # Author(s): bartv |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
38 # Contact(s): bartv |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
39 # Date: 2002/08/07 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
40 # Version: 0.01 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
41 # Description: |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
42 # 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
|
43 # be run from inside the ecosynth auxiliary. |
|
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 # ####DESCRIPTIONEND#### |
|
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 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
48 # }}} |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
49 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
50 # 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
|
51 # 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
|
52 # 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
|
53 # 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
|
54 # 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
|
55 # 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
|
56 # is to write some text. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
57 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
58 namespace eval ::console { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
59 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
60 variable _pending_output "" |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
61 variable filter_count 0 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
62 array set filters [list] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
63 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
64 proc instantiate { id name data } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
65 # 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
|
66 # cannot provide any initialization data. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
67 if { ("" != $name) || ("" != $data) } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
68 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
|
69 return "" |
|
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 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
72 # 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
|
73 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
74 # 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
|
75 # 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
|
76 # should always be consumed. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
77 set console_appearance "" |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
78 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
79 if { [synth::tdf_has_device "console"] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
80 if { [synth::tdf_has_option "console" "appearance"] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
81 set console_appearance [synth::tdf_get_option "console" "appearance"] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
82 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
83 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
84 if { [synth::tdf_has_option "console" "filter"] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
85 set tdf_filters [synth::tdf_get_options "console" "filter"] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
86 foreach filter $tdf_filters { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
87 if { 2 > [llength $filter] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
88 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
|
89 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
|
90 synth::report_error $msg |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
91 } else { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
92 # Attempt some minimal validation of the regexp |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
93 set name [lindex $filter 0] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
94 set regexp [lindex $filter 1] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
95 set error "" |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
96 if { [catch { regexp -- $regexp "Hello world\n" } error] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
97 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
|
98 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
|
99 synth::report_error $msg |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
100 } else { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
101 set ::console::filters($::console::filter_count,name) $name |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
102 set ::console::filters($::console::filter_count,regexp) $regexp |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
103 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
|
104 incr ::console::filter_count |
|
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 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
109 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
110 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
111 # 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
|
112 # any additional filters specified in the target definition file |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
113 # for e.g. trace output. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
114 if { $synth::flag_gui } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
115 if { [synth::filter_exists "console" ] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
116 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
|
117 } elseif { "" == $console_appearance } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
118 synth::filter_add "console" |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
119 } else { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
120 array set parsed_options [list] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
121 set message "" |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
122 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
|
123 synth::report_error \ |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
124 "Invalid entry in target definition file $synth::target_definition\ |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
125 \n synth_device \"console\", entry \"appearance\"\n$message" |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
126 } else { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
127 synth::filter_add_parsed "console" parsed_options |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
128 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
129 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
130 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
131 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
|
132 set name $::console::filters($i,name) |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
133 set appearance $::console::filters($i,appearance) |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
134 array unset parsed_options |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
135 array set parsed_options [list] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
136 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
137 if { [synth::filter_exists $name] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
138 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
|
139 } else { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
140 set message "" |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
141 if { ![synth::filter_parse_options $appearance parsed_options message] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
142 synth::report_error \ |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
143 "Invalid entry in target definition file $synth::target_definition\ |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
144 \n synth_device \"console\", entry filter $name\n$message" |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
145 } else { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
146 synth::filter_add_parsed $name parsed_options |
|
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 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
150 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
151 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
152 # 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
|
153 # to this device instance. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
154 return console::handle_request |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
155 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
156 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
157 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
|
158 # Unfortunately the main eCos diagnostic code assumes it is |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
159 # 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
|
160 # 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
|
161 # carriage returns which are best filtered out here. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
162 set reqdata [string map {"\r" " "} $reqdata] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
163 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
164 # 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
|
165 # easier to write the regexp filters. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
166 append console::_pending_output $reqdata |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
167 while { -1 != [string first "\n" $console::_pending_output] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
168 set regexp_matched 0 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
169 set index [string first "\n" $console::_pending_output] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
170 set line [string range $console::_pending_output 0 $index] |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
171 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
|
172 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
173 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
|
174 if { [regexp -- $console::filters($i,regexp) $line] } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
175 synth::output $line $console::filters($i,name) |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
176 set regexp_matched 1 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
177 } |
|
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 if { ! $regexp_matched } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
180 synth::output $line "console" |
|
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 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
183 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
184 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
185 # 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
|
186 # 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
|
187 # 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
|
188 # eCos. |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
189 proc _flush { arg_list } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
190 if { "" != $console::_pending_output } { |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
191 synth::output "$console::_pending_output\n" "console" |
|
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 synth::hook_add "ecos_exit" console::_flush |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
195 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
196 } |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
197 |
|
7c1c8dc43ba1
Now witness the firepower of this fully armed and operational
bartv
parents:
diff
changeset
|
198 return console::instantiate |
