Posted to tcl by bjorkintosh at Wed Apr 04 19:34:05 GMT 2012view raw

  1. 1 package require Tk
  2. 2 package require img::jpeg
  3. 3 wm withdraw .
  4. 4 set main .ieee
  5. 5 toplevel $main
  6. 6 ttk::scrollbar .sy -orient vertical -command {$main.t yview}
  7. 7 text $main.t -state disabled -state disabled
  8. 8 pack $main.t -expand 1 -fill both
  9. 9
  10. 10 proc Reader {fid} {
  11. 11
  12. 12 if {[chan gets $fid data] < 0} {
  13. 13 if {[chan eof $fid]} {
  14. 14 catch {chan close $fid}
  15. 15 set done 1
  16. 16 return
  17. 17 }
  18. 18 }
  19. 19
  20. 20 chan puts $data
  21. 21 $main.t configure -state normal
  22. 22 $main.t insert end $data {} \n {}
  23. 23 $main.t see end
  24. 24 $main.t configure -state disabled
  25. 25 }
  26. 26
  27. 27 set comm [open /dev/ttyACM0 r+]
  28. 28 chan configure $comm -mode -9600,n,8,1 -blocking 0 -buffering none
  29. 29 chan event $comm readable [list Reader $comm]
  30.