From ce3b56e7681123f8ac5971056dde35efd784a9c0 Mon Sep 17 00:00:00 2001 From: consti10 Date: Sat, 19 Dec 2020 20:00:58 +0100 Subject: [PATCH] default to flush interval of -1 (which means behaviour is exactly as it was without a flush interval before) --- src/rx.cpp | 4 ++-- src/tx.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rx.cpp b/src/rx.cpp index 68fdc8d5..8faee132 100644 --- a/src/rx.cpp +++ b/src/rx.cpp @@ -403,13 +403,13 @@ radio_loop(std::shared_ptr agg,const std::vector rxInte if (rc == 0){ // timeout expired - // smaller than 0 means no flush enabled if(flush_interval.count()>0){ + // smaller than 0 means no flush enabled + // else we didn't receive data for FLUSH_INTERVAL ms agg->flushRxRing(); } continue; } - for (int i = 0; rc > 0 && i < N_RECEIVERS; i++) { if (fds[i].revents & (POLLERR | POLLNVAL)) { throw std::runtime_error("socket error!"); diff --git a/src/tx.cpp b/src/tx.cpp index d9627c9a..14257df6 100644 --- a/src/tx.cpp +++ b/src/tx.cpp @@ -125,6 +125,7 @@ void WBTransmitter::loop() { } firstTime=false; } + // we set the timeout earlier when creating the socket const ssize_t message_length = recvfrom(mInputSocket, buf.data(), MAX_PAYLOAD_SIZE, 0, nullptr, nullptr); if(std::chrono::steady_clock::now()>=log_ts){ const auto runTimeMs=std::chrono::duration_cast(std::chrono::steady_clock::now()-INIT_TIME).count(); @@ -147,6 +148,7 @@ void WBTransmitter::loop() { // timeout if(FLUSH_INTERVAL.count()>0){ // smaller than 0 means no flush enabled + // else we didn't receive data for FLUSH_INTERVAL ms finishCurrentBlock(); } continue;