Requested timestamp is in the past error
Posted: Fri Dec 11, 2015 6:02 pm
Hi,
I have the following code snippet to get the current timestamp (after I do a retune) and schedule a receive at this timestamp. My understanding is that the timestamp in the sample buffers will be before the current one and I want to discard those and only want those from the current timestamp (after the retune). However this code always results in the "timestamp is in the past" error. Even if I increment the current timestamp value by sample rate I get the same error:
So I've had to resort to call sync_rx in a loop with the BLADERF_META_FLAG_RX_NOW flag and loop until I get the desired timestamp:
This works fine. But I don't understand why the initial version doesn't.
Thanks for any help,
--Patrick
I have the following code snippet to get the current timestamp (after I do a retune) and schedule a receive at this timestamp. My understanding is that the timestamp in the sample buffers will be before the current one and I want to discard those and only want those from the current timestamp (after the retune). However this code always results in the "timestamp is in the past" error. Even if I increment the current timestamp value by sample rate I get the same error:
Code: Select all
struct bladerf_metadata metadata2;
memset(&metadata2, 0, sizeof(metadata2));
status = bladerf_get_timestamp(this->m_dev,
BLADERF_MODULE_RX,
&metadata2.timestamp);
HANDLE_ERROR("Failed to get current RX timestamp: %s\n");
fprintf(stderr, "Current RX timestamp: 0x%016lx ", metadata2.timestamp);
// Schedule for 1 second in the future.
metadata2.timestamp += this->m_sampleRate;
fprintf(stderr, " 0x%016lx ", metadata2.timestamp);
metadata2.flags = 0;
/* ... Handle signals at current frequency ... */
status = bladerf_sync_rx(this->m_dev,
sample_buffer,
this->m_sampleCount,
&metadata2,
0);
fprintf(stderr, " 0x%016lx\n", metadata2.timestamp);
HANDLE_ERROR("Failed to receive samples at %u Hz: %%s\n",
this->m_frequencies[this->m_frequencyIndex]);
Code: Select all
struct bladerf_metadata metadata2;
memset(&metadata2, 0, sizeof(metadata2));
status = bladerf_get_timestamp(this->m_dev,
BLADERF_MODULE_RX,
&metadata2.timestamp);
HANDLE_ERROR("Failed to get current RX timestamp: %s\n");
fprintf(stderr, "Current RX timestamp: 0x%016lx ", metadata2.timestamp);
metadata = metadata2;
metadata2.flags = BLADERF_META_FLAG_RX_NOW;
/* ... Handle signals at current frequency ... */
while (true) {
status = bladerf_sync_rx(this->m_dev,
sample_buffer,
this->m_sampleCount,
&metadata2,
0);
fprintf(stderr, " 0x%016lx\n", metadata2.timestamp);
HANDLE_ERROR("Failed to receive samples at %u Hz: %%s\n",
this->m_frequencies[this->m_frequencyIndex]);
if (metadata2.timestamp >= metadata.timestamp) {
break;
}
Thanks for any help,
--Patrick