arm11_dbgtap: -Wshadow warning fixes
[openocd/cmsis-dap.git] / testing / tcl_test.tcl
blob476e1c21a014c8fbea325bb89d6f56eadcc4a9d1
1 if { $argc != 1 } {
2 puts "Usage: test_tcl.tcl <ipaddress>"
3 exit 1
6 puts $argv
8 # Simple tcl client to connect to openocd
9 global fo
10 set fo [socket $argv 6666]
12 # If a fn is unknown to Tcl, send it off to OpenOCD
13 proc unknown args {
14 global fo
15 puts $fo $args
16 flush $fo
17 gets $fo line
18 return $line
23 #Print help text for a command. Word wrap
24 #help text that is too wide inside column.
25 proc pc_help {args} {
26 global ocd_helptext
27 set cmd $args
28 foreach a [lsort $ocd_helptext] {
29 if {[string length $cmd]==0||[string first $cmd $a]!=-1||[string first $cmd [lindex $a 1]]!=-1} {
30 set w 50
31 set cmdname [lindex $a 0]
32 set h [lindex $a 1]
33 set n 0
34 while 1 {
35 if {$n > [string length $h]} {break}
37 set next_a [expr $n+$w]
38 if {[string length $h]>$n+$w} {
39 set xxxx [string range $h $n [expr $n+$w]]
40 for {set lastpos [expr [string length $xxxx]-1]} {$lastpos>=0&&[string compare [string range $xxxx $lastpos $lastpos] " "]!=0} {set lastpos [expr $lastpos-1]} {
42 #set next_a -1
43 if {$lastpos!=-1} {
44 set next_a [expr $lastpos+$n+1]
49 puts [format "%-25s %s" $cmdname [string range $h $n [expr $next_a-1]] ]
50 set cmdname ""
51 set n [expr $next_a]
57 puts "Running flash_banks"
58 puts [flash_banks]
59 puts "Running help on PC using data from OpenOCD"
60 global ocd_helptext
61 set ocd_helptext [get_help_text]
62 puts [pc_help]