Fixed endless loop when communication times out and added
diagnostics.
This commit is contained in:
@@ -226,7 +226,7 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
|
||||
asynPrint(
|
||||
this->pasynUser(), ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line %d\nTimeout while "
|
||||
"writing to the MCU.%s\n",
|
||||
"writing to the controller. Retrying ...%s\n",
|
||||
portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
|
||||
msgPrintControl_.getSuffix());
|
||||
}
|
||||
@@ -239,6 +239,10 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
|
||||
checkMaxSubsequentTimeouts(timeoutCounter, axis);
|
||||
timeoutCounter += 1;
|
||||
|
||||
if (maxSubsequentTimeoutsExceeded_) {
|
||||
break;
|
||||
}
|
||||
|
||||
status = pasynOctetSyncIO->writeRead(
|
||||
pasynOctetSyncIOipPort(), command, commandLength, response,
|
||||
MAXBUF_, comTimeout_, &nbytesOut, &nbytesIn, &eomReason);
|
||||
@@ -273,17 +277,37 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
|
||||
if (eomReason != 2) {
|
||||
status = asynError;
|
||||
|
||||
char reasonStringified[30] = {0};
|
||||
switch (eomReason) {
|
||||
case 0:
|
||||
snprintf(reasonStringified, sizeof(reasonStringified), "Timeout");
|
||||
break;
|
||||
case 1:
|
||||
snprintf(reasonStringified, sizeof(reasonStringified),
|
||||
"Request count reached");
|
||||
break;
|
||||
case 2:
|
||||
snprintf(reasonStringified, sizeof(reasonStringified),
|
||||
"End of string detected");
|
||||
break;
|
||||
case 3:
|
||||
snprintf(reasonStringified, sizeof(reasonStringified),
|
||||
"End indicator detected");
|
||||
break;
|
||||
}
|
||||
|
||||
snprintf(drvMessageText, sizeof(drvMessageText),
|
||||
"Terminated message due to reason %d (should be 2). Please "
|
||||
"call the support.",
|
||||
eomReason);
|
||||
"Terminated message due to reason %s (should be \"End of "
|
||||
"string detected\"). Please call the support.",
|
||||
reasonStringified);
|
||||
|
||||
if (msgPrintControl_.shouldBePrinted(terminateKey, true, pasynUser())) {
|
||||
|
||||
asynPrint(this->pasynUser(), ASYN_TRACE_ERROR,
|
||||
"Controller \"%s\", axis %d => %s, line %d\nMessage "
|
||||
"terminated due to reason %i.%s\n",
|
||||
"terminated due to reason %s.%s\n",
|
||||
portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
|
||||
eomReason, msgPrintControl_.getSuffix());
|
||||
reasonStringified, msgPrintControl_.getSuffix());
|
||||
}
|
||||
} else {
|
||||
msgPrintControl_.resetCount(terminateKey, pasynUser());
|
||||
|
||||
Reference in New Issue
Block a user