ERROR_OPERATION_ABORTED

G

Guest

I have a system that has multiple serial ports writing to and reading from
each other. Sometimes, I will get an error code 995
(ERROR_OPERATION_ABORTED) while reading. I realize that this means the I/O
operations was aborted due to an existing thread or application request. I'm
not doing either of these to my knowledge. All of this is in one thread
which has a loop to write on all ports then another loop to read all ports.
When I receive the error, the code will still move on to the next port. I
cannot figure out what is causing this, and why it doesn't happen everytime.
I am running on an XP Pro PC. All ports have 9600 baud, which is not
optional, no parity, 1 stop bit.

This is my code if it helps...

bResult = ReadFile(hComm,BufBytes,NumBytes, ref BytesRead,ref ovlCommPort);
if(bResult == false)
{
lLastError = GetLastError();
if(lLastError == ERROR_IO_PENDING)
{
bOverlapResult = GetOverlappedResult(hComm,
ref ovlCommPort,
ref BytesRead, false); //bWait = false
while(bOverlapResult == false)
{
lLastError = GetLastError();
if(lLastError == ERROR_IO_INCOMPLETE)
//normal result if not finished
continue;
else
{
ClearCommError(hComm,
ref
lErrorFlags, ref lpComStat);
break;
}
}
}
else if(lLastError == ERROR_OPERATION_ABORTED)
{
Console.WriteLine("Read: ERROR_OPERATION_ABORTED");
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top