Moved error handling out of error read condition.
Some checks failed
Test And Build / Lint (push) Failing after 9s
Test And Build / Build (push) Successful in 12s

Previously, error messaging was only done after the error has been read.
This means that cached errors were simply ignored, if e.g. the motor was
moving. This commit now messages an error as long as it exists in the
cache "masterMacsAxisImpl->axisError".
This commit is contained in:
2025-08-05 09:04:11 +02:00
parent ff183576ec
commit 954fc82414

View File

@@ -432,11 +432,12 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
Read out the error if either a fault condition status flag has been set or Read out the error if either a fault condition status flag has been set or
if a movement has just ended. if a movement has just ended.
*/ */
msgPrintControlKey keyError = msgPrintControlKey(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
if (faultConditionSet() || !(*moving)) { if (faultConditionSet() || !(*moving)) {
rw_status = readAxisError(); rw_status = readAxisError();
}
msgPrintControlKey keyError = msgPrintControlKey(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
/* /*
A communication error is a special case. If a communication between A communication error is a special case. If a communication between
@@ -469,8 +470,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
if (shortCircuit()) { if (shortCircuit()) {
appendErrorMessage(shellMessage, sizeof(shellMessage), appendErrorMessage(shellMessage, sizeof(shellMessage),
"Short circuit fault."); "Short circuit fault.");
appendErrorMessage( appendErrorMessage(errorMessage, sizeof(errorMessage),
errorMessage, sizeof(errorMessage),
"Short circuit error. Please call the support."); "Short circuit error. Please call the support.");
poll_status = asynError; poll_status = asynError;
@@ -486,8 +486,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
} }
if (followingError()) { if (followingError()) {
appendErrorMessage( appendErrorMessage(shellMessage, sizeof(shellMessage),
shellMessage, sizeof(shellMessage),
"Maximum callowed following error exceeded."); "Maximum callowed following error exceeded.");
appendErrorMessage( appendErrorMessage(
errorMessage, sizeof(errorMessage), errorMessage, sizeof(errorMessage),
@@ -549,8 +548,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
if (overCurrent()) { if (overCurrent()) {
appendErrorMessage(shellMessage, sizeof(shellMessage), appendErrorMessage(shellMessage, sizeof(shellMessage),
"Overcurrent error."); "Overcurrent error.");
appendErrorMessage( appendErrorMessage(errorMessage, sizeof(errorMessage),
errorMessage, sizeof(errorMessage),
"Overcurrent error. Please call the support."); "Overcurrent error. Please call the support.");
poll_status = asynError; poll_status = asynError;
@@ -569,8 +567,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
if (overVoltage()) { if (overVoltage()) {
appendErrorMessage(shellMessage, sizeof(shellMessage), appendErrorMessage(shellMessage, sizeof(shellMessage),
"Overvoltage error."); "Overvoltage error.");
appendErrorMessage( appendErrorMessage(errorMessage, sizeof(errorMessage),
errorMessage, sizeof(errorMessage),
"Overvoltage error. Please call the support."); "Overvoltage error. Please call the support.");
poll_status = asynError; poll_status = asynError;
@@ -579,8 +576,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
if (underVoltage()) { if (underVoltage()) {
appendErrorMessage(shellMessage, sizeof(shellMessage), appendErrorMessage(shellMessage, sizeof(shellMessage),
"Undervoltage error."); "Undervoltage error.");
appendErrorMessage( appendErrorMessage(errorMessage, sizeof(errorMessage),
errorMessage, sizeof(errorMessage),
"Undervoltage error. Please call the support."); "Undervoltage error. Please call the support.");
poll_status = asynError; poll_status = asynError;
@@ -596,20 +592,21 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
} }
if (strlen(shellMessage) > 0) { if (strlen(shellMessage) > 0) {
if (pC_->getMsgPrintControl().shouldBePrinted( if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true,
keyError, true, pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line " "Controller \"%s\", axis %d => %s, line "
"%d\n%s%s\n", "%d\n%s%s\n",
pC_->portName, axisNo_, __PRETTY_FUNCTION__, pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__,
__LINE__, shellMessage, shellMessage, pC_->getMsgPrintControl().getSuffix());
pC_->getMsgPrintControl().getSuffix());
} }
} }
setAxisParamChecked(this, motorMessageText, errorMessage); setAxisParamChecked(this, motorMessageText, errorMessage);
} }
} else {
// No error has been detected -> Reset the error count
if (poll_status == asynSuccess) {
pC_->getMsgPrintControl().resetCount(keyError, pC_->pasynUser()); pC_->getMsgPrintControl().resetCount(keyError, pC_->pasynUser());
} }