Skip to content

Commit

Permalink
add tag_now parameter to retune*fft
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Oct 2, 2023
1 parent 82dd8fb commit 292daa3
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 38 deletions.
7 changes: 5 additions & 2 deletions grc/iqtlabs_retune_fft.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ documentation: |-
description: a string description to be included with each update.
rotate_secs: if > 0, use a new epoch timestamped directory every N seconds.
pre_fft: if True, tuning is controlled by the retune_pre_fft block.
tag_now: if True, send "tag:now" tag along with tuning message.
example JSON output:
{ "ts": <epoch time>, "sweep start": <epoch time>,
Expand All @@ -64,7 +65,7 @@ templates:
iqtlabs.retune_fft(${tag}, ${vlen}, ${nfft}, ${samp_rate}, ${freq_start},
${freq_end}, ${tune_step_hz}, ${tune_step_fft}, ${skip_tune_step_fft},
${fft_min}, ${fft_max}, ${sdir}, ${write_step_fft}, ${bucket_range},
${tuning_ranges}, ${description}, ${rotate_secs}, ${pre_fft})
${tuning_ranges}, ${description}, ${rotate_secs}, ${pre_fft}, ${tag_now})
cpp_templates:
includes: ['#include <gnuradio/iqtlabs/retune_fft.h>']
Expand All @@ -74,7 +75,7 @@ cpp_templates:
${samp_rate}, ${freq_start}, ${freq_end}, ${tune_step_hz}, ${tune_step_fft},
${skip_tune_step_fft}, ${fft_min}, ${fft_max}, ${sdir}, ${write_step_fft},
${bucket_range}, ${tuning_ranges}, ${description}, ${rotate_secs},
${pre_fft});
${pre_fft}, ${tag_now});
link: ['libgnuradio-iqtlabs.so']

asserts:
Expand Down Expand Up @@ -121,6 +122,8 @@ parameters:
dtype: string
- id: rotate_secs
dtype: int
- id: tag_now
dtype: bool

inputs:
- label: input
Expand Down
6 changes: 4 additions & 2 deletions grc/iqtlabs_retune_pre_fft.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ templates:
${nfft}, ${fft_batch_size},
${tag}, ${freq_start}, ${freq_end},
${tune_step_hz}, ${tune_step_fft}, ${skip_tune_step_fft},
${tuning_ranges})
${tuning_ranges}, ${tag_now})
cpp_templates:
includes: ['#include <gnuradio/iqtlabs/retune_pre_fft.h>']
Expand All @@ -21,7 +21,7 @@ cpp_templates:
${nfft}, ${fft_batch_size},
${tag}, {freq_start}, ${freq_end},
${tune_step_hz}, ${tune_step_fft}, ${skip_tune_step_fft},
${tuning_ranges});
${tuning_ranges}, ${tag_now});
link: ['libgnuradio-iqtlabs.so']

parameters:
Expand All @@ -44,6 +44,8 @@ parameters:
dtype: int
- id: tuning_ranges
dtype: string
- id: tag_now
dtype: bool

inputs:
- label: input
Expand Down
2 changes: 1 addition & 1 deletion include/gnuradio/iqtlabs/retune_fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class IQTLABS_API retune_fft : virtual public gr::block {
const std::string &sdir, uint64_t write_step_fft,
double bucket_range, const std::string &tuning_ranges,
const std::string &description, uint64_t rotate_secs,
bool pre_fft);
bool pre_fft, bool tag_now);
};

} // namespace iqtlabs
Expand Down
2 changes: 1 addition & 1 deletion include/gnuradio/iqtlabs/retune_pre_fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class IQTLABS_API retune_pre_fft : virtual public gr::sync_decimator {
uint64_t freq_start, uint64_t freq_end,
uint64_t tune_step_hz, uint64_t tune_step_fft,
uint64_t skip_tune_step_fft,
const std::string &tuning_ranges);
const std::string &tuning_ranges, bool tag_now);
};

} // namespace iqtlabs
Expand Down
9 changes: 9 additions & 0 deletions lib/base_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,14 @@ void base_impl::get_tags(const pmt::pmt_t want_tag,
}
}
}

pmt::pmt_t base_impl::tune_rx_msg(uint64_t tune_freq, bool tag_now) {
pmt::pmt_t tune_rx = pmt::make_dict();
tune_rx = pmt::dict_add(tune_rx, pmt::mp("freq"), pmt::from_long(tune_freq));
if (tag_now) {
tune_rx = pmt::dict_add(tune_rx, pmt::mp("tag"), pmt::mp("now"));
}
return tune_rx;
}
} /* namespace iqtlabs */
} /* namespace gr */
1 change: 1 addition & 0 deletions lib/base_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class base_impl {
void get_tags(const pmt::pmt_t want_tag, const std::vector<tag_t> &all_tags,
std::vector<tag_t> &rx_freq_tags, std::vector<double> &rx_times,
size_t in_count);
pmt::pmt_t tune_rx_msg(uint64_t tune_freq, bool tag_now);
};
} /* namespace iqtlabs */
} /* namespace gr */
29 changes: 15 additions & 14 deletions lib/retune_fft_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,19 @@ const pmt::pmt_t JSON_KEY = pmt::mp("json");
const boost::iostreams::zstd_params zstd_params =
boost::iostreams::zstd_params(boost::iostreams::zstd::default_compression);

retune_fft::sptr retune_fft::make(
const std::string &tag, size_t vlen, size_t nfft, uint64_t samp_rate,
uint64_t freq_start, uint64_t freq_end, uint64_t tune_step_hz,
uint64_t tune_step_fft, uint64_t skip_tune_step_fft, double fft_min,
double fft_max, const std::string &sdir, uint64_t write_step_fft,
double bucket_range, const std::string &tuning_ranges,
const std::string &description, uint64_t rotate_secs, bool pre_fft) {
retune_fft::sptr
retune_fft::make(const std::string &tag, size_t vlen, size_t nfft,
uint64_t samp_rate, uint64_t freq_start, uint64_t freq_end,
uint64_t tune_step_hz, uint64_t tune_step_fft,
uint64_t skip_tune_step_fft, double fft_min, double fft_max,
const std::string &sdir, uint64_t write_step_fft,
double bucket_range, const std::string &tuning_ranges,
const std::string &description, uint64_t rotate_secs,
bool pre_fft, bool tag_now) {
return gnuradio::make_block_sptr<retune_fft_impl>(
tag, vlen, nfft, samp_rate, freq_start, freq_end, tune_step_hz,
tune_step_fft, skip_tune_step_fft, fft_min, fft_max, sdir, write_step_fft,
bucket_range, tuning_ranges, description, rotate_secs, pre_fft);
bucket_range, tuning_ranges, description, rotate_secs, pre_fft, tag_now);
}

retune_fft_impl::retune_fft_impl(
Expand All @@ -237,7 +239,8 @@ retune_fft_impl::retune_fft_impl(
uint64_t tune_step_fft, uint64_t skip_tune_step_fft, double fft_min,
double fft_max, const std::string &sdir, uint64_t write_step_fft,
double bucket_range, const std::string &tuning_ranges,
const std::string &description, uint64_t rotate_secs, bool pre_fft)
const std::string &description, uint64_t rotate_secs, bool pre_fft,
bool tag_now)
: gr::block("retune_fft",
gr::io_signature::make(1 /* min inputs */, 1 /* max inputs */,
vlen * sizeof(input_type)),
Expand All @@ -249,7 +252,8 @@ retune_fft_impl::retune_fft_impl(
fft_min_(fft_min), fft_max_(fft_max), sample_(nfft), sample_count_(0),
sdir_(sdir), write_step_fft_(write_step_fft),
write_step_fft_count_(write_step_fft), bucket_range_(bucket_range),
description_(description), rotate_secs_(rotate_secs), pre_fft_(pre_fft) {
description_(description), rotate_secs_(rotate_secs), pre_fft_(pre_fft),
tag_now_(tag_now) {
bucket_offset_ = round(float((vlen_ - round(bucket_range_ * vlen_)) / 2));
outbuf_p.reset(new boost::iostreams::filtering_ostream());
message_port_register_out(TUNE_KEY);
Expand Down Expand Up @@ -286,10 +290,7 @@ void retune_fft_impl::close_() {

void retune_fft_impl::send_retune_(uint64_t tune_freq) {
d_logger->debug("retuning to {}", tune_freq);
pmt::pmt_t tune_rx = pmt::make_dict();
tune_rx = pmt::dict_add(tune_rx, pmt::mp("freq"), pmt::from_long(tune_freq));
tune_rx = pmt::dict_add(tune_rx, pmt::mp("tag"), pmt::mp("now"));
message_port_pub(TUNE_KEY, tune_rx);
message_port_pub(TUNE_KEY, tune_rx_msg(tune_freq, tag_now_));
}

void retune_fft_impl::retune_now_() {
Expand Down
3 changes: 2 additions & 1 deletion lib/retune_fft_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class retune_fft_impl : public retune_fft, base_impl, retuner_impl {
std::string sdir_;
std::string description_;
bool pre_fft_;
bool tag_now_;

double fft_min_;
double fft_max_;
Expand All @@ -268,7 +269,7 @@ class retune_fft_impl : public retune_fft, base_impl, retuner_impl {
const std::string &sdir, uint64_t write_step_fft,
double bucket_range, const std::string &tuning_ranges,
const std::string &description, uint64_t rotate_secs,
bool pre_fft);
bool pre_fft, bool tag_now);
~retune_fft_impl();
void forecast(int noutput_items, gr_vector_int &ninput_items_required);
int general_work(int noutput_items, gr_vector_int &ninput_items,
Expand Down
24 changes: 10 additions & 14 deletions lib/retune_pre_fft_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,17 @@ retune_pre_fft::make(size_t nfft, size_t fft_batch_size, const std::string &tag,
uint64_t freq_start, uint64_t freq_end,
uint64_t tune_step_hz, uint64_t tune_step_fft,
uint64_t skip_tune_step_fft,
const std::string &tuning_ranges) {
const std::string &tuning_ranges, bool tag_now) {
return gnuradio::make_block_sptr<retune_pre_fft_impl>(
nfft, fft_batch_size, tag, freq_start, freq_end, tune_step_hz,
tune_step_fft, skip_tune_step_fft, tuning_ranges);
tune_step_fft, skip_tune_step_fft, tuning_ranges, tag_now);
}

retune_pre_fft_impl::retune_pre_fft_impl(size_t nfft, size_t fft_batch_size,
const std::string &tag,
uint64_t freq_start, uint64_t freq_end,
uint64_t tune_step_hz,
uint64_t tune_step_fft,
uint64_t skip_tune_step_fft,
const std::string &tuning_ranges)
retune_pre_fft_impl::retune_pre_fft_impl(
size_t nfft, size_t fft_batch_size, const std::string &tag,
uint64_t freq_start, uint64_t freq_end, uint64_t tune_step_hz,
uint64_t tune_step_fft, uint64_t skip_tune_step_fft,
const std::string &tuning_ranges, bool tag_now)
: gr::sync_decimator(
"retune_pre_fft",
gr::io_signature::make(1 /* min inputs */, 1 /* max inputs */,
Expand All @@ -238,18 +236,16 @@ retune_pre_fft_impl::retune_pre_fft_impl(size_t nfft, size_t fft_batch_size,
nfft * fft_batch_size /*<+decimation+>*/),
retuner_impl(freq_start, freq_end, tune_step_hz, tune_step_fft,
skip_tune_step_fft, tuning_ranges),
nfft_(nfft), fft_batch_size_(fft_batch_size), tag_(pmt::intern(tag)) {
nfft_(nfft), fft_batch_size_(fft_batch_size), tag_(pmt::intern(tag)),
tag_now_(tag_now) {
message_port_register_out(TUNE_KEY);
}

retune_pre_fft_impl::~retune_pre_fft_impl() {}

void retune_pre_fft_impl::send_retune_(uint64_t tune_freq) {
d_logger->debug("retuning to {}", tune_freq);
pmt::pmt_t tune_rx = pmt::make_dict();
tune_rx = pmt::dict_add(tune_rx, pmt::mp("freq"), pmt::from_long(tune_freq));
tune_rx = pmt::dict_add(tune_rx, pmt::mp("tag"), pmt::mp("now"));
message_port_pub(TUNE_KEY, tune_rx);
message_port_pub(TUNE_KEY, tune_rx_msg(tune_freq, tag_now_));
}

void retune_pre_fft_impl::retune_now_() {
Expand Down
3 changes: 2 additions & 1 deletion lib/retune_pre_fft_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,14 @@ class retune_pre_fft_impl : public retune_pre_fft, base_impl, retuner_impl {
size_t nfft_;
size_t fft_batch_size_;
pmt::pmt_t tag_;
bool tag_now_;

public:
retune_pre_fft_impl(size_t nfft, size_t fft_batch_size,
const std::string &tag, uint64_t freq_start,
uint64_t freq_end, uint64_t tune_step_hz,
uint64_t tune_step_fft, uint64_t skip_tune_step_fft,
const std::string &tuning_ranges);
const std::string &tuning_ranges, bool tag_now);
~retune_pre_fft_impl();

int work(int noutput_items, gr_vector_const_void_star &input_items,
Expand Down
3 changes: 2 additions & 1 deletion python/iqtlabs/bindings/retune_fft_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(retune_fft.h) */
/* BINDTOOL_HEADER_FILE_HASH(291a634c39f0e6860211913645932d56) */
/* BINDTOOL_HEADER_FILE_HASH(b28088ca33ba5c42293eb74f6c90de2b) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand Down Expand Up @@ -55,6 +55,7 @@ void bind_retune_fft(py::module& m)
py::arg("description"),
py::arg("rotate_secs"),
py::arg("pre_fft"),
py::arg("tag_now"),
D(retune_fft, make))


Expand Down
3 changes: 2 additions & 1 deletion python/iqtlabs/bindings/retune_pre_fft_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(retune_pre_fft.h) */
/* BINDTOOL_HEADER_FILE_HASH(a9b4051c99f17cef5206780055ededed) */
/* BINDTOOL_HEADER_FILE_HASH(8b85264423963500dfd62650d0c0055a) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand Down Expand Up @@ -46,6 +46,7 @@ void bind_retune_pre_fft(py::module& m)
py::arg("tune_step_fft"),
py::arg("skip_tune_step_fft"),
py::arg("tuning_ranges"),
py::arg("tag_now"),
D(retune_pre_fft, make))


Expand Down
2 changes: 2 additions & 0 deletions python/iqtlabs/qa_retune_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def retune_fft(self, fft_roll):
tune_step_fft,
skip_tune_step_fft,
tuning_ranges,
False,
)

iqtlabs_retune_fft_0 = retune_fft(
Expand All @@ -316,6 +317,7 @@ def retune_fft(self, fft_roll):
"a text description",
3600,
True,
False,
)
pdu_decoder_0 = pdu_decoder()
fft_vxx_0 = fft.fft_vcc(points, True, [], fft_roll, 1)
Expand Down

0 comments on commit 292daa3

Please sign in to comment.