diff --git a/src/turboPmacAxis.cpp b/src/turboPmacAxis.cpp index 74fded0..5c01642 100644 --- a/src/turboPmacAxis.cpp +++ b/src/turboPmacAxis.cpp @@ -161,7 +161,15 @@ asynStatus turboPmacAxis::init() { axisNo_, axisNo_, axisNo_, axisNo_, axisNo_); status = pC_->writeRead(axisNo_, command, response, 6); if (status != asynSuccess) { - return status; + asynPrint( + pC_->pasynUser(), ASYN_TRACE_ERROR, + "Controller \"%s\", axis %d => %s, line %d\nCould not communicate " + "with controller during IOC initialization. Check if you used " + "\"pmacAsynIPPortConfigure\" instead of the standard " + "\"drvAsynIPPortConfigure\" function in the .cmd file in order to " + "create the port driver.\nTerminating IOC.\n", + pC_->portName, axisNo(), __PRETTY_FUNCTION__, __LINE__); + exit(-1); } nvals = sscanf(response, "%d %lf %lf %lf %lf %d", &axStatus, &motorPos, &motorVmax, &motorVelocity, &motorAccel, &acoDelay); diff --git a/src/turboPmacController.cpp b/src/turboPmacController.cpp index bdc722c..dc80072 100644 --- a/src/turboPmacController.cpp +++ b/src/turboPmacController.cpp @@ -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());