Hi folks,
I'm using "LPT1" via CreateFile for Overlapped communications. I use
WaitSingleObject and then GetOverlapped Result to collect ReadFile results.
All that code, including overlapped WriteFile's work great and have been for
years.
However, now I need to get the BUSY state of the port. It appears the only
way to do this in the context of Win32 is via:
DeviceIOControl(Handle, IOCTL_PAR_QUERY_INFORMATION, Nil, 0, @status,
SizeOf(status), @OVERLAPPED);
This call works great, repeated adnausem and yields the proper results every
time, in realtime. Brilliant!
That is, until I call ReadFile.
Structure is as follows.
CreateFile
Repeat
Setup Overlapped
Check DeviceIOControl (WaitSingle and GetOverlapped)
Free Overlapped
Setup Overlapped
Check ReadFile (WaitSingle and GetOverlapped)
Free Overlapped
Until StopRequested
CloseHandle
What happens here is the Status returned from DeviceIOControl starts filling
with 0's and 4's after the first successful proper result is returned the
first time through the loop. These subsequent results are invalid results.
I've also tried a ResetEvent rather than freeing and setting up a new Event
each time. Same results.
NOW, If I close the file handle and reopen in inside the loop, it works. But
that's not desirable for obvious reasons.
Also this is under WinXP and intended for WinXP+ releases.
Thoughts?
|