Add the serial timeout to the Windows serial port handler.

pull/1/head
Jonathan Naylor 8 years ago
parent 2cde6fb014
commit 91d2645011

@ -205,16 +205,22 @@ int CSerialDataController::readNonblock(unsigned char* buffer, unsigned int leng
m_readPending = true;
}
BOOL res = HasOverlappedIoCompleted(&m_readOverlapped);
if (!res)
return 0;
DWORD bytes = 0UL;
res = ::GetOverlappedResult(m_handle, &m_readOverlapped, &bytes, TRUE);
DWORD millis = timeout;
res = ::GetOverlappedResultEx(m_handle, &m_readOverlapped, &bytes, millis, FALSE);
if (!res) {
wxLogError(wxT("Error from GetOverlappedResult (ReadFile): %04lx"), ::GetLastError());
DWORD error = ::GetLastError();
if (timeout == 0U && error == ERROR_IO_INCOMPLETE) {
return 0;
} else if (timeout > 0U && error == WAIT_TIMEOUT) {
return 0;
} else if (timeout > 0U && error == WAIT_IO_COMPLETION) {
return 0;
} else {
wxLogError(wxT("Error from GetOverlappedResultEx (ReadFile): %04lx"), error);
return -1;
}
}
::memcpy(buffer, m_readBuffer, bytes);
m_readPending = false;

Loading…
Cancel
Save

Powered by TurnKey Linux.