nyholku/purejavacomm — pull request #17 by roniegh (2013-03-02 16:37:46+00:00)
Title: Fix for 'tail eating' bug which was trying to start a new WaitCommEvent on a port.m_Comm handle before the previous WaitCommEvent had finished.

I've patched src/jtermios/windows/JTermiosImpl.java with a fix for the 'tail eating' bug, which was trying to start a new WaitCommEvent on a port.m_Comm handle before the previous WaitCommEvent had finished.

According to [Microsoft OVERLAPPED structure documentation] (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684342%28v=vs.85%29.aspx):
*"A common mistake is to reuse an OVERLAPPED structure before the previous asynchronous operation has been completed. You should use a separate structure for each request."*

Here are some related discussions:
- - -
http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.kernel/2004-07/0428.html
> Once every 100 or so calls in the same loop WaitCommEvent returns an
> 87: bad parameter, error code.
>>That may happen because of the incorrect cancellation again. **WaitCommEvent()
>>will fail with that status when there is another WaitCommEvent() in
>>progress.**

- - -
http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/91c180b9-4c3c-4694-9572-0da9f1ef2a6f
> "In my old pc (1GHZ) it also works...But when I gave that to my firend to check in his pc (3,4)..it doesn;t work"

- - -