Posted to tcl by venks at Wed Apr 27 17:35:00 GMT 2011view raw

  1. When I read a few megabytes over a serial link, the file closes
  2. after about 6MB, sometimes. Might be related to PC load. Windows XP.
  3. Is this method OK?
  4.  
  5.  
  6. fconfigure $fi -mode 115200,n,8,1
  7. fconfigure $fi -buffering line -blocking 0 -translation binary
  8. fileevent $fi readable [list [info coroutine] read]
  9. while {1} {
  10. set line [yield $ret]
  11. while {1} {
  12. set err [catch {set bytes [gets $fi line]} msg]
  13. if {$err || [eof $fi]} {
  14. set done 1
  15. puts "*** Read failed, EOF"
  16. }
  17. if {$bytes < 0} break
  18. }
  19. }
  20.  
  21.  
  22.