| 1 |
2 |
olivier.gi |
#!/usr/bin/wish
|
| 2 |
|
|
#------------------------------------------------------------------------------
|
| 3 |
|
|
# Copyright (C) 2001 Authors
|
| 4 |
|
|
#
|
| 5 |
|
|
# This source file may be used and distributed without restriction provided
|
| 6 |
|
|
# that this copyright statement is not removed from the file and that any
|
| 7 |
|
|
# derivative work contains the original copyright notice and the associated
|
| 8 |
|
|
# disclaimer.
|
| 9 |
|
|
#
|
| 10 |
|
|
# This source file is free software; you can redistribute it and/or modify
|
| 11 |
|
|
# it under the terms of the GNU Lesser General Public License as published
|
| 12 |
|
|
# by the Free Software Foundation; either version 2.1 of the License, or
|
| 13 |
|
|
# (at your option) any later version.
|
| 14 |
|
|
#
|
| 15 |
|
|
# This source is distributed in the hope that it will be useful, but WITHOUT
|
| 16 |
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 17 |
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
| 18 |
|
|
# License for more details.
|
| 19 |
|
|
#
|
| 20 |
|
|
# You should have received a copy of the GNU Lesser General Public License
|
| 21 |
|
|
# along with this source; if not, write to the Free Software Foundation,
|
| 22 |
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 23 |
|
|
#
|
| 24 |
|
|
#------------------------------------------------------------------------------
|
| 25 |
|
|
#
|
| 26 |
|
|
# File Name: server.tcl
|
| 27 |
|
|
#
|
| 28 |
15 |
olivier.gi |
# Author(s):
|
| 29 |
|
|
# - Olivier Girard, olgirard@gmail.com
|
| 30 |
|
|
#
|
| 31 |
2 |
olivier.gi |
#------------------------------------------------------------------------------
|
| 32 |
15 |
olivier.gi |
# $Rev: 198 $
|
| 33 |
|
|
# $LastChangedBy: olivier.girard $
|
| 34 |
|
|
# $LastChangedDate: 2014-10-07 21:30:05 +0200 (Tue, 07 Oct 2014) $
|
| 35 |
|
|
#------------------------------------------------------------------------------
|
| 36 |
2 |
olivier.gi |
|
| 37 |
|
|
global clients
|
| 38 |
|
|
global server
|
| 39 |
|
|
|
| 40 |
172 |
olivier.gi |
global CpuNr
|
| 41 |
|
|
set CpuNr 0
|
| 42 |
2 |
olivier.gi |
|
| 43 |
172 |
olivier.gi |
|
| 44 |
2 |
olivier.gi |
###############################################################################
|
| 45 |
|
|
# #
|
| 46 |
|
|
# START/STOP LOCAL SERVER #
|
| 47 |
|
|
# #
|
| 48 |
|
|
###############################################################################
|
| 49 |
|
|
|
| 50 |
172 |
olivier.gi |
proc startServer { CpuNr } {
|
| 51 |
|
|
global server
|
| 52 |
2 |
olivier.gi |
|
| 53 |
172 |
olivier.gi |
if {![info exists server($CpuNr,socket)]} {
|
| 54 |
|
|
putsLog "CORE $CpuNr: Open socket on port $server($CpuNr,port)... " 1
|
| 55 |
|
|
if {[catch {socket -server "clientAccept $CpuNr" $server($CpuNr,port)} server($CpuNr,socket)]} {
|
| 56 |
158 |
olivier.gi |
putsLog "failed"
|
| 57 |
172 |
olivier.gi |
putsLog "CORE $CpuNr: ERROR: $server($CpuNr,socket)."
|
| 58 |
|
|
unset server($CpuNr,socket)
|
| 59 |
158 |
olivier.gi |
return 0
|
| 60 |
|
|
}
|
| 61 |
|
|
putsLog "done"
|
| 62 |
172 |
olivier.gi |
putsLog "CORE $CpuNr: INFO: Waiting on TCP port $server($CpuNr,port)"
|
| 63 |
2 |
olivier.gi |
} else {
|
| 64 |
172 |
olivier.gi |
putsLog "CORE $CpuNr: Server is already up and running."
|
| 65 |
2 |
olivier.gi |
}
|
| 66 |
|
|
return 1
|
| 67 |
|
|
}
|
| 68 |
|
|
|
| 69 |
172 |
olivier.gi |
proc stopAllServers { } {
|
| 70 |
158 |
olivier.gi |
global omsp_info
|
| 71 |
2 |
olivier.gi |
global server
|
| 72 |
172 |
olivier.gi |
global omsp_nr
|
| 73 |
2 |
olivier.gi |
|
| 74 |
172 |
olivier.gi |
for { set CpuNr 0 } { $CpuNr < $omsp_nr } { incr CpuNr } {
|
| 75 |
|
|
|
| 76 |
|
|
if {[info exists server($CpuNr,socket)]} {
|
| 77 |
|
|
set port [lindex [fconfigure $server($CpuNr,socket) -sockname] 2]
|
| 78 |
|
|
putsLog "CORE $CpuNr: Stop server (port $port)"
|
| 79 |
|
|
close $server($CpuNr,socket)
|
| 80 |
|
|
unset server($CpuNr,socket)
|
| 81 |
|
|
}
|
| 82 |
|
|
if {$omsp_info($CpuNr,connected)} {
|
| 83 |
|
|
ReleaseDevice $CpuNr 0xfffe
|
| 84 |
|
|
}
|
| 85 |
2 |
olivier.gi |
}
|
| 86 |
|
|
}
|
| 87 |
|
|
|
| 88 |
172 |
olivier.gi |
proc clientAccept {CpuNr sock addr port} {
|
| 89 |
2 |
olivier.gi |
global clients
|
| 90 |
|
|
|
| 91 |
172 |
olivier.gi |
putsLog "CORE $CpuNr: Accept client: $addr ($port)\n"
|
| 92 |
2 |
olivier.gi |
|
| 93 |
172 |
olivier.gi |
set clients($CpuNr,addr,$sock) [list $addr $port]
|
| 94 |
2 |
olivier.gi |
fconfigure $sock -buffering none
|
| 95 |
172 |
olivier.gi |
fileevent $sock readable [list receiveRSPpacket $CpuNr $sock]
|
| 96 |
2 |
olivier.gi |
|
| 97 |
158 |
olivier.gi |
InitBreakUnits $CpuNr
|
| 98 |
2 |
olivier.gi |
}
|
| 99 |
|
|
|
| 100 |
|
|
proc startServerGUI { } {
|
| 101 |
158 |
olivier.gi |
global omsp_conf
|
| 102 |
110 |
olivier.gi |
global omsp_info
|
| 103 |
172 |
olivier.gi |
global omsp_nr
|
| 104 |
|
|
global breakSelect
|
| 105 |
2 |
olivier.gi |
|
| 106 |
172 |
olivier.gi |
# Connect to all devices
|
| 107 |
|
|
set connection_status 0
|
| 108 |
|
|
set connection_sum 0
|
| 109 |
|
|
for { set CpuNr 0 } { $CpuNr < $omsp_nr } { incr CpuNr } {
|
| 110 |
|
|
set connection_ok [GetDevice $CpuNr]
|
| 111 |
|
|
set connection_sum [expr $connection_sum + $connection_ok]
|
| 112 |
|
|
if {$connection_ok==0} {
|
| 113 |
|
|
set error_nr "$CpuNr"
|
| 114 |
|
|
}
|
| 115 |
2 |
olivier.gi |
}
|
| 116 |
172 |
olivier.gi |
if {$connection_sum==$omsp_nr} {
|
| 117 |
|
|
set connection_status 1
|
| 118 |
|
|
}
|
| 119 |
2 |
olivier.gi |
|
| 120 |
172 |
olivier.gi |
if {!$connection_status} {
|
| 121 |
|
|
.info.cpu.con configure -text "Connection problem" -fg red
|
| 122 |
|
|
putsLog ""
|
| 123 |
|
|
putsLog "ERROR: Could not connect to Core $error_nr"
|
| 124 |
|
|
putsLog ""
|
| 125 |
|
|
putsLog " -----------------------------------------------------------------------"
|
| 126 |
|
|
putsLog " !!!! Please consider the following options: !!!!"
|
| 127 |
|
|
putsLog " !!!! !!!!"
|
| 128 |
|
|
putsLog " !!!! - make sure \"$omsp_conf(device)\" is the right device."
|
| 129 |
198 |
olivier.gi |
putsLog " !!!! - check permissions of the \"$omsp_conf(device)\" device (run as root if necessary)."
|
| 130 |
172 |
olivier.gi |
putsLog " !!!! - check the physical connection to the board. !!!!"
|
| 131 |
|
|
putsLog " !!!! - adjust the serial connection baudrate. !!!!"
|
| 132 |
|
|
putsLog " !!!! - for UART, don't forget to reset the serial debug interface !!!!"
|
| 133 |
|
|
putsLog " !!!! between each attempt. !!!!"
|
| 134 |
|
|
putsLog " !!!! - for I2C, make sure $omsp_conf($error_nr,cpuaddr) the is the right address. !!!!"
|
| 135 |
|
|
putsLog " -----------------------------------------------------------------------"
|
| 136 |
|
|
putsLog ""
|
| 137 |
|
|
return 0
|
| 138 |
|
|
}
|
| 139 |
|
|
|
| 140 |
|
|
if {$breakSelect==1} {
|
| 141 |
|
|
if {$omsp_info(0,hw_break)==0} {
|
| 142 |
|
|
.info.cpu.con configure -text "No Hardware breakpoint unit detected" -fg red
|
| 143 |
|
|
putsLog ""
|
| 144 |
|
|
putsLog "ERROR: Could not detect any Hardware Breakpoint Unit"
|
| 145 |
|
|
putsLog " Consider switching to the Software Breakpoint configuration"
|
| 146 |
|
|
putsLog ""
|
| 147 |
|
|
return 0
|
| 148 |
|
|
}
|
| 149 |
|
|
}
|
| 150 |
|
|
|
| 151 |
|
|
if {$omsp_info(0,alias)==""} {
|
| 152 |
158 |
olivier.gi |
.info.cpu.con configure -text "Connected" -fg "\#00ae00"
|
| 153 |
110 |
olivier.gi |
} else {
|
| 154 |
172 |
olivier.gi |
.info.cpu.con configure -text "Connected to $omsp_info(0,alias)" -fg "\#00ae00"
|
| 155 |
110 |
olivier.gi |
}
|
| 156 |
|
|
|
| 157 |
2 |
olivier.gi |
# Display info
|
| 158 |
|
|
putsLog "INFO: Sucessfully connected with the openMSP430 target."
|
| 159 |
172 |
olivier.gi |
set sizes [GetCPU_ID_SIZE 0]
|
| 160 |
|
|
if {$omsp_info(0,asic)} {
|
| 161 |
|
|
putsLog "INFO: CPU Version - $omsp_info(0,cpu_ver) / ASIC"
|
| 162 |
110 |
olivier.gi |
} else {
|
| 163 |
172 |
olivier.gi |
putsLog "INFO: CPU Version - $omsp_info(0,cpu_ver) / FPGA"
|
| 164 |
110 |
olivier.gi |
}
|
| 165 |
172 |
olivier.gi |
putsLog "INFO: User Version - $omsp_info(0,user_ver)"
|
| 166 |
|
|
if {$omsp_info(0,cpu_ver)==1} {
|
| 167 |
158 |
olivier.gi |
putsLog "INFO: Hardware Multiplier - --"
|
| 168 |
172 |
olivier.gi |
} elseif {$omsp_info(0,mpy)} {
|
| 169 |
158 |
olivier.gi |
putsLog "INFO: Hardware Multiplier - Yes"
|
| 170 |
110 |
olivier.gi |
} else {
|
| 171 |
158 |
olivier.gi |
putsLog "INFO: Hardware Multiplier - No"
|
| 172 |
110 |
olivier.gi |
}
|
| 173 |
172 |
olivier.gi |
putsLog "INFO: Program Memory Size - $omsp_info(0,pmem_size) B"
|
| 174 |
|
|
putsLog "INFO: Data Memory Size - $omsp_info(0,dmem_size) B"
|
| 175 |
|
|
putsLog "INFO: Peripheral Address Space - $omsp_info(0,per_size) B"
|
| 176 |
|
|
putsLog "INFO: $omsp_info(0,hw_break) Hardware Break/Watch-point unit(s) detected"
|
| 177 |
110 |
olivier.gi |
putsLog ""
|
| 178 |
2 |
olivier.gi |
|
| 179 |
87 |
olivier.gi |
# Activate Load TCL script section
|
| 180 |
|
|
.tclscript.ft.l configure -state normal
|
| 181 |
|
|
.tclscript.ft.file configure -state normal
|
| 182 |
|
|
.tclscript.ft.browse configure -state normal
|
| 183 |
|
|
.tclscript.fb.read configure -state normal
|
| 184 |
|
|
|
| 185 |
110 |
olivier.gi |
# Activate extra cpu info button
|
| 186 |
|
|
.info.cpu.more configure -state normal
|
| 187 |
|
|
|
| 188 |
172 |
olivier.gi |
for { set CpuNr 0 } { $CpuNr < $omsp_nr } { incr CpuNr } {
|
| 189 |
2 |
olivier.gi |
|
| 190 |
172 |
olivier.gi |
# Reset & Stop CPU
|
| 191 |
|
|
ExecutePOR_Halt $CpuNr
|
| 192 |
|
|
|
| 193 |
|
|
# Start server for GDB
|
| 194 |
|
|
if {![startServer $CpuNr]} {
|
| 195 |
|
|
.info.server.con configure -text "Connection problem" -fg red
|
| 196 |
|
|
return 0
|
| 197 |
|
|
}
|
| 198 |
2 |
olivier.gi |
}
|
| 199 |
172 |
olivier.gi |
|
| 200 |
110 |
olivier.gi |
.info.server.con configure -text "Running" -fg "\#00ae00"
|
| 201 |
2 |
olivier.gi |
|
| 202 |
|
|
# Disable gui entries
|
| 203 |
158 |
olivier.gi |
.connect.cfg.if.config1.adapter.p1 configure -state disabled
|
| 204 |
|
|
.connect.cfg.if.config2.adapter.p2 configure -state disabled
|
| 205 |
|
|
.connect.cfg.if.config1.serial_port.p1 configure -state disabled
|
| 206 |
|
|
.connect.cfg.if.config2.serial_port.p2 configure -state disabled
|
| 207 |
198 |
olivier.gi |
.connect.start.comp_mode configure -state disabled
|
| 208 |
158 |
olivier.gi |
.connect.cfg.ad.server_port.p0 configure -state disabled
|
| 209 |
|
|
.connect.cfg.ad.server_port.p1 configure -state disabled
|
| 210 |
|
|
.connect.cfg.ad.server_port.p2 configure -state disabled
|
| 211 |
|
|
.connect.cfg.ad.server_port.p3 configure -state disabled
|
| 212 |
|
|
.connect.cfg.ad.i2c_addr.s0 configure -state disabled
|
| 213 |
|
|
.connect.cfg.ad.i2c_addr.s1 configure -state disabled
|
| 214 |
|
|
.connect.cfg.ad.i2c_addr.s2 configure -state disabled
|
| 215 |
|
|
.connect.cfg.ad.i2c_addr.s3 configure -state disabled
|
| 216 |
|
|
.connect.cfg.ad.i2c_nr.s configure -state disabled
|
| 217 |
172 |
olivier.gi |
|
| 218 |
|
|
.connect.cfg.ad.i2c_nr.f.soft.b configure -state disabled
|
| 219 |
|
|
.connect.cfg.ad.i2c_nr.f.soft.r configure -state disabled
|
| 220 |
|
|
.connect.cfg.ad.i2c_nr.f.hard.r configure -state disabled
|
| 221 |
|
|
if {[winfo exists .omsp_sft_brk]} {
|
| 222 |
|
|
.omsp_sft_brk.map.b.share configure -state disabled
|
| 223 |
|
|
.omsp_sft_brk.map.b.dedic configure -state disabled
|
| 224 |
|
|
.omsp_sft_brk.map.r.core_nr.l0 configure -state disabled
|
| 225 |
|
|
.omsp_sft_brk.map.r.pmem0.p0 configure -state disabled
|
| 226 |
|
|
.omsp_sft_brk.map.r.core_nr.l1 configure -state disabled
|
| 227 |
|
|
.omsp_sft_brk.map.r.pmem0.p1 configure -state disabled
|
| 228 |
|
|
.omsp_sft_brk.map.r.pmem1.p1 configure -state disabled
|
| 229 |
|
|
.omsp_sft_brk.map.r.core_nr.l2 configure -state disabled
|
| 230 |
|
|
.omsp_sft_brk.map.r.pmem0.p2 configure -state disabled
|
| 231 |
|
|
.omsp_sft_brk.map.r.pmem1.p2 configure -state disabled
|
| 232 |
|
|
.omsp_sft_brk.map.r.pmem2.p2 configure -state disabled
|
| 233 |
|
|
.omsp_sft_brk.map.r.core_nr.l3 configure -state disabled
|
| 234 |
|
|
.omsp_sft_brk.map.r.pmem0.p3 configure -state disabled
|
| 235 |
|
|
.omsp_sft_brk.map.r.pmem1.p3 configure -state disabled
|
| 236 |
|
|
.omsp_sft_brk.map.r.pmem2.p3 configure -state disabled
|
| 237 |
|
|
.omsp_sft_brk.map.r.pmem3.p3 configure -state disabled
|
| 238 |
|
|
}
|
| 239 |
2 |
olivier.gi |
}
|
| 240 |
|
|
|
| 241 |
|
|
###############################################################################
|
| 242 |
|
|
# #
|
| 243 |
|
|
# RECEIVE / SEND RSP PACKETS #
|
| 244 |
|
|
# #
|
| 245 |
|
|
###############################################################################
|
| 246 |
|
|
|
| 247 |
172 |
olivier.gi |
proc receiveRSPpacket {CpuNr sock} {
|
| 248 |
2 |
olivier.gi |
|
| 249 |
|
|
# Get client info
|
| 250 |
|
|
set ip [lindex [fconfigure $sock -peername] 0]
|
| 251 |
|
|
set port [lindex [fconfigure $sock -peername] 2]
|
| 252 |
|
|
|
| 253 |
|
|
# Check if a new packet arrives
|
| 254 |
|
|
set rx_packet 0
|
| 255 |
172 |
olivier.gi |
set rsp_cmd [getDebugChar $CpuNr $sock]
|
| 256 |
2 |
olivier.gi |
set rsp_sum ""
|
| 257 |
|
|
if {[string eq $rsp_cmd "\$"]} {
|
| 258 |
158 |
olivier.gi |
set rx_packet 1
|
| 259 |
|
|
set rsp_cmd ""
|
| 260 |
2 |
olivier.gi |
} else {
|
| 261 |
158 |
olivier.gi |
binary scan $rsp_cmd H* rsp_cmd
|
| 262 |
|
|
if {$rsp_cmd=="03"} {
|
| 263 |
|
|
putsVerbose "--> BREAK"
|
| 264 |
|
|
HaltCPU $CpuNr
|
| 265 |
|
|
}
|
| 266 |
2 |
olivier.gi |
}
|
| 267 |
|
|
# Receive packet
|
| 268 |
|
|
while {$rx_packet} {
|
| 269 |
172 |
olivier.gi |
set char [getDebugChar $CpuNr $sock]
|
| 270 |
158 |
olivier.gi |
if {$char==-1} {
|
| 271 |
|
|
set rx_packet 0
|
| 272 |
|
|
} elseif {[string eq $char "\#"]} {
|
| 273 |
|
|
set rx_packet 0
|
| 274 |
172 |
olivier.gi |
set rsp_sum [getDebugChar $CpuNr $sock]
|
| 275 |
|
|
append rsp_sum [getDebugChar $CpuNr $sock]
|
| 276 |
2 |
olivier.gi |
|
| 277 |
158 |
olivier.gi |
# Re-calculate the checksum
|
| 278 |
|
|
set tmp_sum [RSPcheckSum $rsp_cmd]
|
| 279 |
2 |
olivier.gi |
|
| 280 |
158 |
olivier.gi |
# Acknowledge and analyse the packet
|
| 281 |
|
|
if {[string eq $rsp_sum $tmp_sum]} {
|
| 282 |
|
|
putDebugChar $sock "+"
|
| 283 |
2 |
olivier.gi |
|
| 284 |
158 |
olivier.gi |
# Remove escape characters
|
| 285 |
|
|
set rsp_cmd [removeEscapeChar $rsp_cmd]
|
| 286 |
172 |
olivier.gi |
putsVerbose "CORE $CpuNr: + w $rsp_cmd"
|
| 287 |
2 |
olivier.gi |
|
| 288 |
158 |
olivier.gi |
# Parse packet and send back the answer
|
| 289 |
172 |
olivier.gi |
set rsp_answer [rspParse $CpuNr $sock $rsp_cmd]
|
| 290 |
158 |
olivier.gi |
if {$rsp_answer != "-1"} {
|
| 291 |
172 |
olivier.gi |
sendRSPpacket $CpuNr $sock $rsp_answer
|
| 292 |
158 |
olivier.gi |
}
|
| 293 |
|
|
} else {
|
| 294 |
|
|
putDebugChar $sock "-"
|
| 295 |
|
|
}
|
| 296 |
|
|
} else {
|
| 297 |
|
|
append rsp_cmd $char
|
| 298 |
|
|
}
|
| 299 |
2 |
olivier.gi |
}
|
| 300 |
|
|
}
|
| 301 |
|
|
|
| 302 |
|
|
|
| 303 |
172 |
olivier.gi |
proc sendRSPpacket {CpuNr sock rsp_cmd} {
|
| 304 |
2 |
olivier.gi |
|
| 305 |
|
|
# Set escape characters
|
| 306 |
|
|
set rsp_cmd [setEscapeChar $rsp_cmd]
|
| 307 |
|
|
|
| 308 |
|
|
# Calculate checksum
|
| 309 |
|
|
set rsp_sum [RSPcheckSum $rsp_cmd]
|
| 310 |
|
|
|
| 311 |
|
|
# Format the packet
|
| 312 |
|
|
set rsp_packet "\$$rsp_cmd\#$rsp_sum"
|
| 313 |
|
|
|
| 314 |
|
|
# Send the packet until the "+" aknowledge is received
|
| 315 |
|
|
set send_ok 0
|
| 316 |
|
|
while {!$send_ok} {
|
| 317 |
158 |
olivier.gi |
putDebugChar $sock "$rsp_packet"
|
| 318 |
172 |
olivier.gi |
set char [getDebugChar $CpuNr $sock]
|
| 319 |
2 |
olivier.gi |
|
| 320 |
172 |
olivier.gi |
putsVerbose "CORE $CpuNr: $char r $rsp_cmd"
|
| 321 |
2 |
olivier.gi |
|
| 322 |
158 |
olivier.gi |
if {$char==-1} {
|
| 323 |
|
|
set send_ok 1
|
| 324 |
|
|
} elseif {[string eq $char "+"]} {
|
| 325 |
|
|
set send_ok 1
|
| 326 |
|
|
}
|
| 327 |
2 |
olivier.gi |
}
|
| 328 |
|
|
}
|
| 329 |
|
|
|
| 330 |
|
|
|
| 331 |
|
|
###############################################################################
|
| 332 |
|
|
# #
|
| 333 |
|
|
# CHECKSUM / ESCAPE CHAR / RX / TX FUNCTIONS #
|
| 334 |
|
|
# #
|
| 335 |
|
|
###############################################################################
|
| 336 |
|
|
|
| 337 |
|
|
proc RSPcheckSum {rsp_cmd} {
|
| 338 |
|
|
|
| 339 |
|
|
set rsp_sum 0
|
| 340 |
|
|
for {set i 0} {$i<[string length $rsp_cmd]} {incr i} {
|
| 341 |
158 |
olivier.gi |
scan [string index $rsp_cmd $i] "%c" char_val
|
| 342 |
|
|
set rsp_sum [expr $rsp_sum+$char_val]
|
| 343 |
2 |
olivier.gi |
}
|
| 344 |
|
|
set rsp_sum [format %02x [expr $rsp_sum%256]]
|
| 345 |
|
|
|
| 346 |
|
|
return $rsp_sum
|
| 347 |
|
|
}
|
| 348 |
|
|
|
| 349 |
|
|
proc removeEscapeChar {rsp_cmd} {
|
| 350 |
|
|
|
| 351 |
|
|
# Replace all '\}0x03' characters with '#'
|
| 352 |
|
|
regsub -all "\}[binary format H* 03]" $rsp_cmd "\#" rsp_cmd
|
| 353 |
|
|
|
| 354 |
|
|
# Replace all '\}0x04' characters with '$'
|
| 355 |
|
|
regsub -all "\}[binary format H* 04]" $rsp_cmd "\$" rsp_cmd
|
| 356 |
|
|
|
| 357 |
|
|
# Replace all '\}\]' characters with '\}'
|
| 358 |
|
|
regsub -all "\}\]" $rsp_cmd "\}" rsp_cmd
|
| 359 |
|
|
|
| 360 |
|
|
return "$rsp_cmd"
|
| 361 |
|
|
}
|
| 362 |
|
|
|
| 363 |
|
|
proc setEscapeChar {rsp_cmd} {
|
| 364 |
|
|
|
| 365 |
|
|
# Escape all '\}' characters with '\}\]'
|
| 366 |
|
|
regsub -all "\}" $rsp_cmd "\}\]" rsp_cmd
|
| 367 |
|
|
|
| 368 |
|
|
# Escape all '$' characters with '\}0x04'
|
| 369 |
|
|
regsub -all "\\$" $rsp_cmd "\}[binary format H* 04]" rsp_cmd
|
| 370 |
|
|
|
| 371 |
|
|
# Escape all '#' characters with '\}0x03'
|
| 372 |
|
|
regsub -all "\#" $rsp_cmd "\}[binary format H* 03]" rsp_cmd
|
| 373 |
|
|
|
| 374 |
|
|
return "$rsp_cmd"
|
| 375 |
|
|
}
|
| 376 |
|
|
|
| 377 |
|
|
|
| 378 |
172 |
olivier.gi |
proc getDebugChar {CpuNr sock} {
|
| 379 |
2 |
olivier.gi |
global clients
|
| 380 |
|
|
|
| 381 |
|
|
# Get client info
|
| 382 |
|
|
set ip [lindex [fconfigure $sock -peername] 0]
|
| 383 |
|
|
set port [lindex [fconfigure $sock -peername] 2]
|
| 384 |
|
|
|
| 385 |
|
|
if {[eof $sock] || [catch {set char [read $sock 1]}]} {
|
| 386 |
158 |
olivier.gi |
# end of file or abnormal connection drop
|
| 387 |
|
|
close $sock
|
| 388 |
172 |
olivier.gi |
putsLog "CORE $CpuNr: Connection closed: $ip ($port)\n"
|
| 389 |
|
|
unset clients($CpuNr,addr,$sock)
|
| 390 |
158 |
olivier.gi |
return -1
|
| 391 |
2 |
olivier.gi |
} else {
|
| 392 |
158 |
olivier.gi |
return $char
|
| 393 |
2 |
olivier.gi |
}
|
| 394 |
|
|
}
|
| 395 |
|
|
|
| 396 |
|
|
|
| 397 |
|
|
proc putDebugChar {sock char} {
|
| 398 |
|
|
puts -nonewline $sock $char
|
| 399 |
|
|
}
|
| 400 |
110 |
olivier.gi |
|
| 401 |
|
|
###############################################################################
|
| 402 |
|
|
# #
|
| 403 |
|
|
# GUI: DISPLAY EXTRA INFO #
|
| 404 |
|
|
# #
|
| 405 |
|
|
###############################################################################
|
| 406 |
|
|
|
| 407 |
|
|
proc displayMore { } {
|
| 408 |
|
|
|
| 409 |
|
|
global omsp_info
|
| 410 |
|
|
|
| 411 |
|
|
# Destroy windows if already existing
|
| 412 |
|
|
if {[lsearch -exact [winfo children .] .omsp_extra_info]!=-1} {
|
| 413 |
158 |
olivier.gi |
destroy .omsp_extra_info
|
| 414 |
110 |
olivier.gi |
}
|
| 415 |
|
|
|
| 416 |
|
|
# Create master window
|
| 417 |
|
|
toplevel .omsp_extra_info
|
| 418 |
|
|
wm title .omsp_extra_info "openMSP430 extra info"
|
| 419 |
|
|
wm geometry .omsp_extra_info +380+200
|
| 420 |
|
|
wm resizable .omsp_extra_info 0 0
|
| 421 |
|
|
|
| 422 |
|
|
# Title
|
| 423 |
|
|
set title "openMSP430"
|
| 424 |
172 |
olivier.gi |
if {$omsp_info(0,alias)!=""} {
|
| 425 |
|
|
set title $omsp_info(0,alias)
|
| 426 |
110 |
olivier.gi |
}
|
| 427 |
|
|
label .omsp_extra_info.title -text "$title" -anchor center -fg "\#00ae00" -font {-weight bold -size 16}
|
| 428 |
|
|
pack .omsp_extra_info.title -side top -padx {20 20} -pady {20 10}
|
| 429 |
|
|
|
| 430 |
|
|
# Add extra info
|
| 431 |
|
|
frame .omsp_extra_info.extra
|
| 432 |
|
|
pack .omsp_extra_info.extra -side top -padx 10 -pady {10 10}
|
| 433 |
|
|
scrollbar .omsp_extra_info.extra.yscroll -orient vertical -command {.omsp_extra_info.extra.text yview}
|
| 434 |
|
|
pack .omsp_extra_info.extra.yscroll -side right -fill both
|
| 435 |
|
|
text .omsp_extra_info.extra.text -wrap word -height 20 -font TkFixedFont -yscrollcommand {.omsp_extra_info.extra.yscroll set}
|
| 436 |
|
|
pack .omsp_extra_info.extra.text -side right
|
| 437 |
|
|
|
| 438 |
|
|
# Create OK button
|
| 439 |
|
|
button .omsp_extra_info.okay -text "OK" -font {-weight bold} -command {destroy .omsp_extra_info}
|
| 440 |
|
|
pack .omsp_extra_info.okay -side bottom -expand true -fill x -padx 5 -pady {0 10}
|
| 441 |
|
|
|
| 442 |
|
|
|
| 443 |
|
|
# Fill the text widget will configuration info
|
| 444 |
|
|
.omsp_extra_info.extra.text tag configure bold -font {-family TkFixedFont -weight bold}
|
| 445 |
|
|
.omsp_extra_info.extra.text insert end "Configuration\n\n" bold
|
| 446 |
172 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "CPU Version : %5s\n" $omsp_info(0,cpu_ver)]
|
| 447 |
|
|
.omsp_extra_info.extra.text insert end [format "User Version : %5s\n" $omsp_info(0,user_ver)]
|
| 448 |
|
|
if {$omsp_info(0,cpu_ver)==1} {
|
| 449 |
110 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "Implementation : %5s\n" --]
|
| 450 |
172 |
olivier.gi |
} elseif {$omsp_info(0,asic)==0} {
|
| 451 |
110 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "Implementation : %5s\n" FPGA]
|
| 452 |
172 |
olivier.gi |
} elseif {$omsp_info(0,asic)==1} {
|
| 453 |
110 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "Implementation : %5s\n" ASIC]
|
| 454 |
|
|
}
|
| 455 |
172 |
olivier.gi |
if {$omsp_info(0,mpy)==1} {
|
| 456 |
110 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "Hardware Multiplier support: %5s\n" Yes]
|
| 457 |
172 |
olivier.gi |
} elseif {$omsp_info(0,mpy)==0} {
|
| 458 |
110 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "Hardware Multiplier support: %5s\n" No]
|
| 459 |
|
|
} else {
|
| 460 |
|
|
.omsp_extra_info.extra.text insert end [format "Hardware Multiplier support: %5s\n" --]
|
| 461 |
|
|
}
|
| 462 |
172 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "Program memory size : %5s B\n" $omsp_info(0,pmem_size)]
|
| 463 |
|
|
.omsp_extra_info.extra.text insert end [format "Data memory size : %5s B\n" $omsp_info(0,dmem_size)]
|
| 464 |
|
|
.omsp_extra_info.extra.text insert end [format "Peripheral address space : %5s B\n" $omsp_info(0,per_size)]
|
| 465 |
|
|
if {$omsp_info(0,alias)==""} {
|
| 466 |
110 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "Alias : %5s\n\n\n" None]
|
| 467 |
|
|
} else {
|
| 468 |
172 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "Alias : %5s\n\n\n" $omsp_info(0,alias)]
|
| 469 |
110 |
olivier.gi |
}
|
| 470 |
|
|
|
| 471 |
|
|
.omsp_extra_info.extra.text insert end "Extra Info\n\n" bold
|
| 472 |
|
|
|
| 473 |
172 |
olivier.gi |
if {$omsp_info(0,alias)!=""} {
|
| 474 |
110 |
olivier.gi |
|
| 475 |
158 |
olivier.gi |
set aliasEXTRA [lsort -increasing [array names omsp_info -glob "extra,*"]]
|
| 476 |
|
|
if {[llength $aliasEXTRA]} {
|
| 477 |
110 |
olivier.gi |
|
| 478 |
158 |
olivier.gi |
foreach currentEXTRA $aliasEXTRA {
|
| 479 |
|
|
regexp {^.+,.+,(.+)$} $currentEXTRA whole_match extraATTR
|
| 480 |
172 |
olivier.gi |
.omsp_extra_info.extra.text insert end [format "%-15s: %s\n" $extraATTR $omsp_info(0,$currentEXTRA)]
|
| 481 |
158 |
olivier.gi |
}
|
| 482 |
|
|
.omsp_extra_info.extra.text insert end "\n\n"
|
| 483 |
|
|
}
|
| 484 |
110 |
olivier.gi |
} else {
|
| 485 |
158 |
olivier.gi |
.omsp_extra_info.extra.text insert end "No alias found in 'omsp_alias.xml' file"
|
| 486 |
110 |
olivier.gi |
}
|
| 487 |
|
|
}
|