....if (eventMask & EV_RXCHAR) ....
........ if(SetCommMask(hd,EV_RXCHAR) == 0) { TTY_PORTABILITY_DEBUG("TWinSerialDevice::waitForReadyRead->SetCommMask! Error!"); if (m_emitSignalErrors) errMsg(EWaitReadyReadIO); return retFlag; } //создаем событие (create event) OVERLAPPED ovl; ZeroMemory(&ovl, sizeof(ovl)); ovl.hEvent=CreateEvent(0, false, false, 0); if (ovl.hEvent==INVALID_HANDLE_VALUE) { TTY_PORTABILITY_DEBUG("TWinSerialDevice::waitForReadyRead->CreateEvent! Error!"); if (m_emitSignalErrors) errMsg(EWaitReadyReadIO); return retFlag; } //соотносим события от последовательного устройства (!!!???) DWORD eventMask=0; //маска событий if (WaitCommEvent(hd, &eventMask, &ovl) == 0) { if (GetLastError() == ERROR_IO_PENDING){ switch(WaitForSingleObject(ovl.hEvent, msecs)) { case WAIT_OBJECT_0: retFlag=true; break; case WAIT_TIMEOUT: TTY_PORTABILITY_DEBUG("TWinSerialDevice::waitForReadyRead->Timeout! Error!"); if (emitSignals) if (m_emitSignalErrors) errMsg(EWaitReadyReadTimeout); break; default: TTY_PORTABILITY_DEBUG("TWinSerialDevice::waitForReadyRead->Undefined Events! Error!"); if (m_emitSignalErrors) errMsg(EWaitReadyReadIO); }//switch retVal }//if==ERROR_IO_PENDING else { TTY_PORTABILITY_DEBUG("TWinSerialDevice::waitForReadyRead->GetLastError()!=ERROR_IO_PENDING! Error!"); if (m_emitSignalErrors) errMsg(EWaitReadyReadIO); } }//if WaitCommEvent==0 else { if (eventMask & EV_RXCHAR) retFlag=true; else { TTY_PORTABILITY_DEBUG("TWinSerialDevice::waitForReadyRead->(WaitCommEvent!=0) and (eventMask !=EV_RXCHAR)! Error!"); if (m_emitSignalErrors) errMsg(EWaitReadyReadIO); } }//else WaitCommEvent !=0 SetCommMask(hd,0); if (CloseHandle(ovl.hEvent) == 0) { TTY_PORTABILITY_DEBUG("TWinSerialDevice::waitForReadyRead->CloseHandle! Error!"); if (m_emitSignalErrors) errMsg(EWaitReadyReadIO); }........
QWinEventNotifier::QWinEventNotifier(HANDLE hEvent, QObject *parent) : QObject(parent), handleToEvent(hEvent), enabled(false){ QEventDispatcherWin32 *eventDispatcher = qobject_cast<QEventDispatcherWin32 *>(QAbstractEventDispatcher::instance(thread())); Q_ASSERT_X(eventDispatcher, "QWinEventNotifier::QWinEventNotifier()", "Cannot create a win event notifier without a QEventDispatcherWin32"); eventDispatcher->registerEventNotifier(this); enabled = true;}
void QEventDispatcherWin32::activateEventNotifiers(){ Q_D(QEventDispatcherWin32); //### this could break if events are removed/added in the activation for (int i=0; i<d->winEventNotifierList.count(); i++) { if (WaitForSingleObjectEx(d->winEventNotifierList.at(i)->handle(), 0, TRUE) == WAIT_OBJECT_0) d->activateEventNotifier(d->winEventNotifierList.at(i)); }}
if (WaitCommEvent(hd, &eventMask, &ovl) == 0) {...... }//if WaitCommEvent==0 else { if (eventMask & EV_RXCHAR) retFlag=true;