From c384524877f0a87d27618540743d95c99db166d2 Mon Sep 17 00:00:00 2001 From: gudnimg Date: Sat, 23 Sep 2023 17:11:18 +0000 Subject: [PATCH] mmu: always wait for a request's expected response If a planned request is activated when the current status is finished then the firmware must wait for the response when the request is expecting it An example is a register read or a register write. manage_response not return unless the register has been read or written. And we must see the response to know if an error should be reported. Step to reproduce issue: 1. Fail selector homing 2. Select 'Tune' item 3. Observe issue. In this situation you can see the value for the previous register read is shown. Which is 0. This very timing dependent and does not always happen. 4. Repeat step 2 until the issue appears. It may take a few times. --- Firmware/mmu2_protocol_logic.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Firmware/mmu2_protocol_logic.cpp b/Firmware/mmu2_protocol_logic.cpp index 65b5a4115..78122ab6a 100644 --- a/Firmware/mmu2_protocol_logic.cpp +++ b/Firmware/mmu2_protocol_logic.cpp @@ -809,14 +809,11 @@ StepStatus ProtocolLogic::Step() { // We are ok, switching to Idle if there is no potential next request planned. // But the trouble is we must report a finished command if the previous command has just been finished // i.e. only try to find some planned command if we just finished the Idle cycle - bool previousCommandFinished = currentScope == Scope::Command; // @@TODO this is a nasty hack :( if (!ActivatePlannedRequest()) { // if nothing is planned, switch to Idle SwitchToIdle(); - } else { + } else if (ExpectsResponse()) { // if the previous cycle was Idle and now we have planned a new command -> avoid returning Finished - if (!previousCommandFinished && currentScope == Scope::Command) { - currentStatus = Processing; - } + currentStatus = Processing; } } break; case CommandRejected: