Bug in WriteFile to com port in win95/98 
Author Message
 Bug in WriteFile to com port in win95/98

Bug in WriteFile to com port in win95/98

I have an app with one thread for the gui and one worker thread for the
com port.
At the com port I have short read-writes-read-writes. at highest speed.
I am using WriteFile and ReadFile for this.
As long as the writes are short, 10-20 bytes, there is no problem
but when the write is a 240 byte block, in about one out of ten writes,
the WriteFile never returns and the worker thread blocks and everything
I can get around the problem by inserting a Sleep( 50 ) before the call
WriteFile but this in not an acceptable solution.
I have also tried to use overlapped io, but the problem is still there.
This bug is found in win98 and win95 but not in NT.

The only way to get my app working is to use overlapped io.
I compute a timeout for the write and then detect the blocked
WriteFile in my code. And then I close and open the com-port again
to get going. But this is a very unsatisfactory solution.

I have looked at Microsoft's site for this bug, but found nothing.
I am convinced this is a true bug win95/98, since I am not
alone having this problem.

This is what is special about my app:
1. A separate thread for io, doing both read and write at high speed.
2. A long write, up to 240 bytes, and short reads.
3. High speed with shortest possible pauses between consecutive
   My app is "talking" to an another puter so reads are fast too.

I can send code to anybody interested in checking this.

Is there anybody having any info regarding this bug ??

John Rehn

Tue, 26 Mar 2002 03:00:00 GMT  
 Bug in WriteFile to com port in win95/98

>Bug in WriteFile to com port in win95/98


The mcrosoft.public.win32.programmer.kernel group may be a better
choice for your question.

My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Wed, 27 Mar 2002 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. WriteFile to serial port hangs in Win95

2. WriteFile on COM ports

3. Example of CreateFile, ReadFile, and WriteFile for COM port

4. Using CreateFile/WriteFile and COM ports

5. Problem with WriteFile in windows 95,98, me

6. Problem with WriteFile in windows 95,98, me

7. com port and win95

8. Adding COM ports to a WIN95 system

9. Win95 VC++ MFC program hangs using COM port

10. vc++ .net creates corrupted exe for Win95/98

11. Using com2 with win95/98

12. Using DeviceIOControl and CreateFile on Win95/98


Powered by phpBB® Forum Software