HAL_SITL: block in MC read for packet in AP_Periph

can't advance time without a new multicast packet
This commit is contained in:
Andrew Tridgell 2023-08-19 16:37:16 +10:00 committed by Peter Barker
parent 032c5cc6fe
commit 4a07f7a4eb

View File

@ -244,19 +244,20 @@ void SimMCast::multicast_read(void)
}
struct SITL::sitl_fdm state;
socklen_t len = sizeof(in_addr);
if (recvfrom(mc_fd, (void*)&state, sizeof(state), MSG_WAITALL, (sockaddr *)&in_addr, &len) == sizeof(state)) {
if (state.timestamp_us < _sitl->state.timestamp_us) {
// main process has rebooted
base_time_us += (_sitl->state.timestamp_us - state.timestamp_us);
}
_sitl->state = state;
hal.scheduler->stop_clock(_sitl->state.timestamp_us + base_time_us);
HALSITL::Scheduler::timer_event();
if (servo_fd == -1) {
servo_fd_open();
} else {
servo_send();
}
while (recvfrom(mc_fd, (void*)&state, sizeof(state), MSG_WAITALL, (sockaddr *)&in_addr, &len) != sizeof(state)) {
// nop
}
if (state.timestamp_us < _sitl->state.timestamp_us) {
// main process has rebooted
base_time_us += (_sitl->state.timestamp_us - state.timestamp_us);
}
_sitl->state = state;
hal.scheduler->stop_clock(_sitl->state.timestamp_us + base_time_us);
HALSITL::Scheduler::timer_event();
if (servo_fd == -1) {
servo_fd_open();
} else {
servo_send();
}
}