mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-03 04:03:59 -04:00
AP_HAL_SITL: Scheduler remove unreachable code & minor fix
usleep wasn't reached since synthetic clock is always used correct style make constructor explicit use c++ cast
This commit is contained in:
parent
63b3618fc7
commit
ab9e88299f
@ -5,7 +5,6 @@
|
||||
#include "Scheduler.h"
|
||||
#include "UARTDriver.h"
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <fenv.h>
|
||||
|
||||
using namespace HALSITL;
|
||||
@ -43,11 +42,7 @@ void Scheduler::delay_microseconds(uint16_t usec)
|
||||
if (dtime >= usec) {
|
||||
break;
|
||||
}
|
||||
if (_stopped_clock_usec) {
|
||||
_sitlState->wait_clock(start + usec);
|
||||
} else {
|
||||
usleep(usec - dtime);
|
||||
}
|
||||
_sitlState->wait_clock(start + usec);
|
||||
} while (true);
|
||||
}
|
||||
|
||||
@ -83,7 +78,6 @@ void Scheduler::register_timer_process(AP_HAL::MemberProc proc)
|
||||
_timer_proc[_num_timer_procs] = proc;
|
||||
_num_timer_procs++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Scheduler::register_io_process(AP_HAL::MemberProc proc)
|
||||
@ -98,7 +92,6 @@ void Scheduler::register_io_process(AP_HAL::MemberProc proc)
|
||||
_io_proc[_num_io_procs] = proc;
|
||||
_num_io_procs++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Scheduler::register_timer_failsafe(AP_HAL::Proc failsafe, uint32_t period_us)
|
||||
@ -141,10 +134,11 @@ void Scheduler::system_initialized() {
|
||||
}
|
||||
|
||||
void Scheduler::sitl_end_atomic() {
|
||||
if (_nested_atomic_ctr == 0)
|
||||
if (_nested_atomic_ctr == 0) {
|
||||
hal.uartA->println("NESTED ATOMIC ERROR");
|
||||
else
|
||||
} else {
|
||||
_nested_atomic_ctr--;
|
||||
}
|
||||
}
|
||||
|
||||
void Scheduler::reboot(bool hold_in_bootloader)
|
||||
|
@ -10,39 +10,39 @@
|
||||
/* Scheduler implementation: */
|
||||
class HALSITL::Scheduler : public AP_HAL::Scheduler {
|
||||
public:
|
||||
Scheduler(SITL_State *sitlState);
|
||||
explicit Scheduler(SITL_State *sitlState);
|
||||
static Scheduler *from(AP_HAL::Scheduler *scheduler) {
|
||||
return static_cast<HALSITL::Scheduler*>(scheduler);
|
||||
}
|
||||
|
||||
/* AP_HAL::Scheduler methods */
|
||||
|
||||
void init();
|
||||
void delay(uint16_t ms);
|
||||
void delay_microseconds(uint16_t us);
|
||||
void register_delay_callback(AP_HAL::Proc, uint16_t min_time_ms);
|
||||
void init();
|
||||
void delay(uint16_t ms);
|
||||
void delay_microseconds(uint16_t us);
|
||||
void register_delay_callback(AP_HAL::Proc, uint16_t min_time_ms);
|
||||
|
||||
void register_timer_process(AP_HAL::MemberProc);
|
||||
void register_io_process(AP_HAL::MemberProc);
|
||||
void suspend_timer_procs();
|
||||
void resume_timer_procs();
|
||||
void register_timer_process(AP_HAL::MemberProc);
|
||||
void register_io_process(AP_HAL::MemberProc);
|
||||
void suspend_timer_procs();
|
||||
void resume_timer_procs();
|
||||
|
||||
bool in_timerprocess();
|
||||
bool in_timerprocess();
|
||||
|
||||
void register_timer_failsafe(AP_HAL::Proc, uint32_t period_us);
|
||||
void register_timer_failsafe(AP_HAL::Proc, uint32_t period_us);
|
||||
|
||||
void system_initialized();
|
||||
void system_initialized();
|
||||
|
||||
void reboot(bool hold_in_bootloader);
|
||||
void reboot(bool hold_in_bootloader);
|
||||
|
||||
bool interrupts_are_blocked(void) {
|
||||
bool interrupts_are_blocked(void) {
|
||||
return _nested_atomic_ctr != 0;
|
||||
}
|
||||
|
||||
void sitl_begin_atomic() {
|
||||
void sitl_begin_atomic() {
|
||||
_nested_atomic_ctr++;
|
||||
}
|
||||
void sitl_end_atomic();
|
||||
void sitl_end_atomic();
|
||||
|
||||
static void timer_event() {
|
||||
_run_timer_procs(true);
|
||||
@ -67,16 +67,12 @@ private:
|
||||
static AP_HAL::MemberProc _io_proc[SITL_SCHEDULER_MAX_TIMER_PROCS];
|
||||
static uint8_t _num_timer_procs;
|
||||
static uint8_t _num_io_procs;
|
||||
static bool _in_timer_proc;
|
||||
static bool _in_io_proc;
|
||||
static bool _in_timer_proc;
|
||||
static bool _in_io_proc;
|
||||
|
||||
void stop_clock(uint64_t time_usec);
|
||||
|
||||
bool _initialized;
|
||||
uint64_t _stopped_clock_usec;
|
||||
};
|
||||
#endif // CONFIG_HAL_BOARD
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CONFIG_HAL_BOARD
|
||||
|
Loading…
Reference in New Issue
Block a user