Requested timestamp is in the past error

Having issues with the site, hardware, source code, or any other issues?
Post Reply
wpats
Posts: 9
Joined: Tue Aug 18, 2015 8:13 pm

Requested timestamp is in the past error

Post by wpats »

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:

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]);
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:

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;
    }
This works fine. But I don't understand why the initial version doesn't.

Thanks for any help,

--Patrick
wpats
Posts: 9
Joined: Tue Aug 18, 2015 8:13 pm

Re: Requested timestamp is in the past error

Post by wpats »

Hi Jon,

I tried building the examples and found that the libbladeRF_example_sync_tx_meta works just fine. As far as I can tell I am doing the same sequence of API calls as that but I get the error. I'm not sure how the set the DEBUG log level. I ran cmake with -DENABLE_LIBBLADERF_SYNC_LOG_VERBOSE=Yes and built but that did not produce any output.

I have attached a tar file with reduced repro program. It includes a Makefile and a run_scan script which should repro the problem.

Thanks for helping me debug this,

--Patrick
Post Reply