[fpc-pascal] How to poll for a byte in Input?

tcoq tcoq at free.fr
Thu Dec 15 15:31:06 CET 2011


thank you Martin,
I obviously failed somewhere. I did try FILE_FLAG_OVERLAPPED and everything attached to it, but the input is already opened, so i get an error.
I'll try somewhat later when real life gives me a new break.
Off for now.
Thierry
----- Mail Original -----
De: "Martin Schreiber" <mse00000 at gmail.com>
À: fpc-pascal at lists.freepascal.org
Envoyé: Samedi 10 Décembre 2011 18h50:09 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne
Objet: Re: [fpc-pascal] How to poll for a byte in Input?

On 12/10/2011 02:58 PM, tcoq wrote:
> Chad, 
> Thank you very much. I will try your approach, as I'm interested in the piping.
> 
> I also did some experimenting with SetConsoleMode, and also with SetFileAttributes, and with ReadFileEx. But no answer there. Still blocks. 
> 
IIRC non blocking pipes are difficult on Windows. MSEgui uses a separate
thread in tpipereader for simulating non blocking pipes on Windows.
http://gitorious.org/mseide-msegui
http://gitorious.org/mseide-msegui/mseide-msegui/blobs/master/lib/common/kernel/msepipestream.pas

Asynchronous IO on Windows is done by adding FILE_FLAG_OVERLAPPED to
createfile() parameters and a toverlapped with an event object in
readfile().
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365467%28v=VS.85%29.aspx
getoverlappedresult() can then be called with toverlapped or
waitforsingleobject() with toverlapped.event  as parameter.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms687032%28v=vs.85%29.aspx

Don't forget to create and free the event object!
An example with FILE_FLAG_OVERLAPPED is here
http://gitorious.org/mseide-msegui/mseide-msegui/blobs/master/lib/common/serialcomm/msecommport.pas

All IIRC! ;-)

Martin
_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list