From 85232fadbb1fa02f6abeee7bf28ac6e286c45a24 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sun, 22 May 2022 14:45:17 +0100 Subject: simulator: fix off by one error in USB ack calculations The sim's printout of the number of expected USB acks was off by one. Since the sim queue is not registered for broadcasts, it will not receive an ack message and does not need to account for itself when determining the number of acks to expect, unlike the USB code. Change-Id: I6715039c05c1ea95099716c5251d401e37f5b085 --- uisimulator/common/sim_tasks.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/uisimulator/common/sim_tasks.c b/uisimulator/common/sim_tasks.c index 8c1f193080..c53b9990fd 100644 --- a/uisimulator/common/sim_tasks.c +++ b/uisimulator/common/sim_tasks.c @@ -92,7 +92,9 @@ void sim_thread(void) last_broadcast_tick = current_tick; } - num_acks_to_expect += queue_broadcast(SYS_USB_CONNECTED, 0) - 1; + /* NOTE: Unlike the USB code, we do not subtract one here + * because the sim_queue is not registered for broadcasts! */ + num_acks_to_expect += queue_broadcast(SYS_USB_CONNECTED, 0); DEBUGF("USB inserted. Waiting for %d acks...\n", num_acks_to_expect); break; -- cgit v1.2.3