Get duration of transmitting a message between two XBees


I want to write a simple app, which can tell me how long a signal needs to be transferred from one XBee module to another.

I’m using two XBee Pro S2B modules.

My first intent was to

  1. send a string from module A to module B,
    1a. meanwhile start a timer

  2. then send an automatic response from B to A

  3. recognize the incomming string as the automated answer

  4. meassure delta of time from 1. to 3.

I implemented this and it works fine - except measuring the time… the clock() method of C isn’t working well. It always puts out “-1” … [:(]

Does anyone have an idea of where the problem could be?

Is there a possibility to measure time between two actions?


Hello Christian,

clock() method is not implemented in this API, you should use the RTC functions.

rtc_get_uptime() returns a uint32_t with the second counter
rtc_get_ms_uptime() returns a uint32_t with the milliseconds counter (resolution of 4 ms).

So you should read the value of the counter before sending the string and immediately after receiving and substract them.

Another solution could be to ad a high-resolution timer and program to be periodic with the desired resolution and increase a counter in the callback.

Best regards,