Timestamping Tx Channel

I am trying to send a signal for 20ms then receive right after that 20ms period has ended. I am trying to do this via timestamping of LMS_SendStream and LMS_RecvStream methods of LimeSuite API. However, it seems that timestamping only works in the opposite order, that is, receiving and then transmitting. How can I achieve such a task? I tried the code given below but it does not work. I also tried inserting a dummy receive stream segment before all this, in hopes of getting the hardware timer to start counting but that did not work either. Any thoughts on this?

ret = LMS_SendStream(&tx_stream, tx_buffer, send_cnt, &tx1_metadata, 1000);
rx_metadata.timestamp = tx1_metadata.timestamp + send_cnt;
ret = LMS_RecvStream (&rx_stream, rx_buffer, send_cnt, &rx_metadata, 1000);

Thank you in advance

This is a very important issue that I have to solve asap. Can anybody help please? This is a very simple task that I am suggesting here and lime sdr has to be able to do it.

First, to be able to send a signal at a specific timestamp, you must have at least one RX stream open, because the timestamp is actually a counter linked to the number of samples received.

Second, while it’s possible to ask for a signal to be sent at a specific timestamp, I don’t think it’s possible to ask to receive samples starting at a specific timestamp. See lms_stream_meta_t Struct Reference

uint64_t timestamp
Timestamp is a value of HW counter with a tick based on sample rate. In RX: time when the first sample in the returned buffer was received In TX: time when the first sample in the submitted buffer should be send
bool waitForTimestamp
In TX: wait for the specified HW timestamp before broadcasting data over the air In RX: not used/ignored

From what I understand, in RX, the timestamp value you pass will not be used, and it will be set automatically to the received samples.

You should be able to do it as follow:

  1. Start both RX and TX stream, so that you can use timestamp on the TX side
  2. Read some samples from RX to know the current timestamp used
  3. Schedule a signal to send far enough in the future, to be sure that signal reaches the Lime on time
  4. Continue reading samples from RX, and check the timestamp to only analyze the samples after your signal was sent (if your RX and TX are at the same frequency, you could also analyze the samples where your signal is supposed to be, to make sure the transmission worked)

Depending on your requirements you may need to use 2 threads: 1 for RX, 1 for TX. Your RX thread could continually receive the samples and check their timestamps. It would either discard them or do some analysis.