예제 #1
0
std::vector<std::string> Arduino::genericIOReportTask(const std::string &stringToSend, const std::string &header, const std::string &endHeader, double delay)
{
    std::lock_guard<std::mutex> ioLock{this->m_ioMutex};
    if (!this->m_ioStream->isOpen()) {
        this->m_ioStream->openPort();
        GeneralUtilities::delayMilliseconds(BOOTLOADER_BOOT_TIME);
    }
    this->m_ioStream->writeString(stringToSend);
    GeneralUtilities::delayMilliseconds(delay);
    std::unique_ptr<std::string> returnString{std::make_unique<std::string>("")};
    EventTimer eventTimer;
    eventTimer.start();
    do {
        std::string str{this->m_ioStream->readStringUntil("}")};
        if (str != "") {
            *returnString = str;
            break;
        }
        eventTimer.update();
    } while (eventTimer.totalMilliseconds() < this->m_ioStream->timeout());
    if (GeneralUtilities::startsWith(*returnString, header) && GeneralUtilities::endsWith(*returnString, endHeader)) {
        *returnString = returnString->substr(static_cast<std::string>(header).length() + 1);
        *returnString = returnString->substr(0, returnString->length()-1);
    } else {
        return std::vector<std::string>{};
    }
    return GeneralUtilities::parseToVector(*returnString, ';');
}
예제 #2
0
void Session::addToPendingAcks(qint64 msgId) {
    EventTimer *t = new EventTimer(msgId, ACK_TIMEOUT, this);
    connect(t, &EventTimer::timerTimeout, this, &Session::ack);
    t->start(); //timeout of 60 secs
    m_pendingAcks[msgId] = t;
    if (m_pendingAcks.size() > MAX_PENDING_ACKS) {
        ackAll();
    }
}
예제 #3
0
파일: ptp_timers.c 프로젝트: da-phil/ptpd
void 
timerStart(IntervalTimer * itimer, double interval)
{
	if (itimer == NULL)
		return;

        if(interval > PTPTIMER_MAX_INTERVAL) {
            interval = PTPTIMER_MAX_INTERVAL;
        }

	itimer->interval = interval;
	EventTimer* timer = (EventTimer *)(itimer->data);

	timer->start(timer, interval);
}