Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gr-soapy: Add timestamp tag to source output #6106

Closed
NZSmartie opened this issue Aug 22, 2022 · 2 comments · Fixed by #6117
Closed

gr-soapy: Add timestamp tag to source output #6106

NZSmartie opened this issue Aug 22, 2022 · 2 comments · Fixed by #6117

Comments

@NZSmartie
Copy link
Contributor

Feature Description

SoapySDR will provide the hardware timestamp of the received buffer in the form of nanoseconds. gr-soapy's source block discards this timetamp time_ns when outputting items.

int source_impl::general_work(int noutput_items,
[[maybe_unused]] gr_vector_int& ninput_items,
[[maybe_unused]] gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items)
{
long long int time_ns = 0;
int flags = 0;
const long timeout_us = 500000; // 0.5 sec
int nout = 0;
for (;;) {
// No command handlers while reading
int result;
{
std::lock_guard<std::mutex> l(d_device_mutex);
result = d_device->readStream(
d_stream, output_items.data(), noutput_items, flags, time_ns, timeout_us);
}
if (result >= 0) {
nout = result;
break;
}
switch (result) {
// Retry on overflow. Data has been lost.
case SOAPY_SDR_OVERFLOW:
std::cerr << "sO" << std::flush;
continue;
// Yield back to scheduler on timeout.
case SOAPY_SDR_TIMEOUT:
break;
// Report and yield back to scheduler on other errors.
default:
d_logger->warn("Soapy source error: {:s}", SoapySDR::errToStr(result));
break;
}
break;
};
return nout;
}

Can we add a time tag to the output much like gr-uhd does (and possible the frequency and rate as well?)

this->add_item_tag(i, nitems_written(0), TIME_KEY, val, _id);
this->add_item_tag(
i, nitems_written(0), RATE_KEY, pmt::from_double(_samp_rate), _id);
this->add_item_tag(i,
nitems_written(0),
FREQ_KEY,
pmt::from_double(this->get_center_freq(i)),
_id);

Feature Urgency

medium (would be nice to have in the near future)

More Information

No response

@willcode
Copy link
Member

Since hardware timestamps are not provided by all hardware, there would need to be a switch for this.

@NZSmartie
Copy link
Contributor Author

AFAIK there's no easy way to detect if a Soapy driver's Stream API supports timestamps, it just gets filled out if supported. untouched otherwise.
the drivers that support timestamps are:

These Soapy drivers don't populate the timestanp:

Since each driver supported is defined as a seperate source and sink block in gr-soapy. it might be worth while adding a argument to the other_settings parameter.

Alternatively, since each driver that doesn't support hardware timestamps, does not alter its value. Setting it to -1 prior to calling readStream() and checking for any positive value be a requirement for adding the tag.

NZSmartie added a commit to NZSmartie/gnuradio that referenced this issue Aug 28, 2022
Tag the output stream with the hardware based timestamp if populated by
the SoapySDR driver.

Closes gnuradio#6106

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
NZSmartie added a commit to NZSmartie/gnuradio that referenced this issue Sep 4, 2022
Tag the output stream with the hardware based timestamp if populated by
the SoapySDR driver.

Closes gnuradio#6106

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
NZSmartie added a commit to NZSmartie/gnuradio that referenced this issue Sep 4, 2022
Tag the output stream with the frequency, sample rate and hardware time.
Following gr-uhd's rx_freq, rx_rate and rx_time tags.

Closes gnuradio#6106

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
NZSmartie added a commit to NZSmartie/gnuradio that referenced this issue Sep 7, 2022
Tag the output stream with the frequency, sample rate and hardware time.
Following gr-uhd's rx_freq, rx_rate and rx_time tags.

Closes gnuradio#6106

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
mormj pushed a commit that referenced this issue Sep 12, 2022
Tag the output stream with the frequency, sample rate and hardware time.
Following gr-uhd's rx_freq, rx_rate and rx_time tags.

Closes #6106

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
IvanNovakQB pushed a commit to quantum-bit/gnuradio that referenced this issue Oct 5, 2022
Tag the output stream with the frequency, sample rate and hardware time.
Following gr-uhd's rx_freq, rx_rate and rx_time tags.

Closes gnuradio#6106

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
willcode pushed a commit to willcode/gnuradio that referenced this issue Oct 8, 2022
Tag the output stream with the frequency, sample rate and hardware time.
Following gr-uhd's rx_freq, rx_rate and rx_time tags.

Closes gnuradio#6106

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
(cherry picked from commit 3eea105)
Signed-off-by: Jeff Long <willcode4@gmail.com>
willcode pushed a commit that referenced this issue Oct 8, 2022
Tag the output stream with the frequency, sample rate and hardware time.
Following gr-uhd's rx_freq, rx_rate and rx_time tags.

Closes #6106

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
(cherry picked from commit 3eea105)
Signed-off-by: Jeff Long <willcode4@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants