From 526ef8ac236198f801bbcb24296fb67aa883ff7b Mon Sep 17 00:00:00 2001 From: Rex Schilasky <49162693+rex-schilasky@users.noreply.github.com> Date: Fri, 17 May 2024 13:53:10 +0200 Subject: [PATCH] [core] send frequency calculation fixed in case of unconnected publisher (#1606) --- ecal/core/src/readwrite/ecal_writer.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ecal/core/src/readwrite/ecal_writer.cpp b/ecal/core/src/readwrite/ecal_writer.cpp index 3b1a1603a..6f4548e52 100644 --- a/ecal/core/src/readwrite/ecal_writer.cpp +++ b/ecal/core/src/readwrite/ecal_writer.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -233,13 +233,6 @@ namespace eCAL size_t CDataWriter::Write(CPayloadWriter& payload_, long long time_, long long id_) { - { - // we should think about if we would like to potentially use the `time_` variable to tick with (but we would need the same base for checking incoming samples then.... - const auto send_time = std::chrono::steady_clock::now(); - const std::lock_guard lock(m_frequency_calculator_mtx); - m_frequency_calculator.addTick(send_time); - } - // get payload buffer size (one time, to avoid multiple computations) const size_t payload_buf_size(payload_.GetSize()); @@ -508,6 +501,15 @@ namespace eCAL { // increase write clock m_clock++; + + // update send frequency + { + // we should think about if we would like to potentially use the `time_` variable to tick with (but we would need the same base for checking incoming samples then.... + const auto send_time = std::chrono::steady_clock::now(); + const std::lock_guard lock(m_frequency_calculator_mtx); + m_frequency_calculator.addTick(send_time); + } + } std::string CDataWriter::Dump(const std::string& indent_ /* = "" */)