I/O operation sytem error
-
I am in a loop, reading from an RS232 port. There are times when i receive an exception with a system message that says: "The I/O operation has been aborted because of either a thread exit or an application request" // read a byte from port while (!m_bExit) { // reset flag variables dwBytesRead = 0; // read bRC = ReadFile(m_hCommPort, pDataBuff, 20, &dwBytesRead, NULL); dwError = GetLastError(); if (!bRC) { if (ERROR_HANDLE_EOF != dwError || ERROR_TIMEOUT != dwError) { LPVOID SysMsg; // reterieve system message FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&SysMsg, 0, NULL ); // show system message ZeroMemory( m_szBuffer, sizeof(m_szBuffer) ); wsprintf(m_szBuffer, TEXT("ReadRS232Data() over %s: ReadFile(), %s"), m_Port, (LPCTSTR)SysMsg); LocalFree(SysMsg); return 0; } } Has anyone ever found a solution to this or know what would cause this error? Cause once this happens you cannot read from the port until it is out of this conditions which seems to just happen on its own. Thanks in advance for any help or direction.
-
I am in a loop, reading from an RS232 port. There are times when i receive an exception with a system message that says: "The I/O operation has been aborted because of either a thread exit or an application request" // read a byte from port while (!m_bExit) { // reset flag variables dwBytesRead = 0; // read bRC = ReadFile(m_hCommPort, pDataBuff, 20, &dwBytesRead, NULL); dwError = GetLastError(); if (!bRC) { if (ERROR_HANDLE_EOF != dwError || ERROR_TIMEOUT != dwError) { LPVOID SysMsg; // reterieve system message FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&SysMsg, 0, NULL ); // show system message ZeroMemory( m_szBuffer, sizeof(m_szBuffer) ); wsprintf(m_szBuffer, TEXT("ReadRS232Data() over %s: ReadFile(), %s"), m_Port, (LPCTSTR)SysMsg); LocalFree(SysMsg); return 0; } } Has anyone ever found a solution to this or know what would cause this error? Cause once this happens you cannot read from the port until it is out of this conditions which seems to just happen on its own. Thanks in advance for any help or direction.
-
LCI wrote:
I am in a loop
That sounds uncomfortable.
LCI wrote:
or know what would cause this error
What is the number returned from GetLastError?
led mike wrote:
That sounds uncomfortable.
:laugh:
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
LCI wrote:
I am in a loop
That sounds uncomfortable.
LCI wrote:
or know what would cause this error
What is the number returned from GetLastError?