void eCtune::run() { qDebug("## eCtune dataloging engine started.\n"); m_handShakeStatus = false; m_portOK = false; m_busy = false; m_refreshTimer.setInterval(10); m_refreshTimer.setSingleShot(true); connect(this,SIGNAL(startRefreshTimer()),&m_refreshTimer,SLOT(start())); connect(this,SIGNAL(stopRefreshTimer()),&m_refreshTimer,SLOT(stop())); connect(&m_refreshTimer,SIGNAL(timeout()),this,SLOT(refresh())); m_timeoutTimer.setInterval(150); m_timeoutTimer.setSingleShot(true); connect(this,SIGNAL(startTimeoutTimer()),&m_timeoutTimer,SLOT(start())); connect(this,SIGNAL(stopTimeoutTimer()),&m_timeoutTimer,SLOT(stop())); connect(&m_timeoutTimer,SIGNAL(timeout()),this,SLOT(serialTimeout())); m_portOK = this->portSetup(this); this->m_refreshTimer.start(); }
void LogCollector::startTimeoutTimer() { timeoutTimer_.stop(); timeoutTimer_.start(uploadStrategy_->getTimeoutCheckPeriod(), [this] { if (isDeliveryTimeout()) { processTimeout(); } startTimeoutTimer(); }); }
void TelepathyClient::onOfferServerFinished(Tp::PendingOperation *operation) { qDebug() << "Offered server to remote host"; if (operation->isError()) { setError(operation->errorMessage()); setState(Disconnected); return; } startTimeoutTimer(); }
/** * \fn bool DSA::waitForMessage(byte *opcode, byte *parameter) * \deprecated Try to avoid using this function. It will block your * program for the timeout time when no message is received. * Better keep checking transmitRequested() in you main loop. * \brief Wait for a message to receive. * * When a message is expected this function will wait for the message to arrive. * A timeout is set to abort this function at timeout. * \param *opcode Pointer to the opcode variable that will updated after a successful transfer * \param *parameter Pointer to the parameter variable that will updated after a successful transfer. * \return True on a successful transfer, False on a timeout or communication error */ bool DSA::waitForMessage(byte *opcode, byte *parameter) { startTimeoutTimer(DSA_TIMEOUT); while(!transmitRequested()) { if(timeOut()) { resetPins(); return false; } } return receiveMessage(opcode, parameter); }
LogCollector::LogCollector(IKaaChannelManagerPtr manager, IExecutorContext& executorContext) : transport_(nullptr), channelManager_(manager), timeoutAccessPointId_(0), logUploadCheckTimer_("LogCollector logUploadCheckTimer"), scheduledUploadTimer_("LogCollector uploadTimer"), timeoutTimer_("LogCollector timeoutTimer"), executorContext_(executorContext) { #ifdef KAA_USE_SQLITE_LOG_STORAGE storage_.reset(new SQLiteDBLogStorage()); #else storage_.reset(new MemoryLogStorage()); #endif uploadStrategy_.reset(new DefaultLogUploadStrategy()); startTimeoutTimer(); }
int main(void) { SYS_Init(); HAL_UartInit(38400); HAL_LedInit(); HAL_LedOff(0); init_nwk(); startTimeoutTimer(); while (1) { SYS_TaskHandler(); HAL_UartTaskHandler(); APP_TaskHandler(); } }
bool eCtune::sendHandShake() { /* if (!m_busy) busyMutex.unlock(); if (!busyMutex.tryLock()) return false; */ if (m_busy) return false; m_busy = true; QByteArray sbuffer; //data to send sbuffer[0] = 0x10; port->flush(); port->write(sbuffer); emit startTimeoutTimer(); qDebug() << "Sent HandShake, Waiting for Response"; //busyMutex.unlock(); return true; }
void timeoutTimerHandler(SYS_Timer_t *timer) { if (!NWK_Busy()) { frame[0] = 0x06; frame[1] = 0xBB; frame[2] = 0xBB; frame[3] = 0xBB; frame[4] = 0xBB; nwkDataReq.dstAddr = 0x389C; nwkDataReq.dstEndpoint = 1; nwkDataReq.srcEndpoint = 1; nwkDataReq.size = sizeof(frame); nwkDataReq.data = frame; nwkDataReq.confirm = appDataConf; NWK_DataReq(&nwkDataReq); } startTimeoutTimer(); }
bool eCtune::getRawValues() { /* if (!busyMutex.tryLock()) return false; */ if (m_busy) return false; m_busy = true; QByteArray sbuffer; //data to send sbuffer[0] = 0x20; port->flush(); //qDebug() << "Data Request" << QString::number(sbuffer[0], 16).prepend("0x"); port->write(sbuffer); emit startTimeoutTimer(); //busyMutex.unlock(); return true; }
void LogCollector::rescheduleTimers() { startTimeoutTimer(); startLogUploadCheckTimer(); }
/** * \fn bool DSA::sendMessage(byte opcode, byte parameter) * \brief Send a message. * * A DSA message contains a opcode and a parameter send as one 16bit command. * \param opcode The DSA opcode to send. * \param parameter The DSA parameter to send. * \return True on a successful transfer, False on a communication error */ bool DSA::sendMessage(byte opcode, byte parameter) { /* synchPhase */ int command = opcode; command = command << 8; command += parameter; digitalWrite(_DSApin, HIGH); resetPins(); pinMode(_DSApin, OUTPUT); startTimeoutTimer(DSA_TIMEOUT); digitalWrite(_DSApin, LOW); while(digitalRead(_ACKpin)) { if(timeOut()) { resetPins(); return false; } } digitalWrite(_DSApin, HIGH); while(!digitalRead(_ACKpin)) { if(timeOut()) { resetPins(); return false; } } /* data transfer phase */ digitalWrite(_STBpin, HIGH); pinMode(_STBpin, OUTPUT); startTimeoutTimer(DSA_TIMEOUT); unsigned int mask = 0x8000; int i; for (i = 0; i < 16; i++ ) { if(!(command & mask)) digitalWrite(_DSApin, LOW); digitalWrite(_STBpin, LOW); while(digitalRead(_ACKpin)) { if(timeOut()) { resetPins(); return false; } } digitalWrite(_STBpin, HIGH); digitalWrite(_DSApin, HIGH); while(!digitalRead(_ACKpin)) { if(timeOut()) { resetPins(); return false; } } mask = mask >> 1; } /* acknowledge phase */ digitalWrite(_ACKpin, HIGH); resetPins(); pinMode(_ACKpin, OUTPUT); startTimeoutTimer(DSA_TIMEOUT); digitalWrite(_ACKpin, LOW); while(digitalRead(_STBpin)) { if(timeOut()) { resetPins(); return false; } } if(!digitalRead(_DSApin)) { resetPins(); return false; } digitalWrite(_ACKpin, HIGH); while(!digitalRead(_STBpin)) { if(timeOut()) { resetPins(); return false; } } resetPins(); return true; }
/** * \fn bool DSA::receiveMessage(byte *opcode, byte *parameter) * \brief Receive a message. * * \param *opcode Pointer to the opcode variable that will updated after a successful transfer * \param *parameter Pointer to the parameter variable that will updated after a successful transfer. * \return True on a successful transfer, False on a communication error */ bool DSA::receiveMessage(byte *opcode, byte *parameter) { /* synchPhase */ word command = 0; digitalWrite(_ACKpin, HIGH); resetPins(); pinMode(_ACKpin, OUTPUT); startTimeoutTimer(DSA_TIMEOUT); digitalWrite(_ACKpin, LOW); while(!digitalRead(_DSApin)) { if(timeOut()) { resetPins(); return false; } } digitalWrite(_ACKpin, HIGH); /* data transmission phase */ startTimeoutTimer(DSA_TIMEOUT); unsigned int mask = 0x8000; int i; for (i = 0; i < 16; i++ ) { while(digitalRead(_STBpin)) { if(timeOut()) { resetPins(); return false; } } if (digitalRead(_DSApin)) command = command | mask; digitalWrite(_ACKpin, LOW); while(!digitalRead(_STBpin)) { if(timeOut()) { resetPins(); return false; } } digitalWrite(_ACKpin, HIGH); mask = mask >> 1; } /* acknowledge phase */ pinMode(_STBpin, OUTPUT); pinMode(_DSApin, OUTPUT); pinMode(_ACKpin, INPUT); startTimeoutTimer(DSA_TIMEOUT); while(digitalRead(_ACKpin)) { if(timeOut()) { resetPins(); return false; } } if(i != 16) digitalWrite(_DSApin, LOW); digitalWrite(_STBpin, LOW); while(!digitalRead(_ACKpin)) { if(timeOut()) { resetPins(); return false; } } digitalWrite(_DSApin, HIGH); digitalWrite(_STBpin, HIGH); *parameter = lowByte(command); *opcode = highByte(command); resetPins(); return true; }