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