BOOL ReceiveMessageFromNet( SOCK ss, NetMessage *msg, int timeOutMs, BOOL block, const char *caller ) { BOOL ret = FALSE; if( msg && ss != NULLSOCKET ){ CritSectEx::Scope scope(ReceiveMutex); ret = BasicReceiveNetMessage( ss, msg, sizeof(NetMessage), timeOutMs, block ); if( ret ){ if( msg->size != sizeof(NetMessage) || msg->protocol != NETMESSAGE_PROTOCOL ){ QTils_LogMsgEx( "ReceiveMessageFromNet: ignoring NetMessage with size %hu!=%hu and/or protocol %hu!=%hu", msg->size, sizeof(NetMessage), msg->protocol, NETMESSAGE_PROTOCOL ); ret = FALSE; receiveError(); } #ifdef COMMTIMING msg->recdTime = HRTime_Time(); if( msg->sentTime >= 0.0 ){ cumSendRcvDelay += msg->recdTime - msg->sentTime; sendRcvDelays += 1; } #endif } else{ if( errSock ){ NetMessageToLogMsg( caller, "Receive error)", msg ); receiveError(); errSock = 0; } } } return ret; }
void CDirectSerial::CheckErrors() { DWORD errors=0; // check for errors if (ClearCommError (hCom, &errors, NULL)) if (errors & (CE_BREAK | CE_FRAME | CE_RXPARITY)) { Bit8u errreg = 0; if (errors & CE_BREAK) errreg |= LSR_RX_BREAK_MASK; if (errors & CE_FRAME) errreg |= LSR_FRAMING_ERROR_MASK; if (errors & CE_RXPARITY) errreg |= LSR_PARITY_ERROR_MASK; receiveError (errreg); } }
/** * @short KLAid constructor * @author Rene Schmidt <*****@*****.**> * @version 0.1 */ KLAid::KLAid(QWidget * parent) : KMainWindow(0, "KLAid") { this->_defaultConfig(); // Create DOM parser and connect signals; _dom = new DomParser; QObject::connect(_dom, SIGNAL(error(uint)), parent, SLOT(receiveError(uint))); // Create timer and connect slot _timer = new QTimer(); QObject::connect(_timer, SIGNAL(timeout()), this, SLOT(popMark())); srand(static_cast<unsigned>(time(0))); }
void CDirectSerial::RXBufferEmpty () { ULONG dwRead; Bit8u chRead; USHORT errors = 0; ULONG ulParmLen = sizeof(errors); if (lastChance > 0) { receiveByte (ChanceChar); lastChance = 0; } else { // update RX if (DosRead (hCom, &chRead, 1, &dwRead) != NO_ERROR) { if (dwRead != 0) { //LOG_MSG("UART 0x%x: RX 0x%x", base,chRead); receiveByte (chRead); } } } // check for errors Bit8u errreg = 0; APIRET rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETCOMMERROR, 0, 0, 0, &errors, ulParmLen, &ulParmLen); if (rc != NO_ERROR && errors) { if (errors & 8) { LOG_MSG ("Serial port at 0x%x: line error: framing error.", base); errreg |= LSR_FRAMING_ERROR_MASK; } if (errors & 4) { LOG_MSG ("Serial port at 0x%x: line error: parity error.", base); errreg |= LSR_PARITY_ERROR_MASK; } } errors = 0; rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETCOMMEVENT, 0, 0, 0, &errors, ulParmLen, &ulParmLen); if (rc != NO_ERROR && errors) { if (errors & 6) { LOG_MSG ("Serial port at 0x%x: line error: break received.", base); errreg |= LSR_RX_BREAK_MASK; } } if (errreg != 0) { receiveError (errreg); } }
void ClientInvade::receiveOrder(QJsonObject json) { if( !isOrderValid(json) ) { return; } QString method = json["method"].toString(); QJsonObject parameters = json["parameters"].toObject(); qDebug() << "<" << method << parameters; if( method == "refresh" ) { receiveRefresh(json["parameters"].toObject()); } else if( method == "error" ) { receiveError(json["parameters"].toObject()); } else if( method == "requestNewGame" ) { receiveRequestNewGame(json["parameters"].toObject()); } }
const txXPathNode* txExecutionState::retrieveDocument(const nsAString& aUri) { NS_ASSERTION(aUri.FindChar(PRUnichar('#')) == kNotFound, "Remove the fragment."); if (mDisableLoads) { return nsnull; } PR_LOG(txLog::xslt, PR_LOG_DEBUG, ("Retrieve Document %s", NS_LossyConvertUTF16toASCII(aUri).get())); // try to get already loaded document txLoadedDocumentEntry *entry = mLoadedDocuments.PutEntry(aUri); if (!entry) { return nsnull; } if (!entry->mDocument) { // open URI nsAutoString errMsg; // XXX we should get the loader from the actual node // triggering the load, but this will do for the time being nsresult rv; rv = txParseDocumentFromURI(aUri, *mLoadedDocuments.mSourceDocument, errMsg, getter_Transfers(entry->mDocument)); if (NS_FAILED(rv) || !entry->mDocument) { mLoadedDocuments.RawRemoveEntry(entry); receiveError(NS_LITERAL_STRING("Couldn't load document '") + aUri + NS_LITERAL_STRING("': ") + errMsg, rv); return nsnull; } } return entry->mDocument; }
const txXPathNode* txExecutionState::retrieveDocument(const nsAString& aUri) { NS_ASSERTION(!aUri.Contains(char16_t('#')), "Remove the fragment."); if (mDisableLoads) { return nullptr; } MOZ_LOG(txLog::xslt, LogLevel::Debug, ("Retrieve Document %s", NS_LossyConvertUTF16toASCII(aUri).get())); // try to get already loaded document txLoadedDocumentEntry *entry = mLoadedDocuments.PutEntry(aUri); if (!entry) { return nullptr; } if (!entry->mDocument && !entry->LoadingFailed()) { // open URI nsAutoString errMsg; // XXX we should get the loader from the actual node // triggering the load, but this will do for the time being entry->mLoadResult = txParseDocumentFromURI(aUri, *mLoadedDocuments.mSourceDocument, errMsg, getter_Transfers(entry->mDocument)); if (entry->LoadingFailed()) { receiveError(NS_LITERAL_STRING("Couldn't load document '") + aUri + NS_LITERAL_STRING("': ") + errMsg, entry->mLoadResult); } } return entry->mDocument; }
void ChatService::listen(){ connect(mUdpService, SIGNAL(receiveError(QString)), this, SIGNAL(receiveError(QString))); connect(mUdpService, SIGNAL(receiveSuccess(QHostAddress,quint16,ChatMessage)), this, SIGNAL(receiveSuccess(QHostAddress,quint16,ChatMessage))); connect(mUdpService, SIGNAL(sendError(QUuid,QString)), this, SIGNAL(sendError(QUuid,QString))); connect(mUdpService, SIGNAL(sendSuccess(QUuid)), this, SIGNAL(sendSuccess(QUuid))); }
// コンストラクタ Terminal::Terminal(QWidget *parent) : QMainWindow(parent), m_ds(this){ // 変数初期化 // GUIを作成 m_ui.setupUi(this); // GUI各部の制御クラスを作成 m_console = new TerminalConsole(m_ui.ConsoleInput, m_ui.ConsoleOutput, m_ui.ConsoleClear); m_info = new TerminalInfo(m_ui.StatusBar, m_ui.InfoIconDevice, m_ui.InfoLabelName, m_ui.InfoLabelVersion, m_ui.InfoButtonReboot, m_ui.InfoButtonConnect, m_ui.InfoButtonDisconnect); m_access = new TerminalAccess(m_ui.ProcessorInput, m_ui.ProcessorOpen, m_ui.ProcessorWrite, m_ui.ProcessorRead, m_ui.BitstreamInput, m_ui.BitstreamOpen, m_ui.BitstreamSend, m_ui.BitstreamWrite, m_ui.CoprocessorInput, m_ui.CoprocessorOpen, m_ui.CoprocessorSend, m_ui.CoprocessorWrite); m_controller = new TerminalController(this, m_ui.ControllerShow); m_logger = new TerminalLogger(m_ui.LoggerCheckUse, m_ui.LoggerGraph, m_ui.LoggerButtonAdd, m_ui.LoggerButtonRemove, m_ui.LoggerList, m_ui.LoggerSaveList, m_ui.LoggerLabel, m_ui.LoggerStart, m_ui.LoggerStop, m_ui.LoggerSave); m_pipe = new TerminalPipe(m_ui.PipeTable); m_file = new TerminalFile(m_ui.FileTree, m_ui.FileProgress); // ファイラータブのツールボックスにアイコンを設定 QFileIconProvider icon_provider; m_ui.FilerToolBox->setItemIcon(0, icon_provider.icon(QFileIconProvider::Network)); m_ui.FilerToolBox->setItemIcon(1, icon_provider.icon(QFileIconProvider::Drive)); // 非同期操作用のスレッドを作成 m_thread = new QThread(this); m_async = new TerminalAsync(&m_ds); m_async->moveToThread(m_thread); // シグナルを接続 connect(&m_ds, SIGNAL(enableConsole(bool)), m_console, SLOT(enable(bool))); connect(&m_ds, SIGNAL(enableInfo(bool, bool)), m_info, SLOT(enable(bool, bool))); connect(&m_ds, SIGNAL(enableAccess(char, bool, bool, bool, bool)), m_access, SLOT(enable(char, bool, bool, bool, bool))); connect(&m_ds, SIGNAL(enableFileTree(bool, bool, bool, bool, bool, bool)), m_file, SLOT(enable(bool, bool, bool, bool, bool, bool))); connect(&m_ds, SIGNAL(enableController(bool, bool, bool)), m_controller, SLOT(enable(bool, bool, bool))); connect(&m_ds, SIGNAL(enableLogger(bool, bool, bool)), m_logger, SLOT(enable(bool, bool, bool))); connect(m_async, SIGNAL(showWarningConst(const wchar_t *, const wchar_t *)), this, SLOT(showWarningConst(const wchar_t *, const wchar_t *)), Qt::QueuedConnection); connect(m_async, SIGNAL(sendProgress(int)), m_info, SLOT(setProgress(int)), Qt::QueuedConnection); connect(m_async, SIGNAL(setExclusiveState(bool)), &m_ds, SLOT(setExclusiveState(bool)), Qt::QueuedConnection); connect(m_console, SIGNAL(send(const QString &)), this, SLOT(transmitDebug(const QString &))); connect(m_info, SIGNAL(changeConnection(const std::wstring *, bool, bool)), this, SLOT(changeConnection(const std::wstring *, bool, bool))); connect(m_info, SIGNAL(rebootRequest(const wchar_t *)), &m_ds, SLOT(changeBootMode(const wchar_t *))); connect(m_access, SIGNAL(operation(char, std::wstring *)), m_async, SLOT(onAccessOperation(char, std::wstring *)), Qt::QueuedConnection); //connect(m_controller, SIGNAL(operation(const Controller_t &)), &m_ds, SLOT(setController(const Controller_t &))); connect(m_file, SIGNAL(updateRequest(const std::wstring &)), m_ds.m_dsDir, SLOT(updateRequest(const std::wstring &))); connect(m_file, SIGNAL(moveRequest(const std::wstring &, const std::wstring &)), m_ds.m_dsDir, SLOT(moveRequest(const std::wstring &, const std::wstring &))); connect(m_file, SIGNAL(copyRequest(const std::wstring &, const std::wstring &)), m_ds.m_dsDir, SLOT(copyRequest(const std::wstring &, const std::wstring &))); connect(m_file, SIGNAL(deleteRequest(const std::wstring &)), m_ds.m_dsDir, SLOT(deleteRequest(const std::wstring &))); connect(m_file, SIGNAL(mkdirRequest(const std::wstring &)), m_ds.m_dsDir, SLOT(mkdirRequest(const std::wstring &))); connect(m_file, SIGNAL(transfarToDevice(std::wstring *, std::wstring *)), m_async, SLOT(transfarToDevice(std::wstring *, std::wstring *)), Qt::QueuedConnection); connect(m_file, SIGNAL(transfarFromDevice(std::wstring *, std::wstring *)), m_async, SLOT(transfarFromDevice(std::wstring *, std::wstring *)), Qt::QueuedConnection); connect(m_logger, SIGNAL(sendLoggingList(char *, unsigned int)), m_async, SLOT(setLoggingList(char *, unsigned int)), Qt::QueuedConnection); connect(m_async, SIGNAL(sendLog(unsigned short *, unsigned int)), m_logger, SLOT(receiveLog(unsigned short *, unsigned int)), Qt::QueuedConnection); connect(m_async, SIGNAL(sendLoggingError()), m_logger, SLOT(receiveError()), Qt::QueuedConnection); connect(m_controller, SIGNAL(setControllerState(ControllerState_t *)), m_async, SLOT(setControllerState(ControllerState_t *)), Qt::QueuedConnection); connect(m_async, SIGNAL(requestControllerState()), m_controller, SLOT(requestControllerState()), Qt::QueuedConnection); connect(&m_ds, SIGNAL(setDebugText(QString &)), m_info, SLOT(setDebugText(QString &))); connect(&m_ds, SIGNAL(sendProgress(int)), m_info, SLOT(setProgress(int))); connect(&m_ds, SIGNAL(setLogInfo(const std::wstring &)), m_logger, SLOT(setLogInfo(const std::wstring &))); connect(&m_ds, SIGNAL(changeConnection(const std::wstring *, bool, bool)), this, SLOT(changeConnection(const std::wstring *, bool, bool))); connect(&m_ds, SIGNAL(updateWidgetsInfo()), this, SLOT(updateWidgetsInfo())); connect(m_ds.m_dsPipe, SIGNAL(clearPipe()), m_pipe, SLOT(clearPipe())); connect(m_ds.m_dsPipe, SIGNAL(addPipe(const wchar_t *, int, int, const wchar_t *)), m_pipe, SLOT(addPipe(const wchar_t *, int, int, const wchar_t *))); connect(m_ds.m_dsDir, SIGNAL(initTree(const std::wstring &)), m_file, SLOT(initTree(const std::wstring &))); connect(m_ds.m_dsDir, SIGNAL(addDrive(char, const std::wstring &, bool, unsigned long long)), m_file, SLOT(addDrive(char, const std::wstring &, bool, unsigned long long))); connect(m_ds.m_dsDir, SIGNAL(changeDriveStatus(char, unsigned long long)), m_file, SLOT(changeDriveStatus(char, unsigned long long))); connect(m_ds.m_dsDir, SIGNAL(moveToItem(const std::wstring &)), m_file, SLOT(moveToItem(const std::wstring &))); connect(m_ds.m_dsDir, SIGNAL(addItem(const std::wstring &, unsigned long long, bool, unsigned int)), m_file, SLOT(addItem(const std::wstring &, unsigned long long, bool, unsigned int))); connect(m_ds.m_dsDir, SIGNAL(moveUp()), m_file, SLOT(moveUp())); connect(m_ds.m_dsFile, SIGNAL(changeFile(std::wstring *, unsigned long long)), m_file, SLOT(changeFile(std::wstring *, unsigned long long)), Qt::QueuedConnection); // タイマーを作成 QTimer *interval = new QTimer(this); connect(interval, SIGNAL(timeout()), this, SLOT(onInterval())); connect(interval, SIGNAL(timeout()), m_logger, SLOT(update())); interval->start(PERIOD); // ウィジェットを初期状態に m_console->enable(false); m_info->enable(false, false); m_access->enable('P', false); m_access->enable('B', false); m_access->enable('C', false); m_file->enable(false); m_controller->enable(false); m_logger->enable(false); // 前回の設定の読み込み int maximized = 0; clINI setting; if (setting.Open(g_ApplicationDir.c_str(), L"setting.ini") == true){ // パスの読み込み wchar_t buf[MAX_PATH]; setting.Read(L"Path", L"Processor", buf); m_access->setPath('P', buf); setting.Read(L"Path", L"Bitstream", buf); m_access->setPath('B', buf); setting.Read(L"Path", L"Coprocessor", buf); m_access->setPath('C', buf); // 設定の読み込み int baudrate = m_info->getBaudrate(); setting.Read(L"Setting", L"Baudrate", baudrate); m_info->setBaudrate(baudrate); // ウィンドウ座標・サイズの読み込み int pos_x, pos_y, size_w, size_h; setting.Read(L"Window", L"Maximize", maximized); setting.Read(L"Window", L"PosX", pos_x); setting.Read(L"Window", L"PosY", pos_y); setting.Read(L"Window", L"SizeW", size_w); setting.Read(L"Window", L"SizeH", size_h); pos_x -= 500000; pos_y -= 500000; size_w -= 500000; size_h -= 500000; if ((abs(pos_x) <= 32767) && (abs(pos_y) <= 32767)) this->move(pos_x, pos_y); if ((abs(size_w) <= 32767) && (abs(size_h) <= 32767)) this->resize(size_w, size_h); } // 非同期操作用スレッドを開始 m_thread->start(); // タイマーの精度を高める timeBeginPeriod(1); // ウィンドウを表示 if (maximized == 0){ this->show(); }else{ this->showMaximized(); } }
void CDirectSerial::Timer2(void) { ULONG dwRead = 0; USHORT errors = 0; Bit8u chRead = 0; ULONG ulParmLen = sizeof(errors); if (lastChance == 0) { // lastChance = 0 if (CanReceiveByte ()) { if (DosRead (hCom, &chRead, 1, &dwRead)) { if (dwRead) receiveByte (chRead); } } else { if (DosRead (hCom, &chRead, 1, &dwRead)) { if (dwRead) { ChanceChar = chRead; lastChance++; } } } } else if (lastChance > 10) { receiveByte (0); // this causes RX Overrun now lastChance = 0; // empty serial buffer dwRead = 1; while (dwRead > 0) { // throw away bytes in buffer DosRead (hCom, &chRead, 1, &dwRead); } } else { // lastChance>0 // already one waiting if (CanReceiveByte ()) { // chance used receiveByte (ChanceChar); lastChance = 0; } else lastChance++; } // check for errors Bit8u errreg = 0; APIRET rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETCOMMERROR, 0, 0, 0, &errors, ulParmLen, &ulParmLen); if (rc != NO_ERROR && errors) { if (errors & 8) { LOG_MSG ("Serial port at 0x%x: line error: framing error.", base); errreg |= LSR_FRAMING_ERROR_MASK; } if (errors & 4) { LOG_MSG ("Serial port at 0x%x: line error: parity error.", base); errreg |= LSR_PARITY_ERROR_MASK; } } errors = 0; rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETCOMMEVENT, 0, 0, 0, &errors, ulParmLen, &ulParmLen); if (rc != NO_ERROR && errors) { if (errors & 6) { LOG_MSG ("Serial port at 0x%x: line error: break received.", base); errreg |= LSR_RX_BREAK_MASK; } } if (errreg != 0) { receiveError (errreg); } // update Modem input line states updateMSR (); }
Connection::Connection() { QObject::connect(&socket, SIGNAL(readyRead()), this, SLOT(receiveData())); QObject::connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(receiveError(QAbstractSocket::SocketError))); }