From 0776a48b3164d9a47e59464eddc0dc422fe36e35 Mon Sep 17 00:00:00 2001 From: Yuriy Kashirin Date: Mon, 9 Feb 2026 12:46:50 +0200 Subject: [PATCH] Fixed work() return value `work` method always return `noutput_items` while streaming. But this is not always correct. The block produces no more samples than are left in the current buffer. The number of these samples is sometimes less than noutput_items. Return value is changed to the number of samples actually written to the output buffer. --- lib/fobos_sdr_impl.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/fobos_sdr_impl.cc b/lib/fobos_sdr_impl.cc index a119e13..e9c5fb8 100644 --- a/lib/fobos_sdr_impl.cc +++ b/lib/fobos_sdr_impl.cc @@ -195,6 +195,7 @@ namespace gr gr_vector_void_star& output_items) { auto out = static_cast(output_items[0]); + int produced_items = 0; if (!_running) { printf("%d ", noutput_items); @@ -218,6 +219,7 @@ namespace gr samples_count = noutput_items; } memcpy((float*)out, buff, samples_count * 2 * sizeof(float)); + produced_items = samples_count; _rx_pos_r += samples_count; if (_rx_pos_r >= _rx_buff_len) { @@ -231,7 +233,7 @@ namespace gr { printf("u"); } - return noutput_items; + return produced_items; } //====================================================================== void fobos_sdr_impl::read_samples_callback(float *buf, uint32_t buf_length, void *ctx)