Skip to content

Commit

Permalink
add samples since tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Feb 6, 2024
1 parent 608b3f3 commit 21b0827
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/iq_inference_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ iq_inference_impl::iq_inference_impl(const std::string &tag, size_t vlen,
min_peak_points_(min_peak_points), model_server_(model_server),
confidence_(confidence), n_inference_(n_inference), samp_rate_(samp_rate),
inference_count_(0), running_(true), last_rx_freq_(0), last_rx_time_(0),
inference_connected_(false) {
inference_connected_(false), samples_since_tag_(0) {
samples_lookback_.reset(new gr_complex[vlen * sample_buffer]);
unsigned int alignment = volk_get_alignment();
total_.reset((float *)volk_malloc(sizeof(float), alignment));
Expand Down Expand Up @@ -422,7 +422,8 @@ void iq_inference_impl::forecast(int noutput_items,
void iq_inference_impl::process_items_(size_t power_in_count,
uint64_t &power_read,
const float *&power_in) {
for (size_t i = 0; i < power_in_count; ++i, power_in += vlen_) {
for (size_t i = 0; i < power_in_count;
++i, power_in += vlen_, samples_since_tag_ += vlen_) {
size_t j = (power_read + i) % sample_buffer_;
volk_32f_index_max_16u(max_.get(), power_in, vlen_);
float power_max = power_in[*max_];
Expand All @@ -436,7 +437,8 @@ void iq_inference_impl::process_items_(size_t power_in_count,
continue;
}
output_item_type output_item;
output_item.rx_time = last_rx_time_;
output_item.rx_time =
last_rx_time_ + (samples_since_tag_ / TIME_T(samp_rate_));
output_item.rx_freq = last_rx_freq_;
output_item.sample_count = vlen_;
output_item.samples = new gr_complex[output_item.sample_count];
Expand Down Expand Up @@ -509,6 +511,7 @@ int iq_inference_impl::general_work(int noutput_items,
d_logger->debug("new rx_freq tag: {}", rx_freq);
last_rx_freq_ = rx_freq;
last_rx_time_ = rx_time;
samples_since_tag_ = 0;
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/iq_inference_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class iq_inference_impl : public iq_inference, base_impl {
size_t n_inference_;
int samp_rate_;
size_t inference_count_;
size_t samples_since_tag_;
boost::lockfree::spsc_queue<output_item_type> inference_q_{MAX_INFERENCE};
boost::lockfree::spsc_queue<std::string> json_q_{MAX_INFERENCE};
bool running_;
Expand Down

0 comments on commit 21b0827

Please sign in to comment.