From 620f2e5cabe83775a4f0572cce35c4c8bb19caa4 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 13 Aug 2026 14:32:15 +1000 Subject: [PATCH] tests/multi_exmod/machine_can_05: Fix test setup race. Follow-up to b35383b which fixed one test setup race, but seemed to introduce failures - at least intermittently on some stm32 test configs. Guessing at a root cause: the 100ms sleep may not have been enough for the host to always coordinate instances, in which case instance1 might start sending onto the bus before instance0. Fix is to add an explicit synchronisation point so instance1 doesn't try to send until after instance0 has definitely started "babbling". This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton --- tests/multi_extmod/machine_can_05_tx_prio_cancel.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/multi_extmod/machine_can_05_tx_prio_cancel.py b/tests/multi_extmod/machine_can_05_tx_prio_cancel.py index 0c5f28c4cd7..c3f67b372df 100644 --- a/tests/multi_extmod/machine_can_05_tx_prio_cancel.py +++ b/tests/multi_extmod/machine_can_05_tx_prio_cancel.py @@ -43,6 +43,8 @@ def instance0(): # requirement) multitest.wait("instance1 ready") + bcast_countdown = 5 + # "Babble" medium priority messages onto the bus to prevent # instance1() from sending anything lower priority than this while len(recv) < ITERS: @@ -50,6 +52,12 @@ def instance0(): can.send(id, b"BABBLE", CAN.FLAG_EXT_ID) if len(recv) >= ITERS: break + if bcast_countdown > 0: + # queue some "babble" messages onto the bus before signalling to + # instance1 that it can start trying to send + bcast_countdown -= 1 + if not bcast_countdown: + multitest.broadcast("instance0 babbling") print("received", ITERS, "messages") for can_id in recv: @@ -92,7 +100,7 @@ def instance1(): # make sure instance0 can queue outgoing medium-priority # babble before we start trying to send, so we're trying to # send onto an already busy bus - time.sleep_ms(100) + multitest.wait("instance0 babbling") for i in range(ITERS): # Fill the transmit queue with low priority messages (all extended IDs)