Fixed bug with errorprint to ioc console

The previous setup created one print key for all error types. The
problem with that is that if an error directly followed another error
(without an error = 0 in between), the MsgPrintControl prevented
printing of the new error. Now every error has its own key.
This commit is contained in:
2025-08-22 15:25:31 +02:00
parent 5845d2e908
commit 4fd95743c4

View File

@@ -553,11 +553,6 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
int sizeUserMessage) { int sizeUserMessage) {
asynStatus status = asynError; asynStatus status = asynError;
// Create the unique callsite identifier manually so it can be used later in
// the shouldBePrinted calls.
msgPrintControlKey keyError = msgPrintControlKey(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__);
switch (error) { switch (error) {
case 0: case 0:
status = asynSuccess; status = asynSuccess;
@@ -566,7 +561,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
case 1: case 1:
// EPICS should already prevent this issue in the first place, // EPICS should already prevent this issue in the first place,
// since it contains the user limits // since it contains the user limits
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nTarget " "Controller \"%s\", axis %d => %s, line %d\nTarget "
@@ -579,7 +575,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
break; break;
case 5: case 5:
// Command not possible // Command not possible
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint( asynPrint(
pC_->pasynUser(), ASYN_TRACE_ERROR, pC_->pasynUser(), ASYN_TRACE_ERROR,
@@ -594,7 +591,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
"moving. Please call the support."); "moving. Please call the support.");
break; break;
case 8: case 8:
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nAir cushion " "Controller \"%s\", axis %d => %s, line %d\nAir cushion "
@@ -609,7 +607,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
setAxisParamChecked(this, motorMessageText, userMessage); setAxisParamChecked(this, motorMessageText, userMessage);
break; break;
case 9: case 9:
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint( asynPrint(
pC_->pasynUser(), ASYN_TRACE_ERROR, pC_->pasynUser(), ASYN_TRACE_ERROR,
@@ -633,7 +632,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
which is not properly homed or if a bug occured. which is not properly homed or if a bug occured.
*/ */
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint( asynPrint(
pC_->pasynUser(), ASYN_TRACE_ERROR, pC_->pasynUser(), ASYN_TRACE_ERROR,
@@ -653,7 +653,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
case 11: case 11:
// Following error // Following error
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint( asynPrint(
pC_->pasynUser(), ASYN_TRACE_ERROR, pC_->pasynUser(), ASYN_TRACE_ERROR,
@@ -671,7 +672,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
break; break;
case 12: case 12:
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nSecurity " "Controller \"%s\", axis %d => %s, line %d\nSecurity "
@@ -690,7 +692,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
case 13: case 13:
// Driver hardware error triggered // Driver hardware error triggered
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nDriver " "Controller \"%s\", axis %d => %s, line %d\nDriver "
@@ -707,7 +710,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
case 14: case 14:
// EPICS should already prevent this issue in the first place, // EPICS should already prevent this issue in the first place,
// since it contains the user limits // since it contains the user limits
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR, asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nMove " "Controller \"%s\", axis %d => %s, line %d\nMove "
@@ -723,7 +727,8 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
break; break;
default: default:
if (pC_->getMsgPrintControl().shouldBePrinted(keyError, true, if (pC_->getMsgPrintControl().shouldBePrinted(
pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, true,
pC_->pasynUser())) { pC_->pasynUser())) {
asynPrint( asynPrint(
pC_->pasynUser(), ASYN_TRACE_ERROR, pC_->pasynUser(), ASYN_TRACE_ERROR,
@@ -735,10 +740,6 @@ asynStatus turboPmacAxis::handleError(int error, char *userMessage,
setAxisParamChecked(this, motorMessageText, userMessage); setAxisParamChecked(this, motorMessageText, userMessage);
break; break;
} }
if (status == asynSuccess) {
pC_->getMsgPrintControl().resetCount(keyError, pC_->pasynUser());
}
return status; return status;
} }