diff --git a/src/sinqAxis.cpp b/src/sinqAxis.cpp index d5061b5..560be8c 100644 --- a/src/sinqAxis.cpp +++ b/src/sinqAxis.cpp @@ -100,36 +100,48 @@ asynStatus sinqAxis::poll(bool *moving) { } } + /* + At the beginning of the poll, it is assumed that the axis has no status + problems and therefore all error indicators are reset. This does not affect + the PVs until callParamCallbacks has been called! + + The motorStatusProblem_ field changes the motor record fields SEVR and STAT. + */ + pl_status = setIntegerParam(pC_->motorStatusProblem_, false); + if (pl_status != asynSuccess) { + pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_", + __PRETTY_FUNCTION__, __LINE__); + } + pl_status = setIntegerParam(pC_->motorStatusCommsError_, false); + if (pl_status != asynSuccess) { + pC_->paramLibAccessFailed(pl_status, "motorStatusCommsError_", + __PRETTY_FUNCTION__, __LINE__); + } + pl_status = setStringParam(pC_->motorMessageText_, ""); + if (pl_status != asynSuccess) { + return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", + __PRETTY_FUNCTION__, __LINE__); + } + // The poll function is just a wrapper around doPoll and // handles mainly the callParamCallbacks() function. This wrapper is used // to make sure callParamCallbacks() is called in case of a premature // return. poll_status = doPoll(moving); - // Check and update the watchdog - if (checkMovTimeoutWatchdog(*moving) != asynSuccess) { - return asynError; - } - - // If the poll status is ok, reset the error indicators in the parameter - // library - if (poll_status == asynSuccess) { - pl_status = setIntegerParam(pC_->motorStatusProblem_, false); + // The poll did not succeed: Something went wrong and the motor has a status + // problem. + if (poll_status != asynSuccess) { + pl_status = setIntegerParam(pC_->motorStatusProblem_, true); if (pl_status != asynSuccess) { pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_", __PRETTY_FUNCTION__, __LINE__); } - pl_status = setIntegerParam(pC_->motorStatusCommsError_, false); - if (pl_status != asynSuccess) { - pC_->paramLibAccessFailed(pl_status, "motorStatusCommsError_", - __PRETTY_FUNCTION__, __LINE__); - } + } - pl_status = setStringParam(pC_->motorMessageText_, ""); - if (pl_status != asynSuccess) { - return pC_->paramLibAccessFailed(pl_status, "motorMessageText_", - __PRETTY_FUNCTION__, __LINE__); - } + // Check and update the watchdog + if (checkMovTimeoutWatchdog(*moving) != asynSuccess) { + return asynError; } if (pl_status != asynSuccess) { @@ -490,8 +502,9 @@ asynStatus sinqAxis::checkMovTimeoutWatchdog(bool moving) { // Check the watchdog asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, "%s => line %d:\nAxis %d exceeded the expected arrival time " - "(%ld).\n", - __PRETTY_FUNCTION__, __LINE__, axisNo_, expectedArrivalTime_); + "%ld (current time is %ld).\n", + __PRETTY_FUNCTION__, __LINE__, axisNo_, expectedArrivalTime_, + time(NULL)); pl_status = setStringParam( pC_->motorMessageText_,