Skip to content
Snippets Groups Projects
Commit dc127fe7 authored by Andrew Tridgell's avatar Andrew Tridgell
Browse files

SITL: ensure we don't run the sitl timer twice

this caused problems with random()
parent 2a011578
No related branches found
No related tags found
No related merge requests found
...@@ -223,7 +223,12 @@ static void sitl_simulator_output(void) ...@@ -223,7 +223,12 @@ static void sitl_simulator_output(void)
static void timer_handler(int signum) static void timer_handler(int signum)
{ {
static uint32_t last_update_count; static uint32_t last_update_count;
static bool running;
if (running) {
return;
}
running = true;
cli(); cli();
#ifndef __CYGWIN__ #ifndef __CYGWIN__
...@@ -261,11 +266,13 @@ static void timer_handler(int signum) ...@@ -261,11 +266,13 @@ static void timer_handler(int signum)
if (update_count == 0) { if (update_count == 0) {
sitl_update_gps(0, 0, 0, 0, 0, false); sitl_update_gps(0, 0, 0, 0, 0, false);
sei(); sei();
running = false;
return; return;
} }
if (update_count == last_update_count) { if (update_count == last_update_count) {
sei(); sei();
running = false;
return; return;
} }
last_update_count = update_count; last_update_count = update_count;
...@@ -280,6 +287,7 @@ static void timer_handler(int signum) ...@@ -280,6 +287,7 @@ static void timer_handler(int signum)
sitl_update_barometer(sim_state.altitude); sitl_update_barometer(sim_state.altitude);
sitl_update_compass(sim_state.rollDeg, sim_state.pitchDeg, sim_state.heading); sitl_update_compass(sim_state.rollDeg, sim_state.pitchDeg, sim_state.heading);
sei(); sei();
running = false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment