From c2b1735f131a9adc667d7e4e7cc0f425e4322a29 Mon Sep 17 00:00:00 2001 From: smathis Date: Wed, 15 Jul 2026 16:29:29 +0200 Subject: [PATCH] Avoid unnecessary polling if the axis is disconnected. --- src/masterMacsAxis.cpp | 9 +++++++++ src/masterMacsController.cpp | 10 +++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/masterMacsAxis.cpp b/src/masterMacsAxis.cpp index 59c2020..ba255ab 100644 --- a/src/masterMacsAxis.cpp +++ b/src/masterMacsAxis.cpp @@ -425,6 +425,15 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { // Perform the rest of the poll, but remember if sth. failed in the // init. poll_status = init(); + + // If the axis is not connected, we don't need to continue with the poll + if (poll_status == asynDisconnected) { + // moving is uninitialized from asynMotorController, so we need to + // make sure it has a reasonable value if the axis is disconnected. + // Obviously, we assume that the disconnected axis is not moving. + *moving = false; + return poll_status; + } } // Are we currently waiting for a handshake? diff --git a/src/masterMacsController.cpp b/src/masterMacsController.cpp index 5a19b09..9a13bfd 100644 --- a/src/masterMacsController.cpp +++ b/src/masterMacsController.cpp @@ -340,11 +340,8 @@ asynStatus masterMacsController::writeRead(int axisNo, int tcpCmd, "Connection timeout. Please call the support."); break; case asynDisconnected: - snprintf(drvMessageText, sizeof(drvMessageText), - "Axis is not connected."); break; case asynDisabled: - snprintf(drvMessageText, sizeof(drvMessageText), "Axis is disabled."); break; case asynError: // Do nothing - error message drvMessageText has already been set. @@ -465,10 +462,9 @@ asynStatus masterMacsController::parseResponse( break; } else if (fullResponse[i] == '\x15') { - /* - NAK - This indicates that the axis is not connected. This is not an error! - */ + // NAK + // This indicates that the axis is not connected. This is not an + // error! snprintf(drvMessageText, MAXBUF_, "Axis not connected."); // Motor was connected before -> Update the paramLib entry and PV