You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

66 lines
1.4 KiB

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