LCOV - code coverage report
Current view: top level - AP_HAL - Scheduler.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 17 30 56.7 %
Date: 2026-09-09 11:02:08 Functions: 4 6 66.7 %

          Line data    Source code
       1             : #include "Scheduler.h"
       2             : #include "AP_HAL.h"
       3             : #include <stdio.h>
       4             : 
       5             : using namespace AP_HAL;
       6             : 
       7             : extern const AP_HAL::HAL& hal;
       8             : 
       9        3733 : void Scheduler::register_delay_callback(AP_HAL::Proc proc,
      10             :                                         uint16_t min_time_ms)
      11             : {
      12        3733 :     _delay_cb = proc;
      13        3733 :     _min_delay_cb_ms = min_time_ms;
      14        3733 : }
      15             : 
      16     2619247 : void Scheduler::call_delay_cb()
      17             : {
      18     2619247 :     if (_delay_cb == nullptr) {
      19      203843 :         return;
      20             :     }
      21     2415404 :     if (_in_delay_callback) {
      22             :         // don't recurse!
      23           0 :         return;
      24             :     }
      25     2415404 :     _in_delay_callback = true;
      26     2415404 :     _delay_cb();
      27     2415404 :     _in_delay_callback = false;
      28             : }
      29             : 
      30     1776239 : ExpectDelay::ExpectDelay(uint32_t ms)
      31             : {
      32     1776239 :     hal.scheduler->expect_delay_ms(ms);
      33     1776239 : }
      34             : 
      35     1776239 : ExpectDelay::~ExpectDelay()
      36             : {
      37     1776239 :     hal.scheduler->expect_delay_ms(0);
      38     1776239 : }
      39             : 
      40             : /*
      41             :   implement TimeCheck class for TIME_CHECK() support
      42             :  */
      43           0 : TimeCheck::TimeCheck(uint32_t _limit_ms, const char *_file, uint32_t _line) :
      44           0 :     limit_ms(_limit_ms),
      45           0 :     line(_line),
      46           0 :     file(_file)
      47             : {
      48           0 :     start_ms = AP_HAL::millis();
      49           0 : }
      50             : 
      51           0 : TimeCheck::~TimeCheck()
      52             : {
      53           0 :     const uint32_t end_ms = AP_HAL::millis();
      54           0 :     const uint32_t delta_ms = end_ms - start_ms;
      55           0 :     if (delta_ms > limit_ms) {
      56           0 :         ::printf("Delta %u at %s:%u\n", unsigned(delta_ms), file, unsigned(line));
      57             :     }
      58           0 : }

Generated by: LCOV version 1.14