Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading information from a background process [fconfigure fileevent]

Status
Not open for further replies.

globulle

Technical User
Mar 16, 2004
1
0
0
FR
Using:
WINDOWS 2000 Pro
Tcl/Tk 8.4a2


I have the folowing code:
***********************************************************
proc ReadLine {fileId} {
global string1
global progBarRation

if {[eof $fileId]} {
catch {close $fileId}
return
}

set newData [read $fileId 1]

if {[string length newData]} {
if {$newData == "%"} {
set progBarRation string1
update idletask
} else {
set string1 "[string range $string1 1 2]$newData"
}
}
}



set string1 "000"
builtGUI

set fileId [open "| \"C:/Program Files/ATMEL/AVR Tools/Stk500/stk500.exe\" -dATMEGA128 -af0x1D000,0x1FFFF -ofessai.hex -rf" {RDWR TRUNC CREAT}]

fconfigure $fileId -buffering none -blocking 0
fileevent $fileId readable [list ReadLine $fileId]
***********************************************************


this works fine EXCEPT that it behaves as if the called prog (stk500.exe) was sending all its information when ending.
Thus when my script starts the prog stk500.exe is executed in background but nothing appends until it finishes.

Does anybody has an idea?
 
You can find some interesting code from here: It contains the code for:
"A usual pattern for reading asynchronously from a pipe",
and a link to "an example showing asynchronous read/write communication over a pipe with fileevent, in a single script".

HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top