| 55 | } |
| 56 | |
| 57 | bool SubscriptionInterval::copy(void *dst) |
| 58 | { |
| 59 | if (_subscription.copy(dst)) { |
| 60 | const hrt_abstime now = hrt_absolute_time(); |
| 61 | |
| 62 | // make sure we don't set a timestamp before the timer started counting (now - _interval_us would wrap because it's unsigned) |
| 63 | if (now > _interval_us) { |
| 64 | // shift last update time forward, but don't let it get further behind than the interval |
| 65 | _last_update = math::constrain(_last_update + _interval_us, now - _interval_us, now); |
| 66 | |
| 67 | } else { |
| 68 | _last_update = now; |
| 69 | } |
| 70 | |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | } // namespace uORB |