Thank you, for pointing me in the right direction Jeff.
After dwelling on the subject I managed to make a custom Head block with
reset.
It may be useful for automating measurements in addition to automatic file
sink name changing.
Blocks and examples are available here:
https://github.com/MarcinWachowiak/GNU-Radio-USRP-Beamforming
Head block has a reset callback that may be used with a dump_buff flag that
should dump samples accumulated at the input when callback is triggered.

I am not sure if the calculation of input items to dump is properly
calculated, but it seems to work fine.
int ninput_items = std::min(ninput_items_[0], noutput_items);

if(d_dump_buff) {
//purge buffer after reset - dump remaining input samples
d_dump_buff = false;
consume_each(ninput_items);
return 0;
}

Kind regards,
Marcin Wachowiak


On Sun, 13 Dec 2020 at 15:02, Jeff Long <willco...@gmail.com> wrote:

> No, the Head block tells the framework that it is 'Done' after the
> specified number of items have been processed. The 'Done' state propagates
> through the flowgraph, block threads exit, etc. The only way to get things
> restarted is to rerun the flowgraph.
>
> On Sun, Dec 13, 2020 at 7:21 AM Marcin Wachowiak <
> marcin.r.wachow...@gmail.com> wrote:
>
>> Hello,
>> I would like to ask if there is any possibility to reset Head block after
>> it has signaled Done - after collecting a number of samples. A simple
>> callback would be most preferred but only:  set_length is defined:
>>
>> make: blocks.head(${type.size}*${vlen}, ${num_items})
>> callbacks:
>> - set_length(${num_items})
>> While there is a reset method defined in head_impl.h
>> void reset() { d_ncopied_items = 0; }
>> void set_length(uint64_t nitems) { d_nitems = nitems; }
>>
>> I am unable to call it via call in flowgraph.py generated file due to
>> lack of registered callback. (I already tried setting length to 0 and then
>> back again, but it didn't reset the block). Should I simply register the
>> callback like:
>>
>> templates:
>> imports: from gnuradio import blocks
>> make: blocks.head(${type.size}*${vlen}, ${num_items})
>> callbacks:
>> - set_length(${num_items})
>> - reset()
>>
>> and then rebuild gr-blocks? (and later commit it to GNU Radio github) Or
>> is there a better solution?
>>
>> What I am trying to achieve is triggering a measurement of N samples and
>> saving it to a generated filename via QT GUI checkbox using a Selector and
>> Head sink.
>> The renaming and file generation is already solved via callbacks, but
>> after a single measurement trigger it only generates empty files - no data
>> is fed into them.
>> Flowgraph img:
>> [image: image.png]
>> Triggering the measurement code: the reset() does not make any effect
>>
>> def set_trigger_measurment(self, trigger_measurment):
>> self.trigger_measurment = trigger_measurment
>> self._trigger_measurment_callback(self.trigger_measurment)
>>
>> if trigger_measurment == True:
>> self.blocks_head_0.reset()
>> self.blocks_file_sink_0.open(testbench_setup_pymodule.get_meas_path(self.distance,
>> self.rx_gain, self.src_att, self.physical_aoa))
>>
>> self.blocks_selector_1.set_output_index(self.trigger_measurment)
>>
>> Kind regards,
>> Marcin Wachowiak
>>
>>
>>
>>
>>
>>

Reply via email to