From 798971aba0578e1118b501ca6730c93fe0253d36 Mon Sep 17 00:00:00 2001 From: smathis Date: Tue, 20 Oct 2026 13:14:25 +0200 Subject: [PATCH] Graceful handling of short-lived communication errors. If a communication error between the MACS controller and a slave controller is short-lived, it shouldn't be reported to the user. --- src/masterMacsAxis.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/masterMacsAxis.cpp b/src/masterMacsAxis.cpp index 0777ab6..30e67b5 100644 --- a/src/masterMacsAxis.cpp +++ b/src/masterMacsAxis.cpp @@ -575,7 +575,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { msgPrintControlKey commError = msgPrintControlKey( pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, - {.maxRepetitions = 5, .minRepetitions = 1}); + {.maxRepetitions = 2000, .minRepetitions = 100}); /* A communication error is a special case. If a communication between @@ -583,7 +583,14 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { since this information is not reliable. */ if (communicationError()) { - + /* + Only emit an error message if the communication error was set at least + minRepetitions times. This is to avoid reporting communication errors + which only occur very temporarily and are not relevant. As a concrete + example, if an axis is connected to the controller, the MACS might + detect that it is connected, but establishing the communication might + take a short time. This is not an error which should be reported. + */ if (pC_->getMsgPrintControl().repetitionCount(commError) >= commError.options_.minRepetitions) { if (pC_->getMsgPrintControl().shouldBePrinted(commError, true, @@ -604,6 +611,16 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { poll_status = asynError; } else { pC_->getMsgPrintControl().incrementRepetitionCount(commError); + + /* + If the error shouldn't be reported yet (see text above), reset the + error message on the controller, as it will otherwise persist even + though the communication has been established. + */ + rwStatus = pC_->write(axisNo_, 17, ""); + if (rwStatus != asynSuccess) { + setAxisParamChecked(this, motorStatusProblem, true); + } } } else {