Overlapped Serial I/O on WinXP or Win2k

Discussion in 'Win32' started by MichaelLondonIV, Sep 14, 2006.

  1. MichaelLondonIV

    MichaelLondonIV New Member

    Joined:
    Sep 14, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi All,

    I have an old piece of software that uses overlapped I/O to read/write from/to a serial port. The code is part of a larger app, that would be difficult to modify.

    The app appears to be dropping an input string, depending on PU/interrupt load. Im not sure if its a hardware or software problem.

    Now to the question:

    The code uses handles in the Overlapped structures in an unusual way (I've been working with overlapped IO for a long time, never seen this). The worker thread runs in a loop, at the top of the loop it waits on 4 handles. 3 of these handles are in the Overlapped structs handle member. When one of the handles signals, it calls a function to process (read or write) data.

    I have always used overlapped IO the opposite way (the way the documentation says to use it):

    1) Call any of the functions that take an Overlapped struct as an argument
    2) Check the return value. If its ERROR_IO_PENDING, then you have to wait on the handle in the Overlapped sturct.
    3) If its OK, then you can continue with whatever you were doing (reading, writing, etc).

    The old code I'm working with does it backwards, first waits on the handles, then calls the function (ReadFile, etc). The documentation does not state what happens in this case.

    Is it valid to first wait on all of the overlapped handles, THEN do the function call?

    Thanks for any help you might provide!!

    Regards,
    Mike London
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice