Graceful handling of short-lived communication errors.
Test And Build / Build (push) Successful in 9s
Test And Build / Lint (push) Failing after 5s

If a communication error between the MACS controller and a slave controller is short-lived, it shouldn't be reported to the user.
This commit is contained in:
mathis_s committed 2026-10-20 13:14:25 +02:00
1 parent 420f0868fc
commit 798971aba0
1 file changed
+19 -2
+19 -2
View File
@@ -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 {