diff --git a/sinqEPICSApp/src/C804Axis.cpp b/sinqEPICSApp/src/C804Axis.cpp index c1e1500..b0905db 100644 --- a/sinqEPICSApp/src/C804Axis.cpp +++ b/sinqEPICSApp/src/C804Axis.cpp @@ -55,7 +55,7 @@ asynStatus C804Axis::poll(bool *moving) // function should be called at the end of a poll implementation. asynStatus status_callback = callParamCallbacks(); if (status_callback != asynSuccess) - {d + { asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, "%s: Updating the parameter library failed for axis %d\n", functionName, axisNo_); return status_callback; @@ -131,20 +131,42 @@ asynStatus C804Axis::poll_no_param_lib_update(bool *moving) save the read result to the member variable earlier), since the parameter library is updated at a later stage! */ - pC_->getDoubleParam(axisNo_, pC_->motorRecResolution_, &motorRecResolution_); + status = pC_->getDoubleParam(axisNo_, pC_->motorRecResolution_, &motorRecResolution_); + - asynPrint(pC_->pasynUserSelf,ASYN_TRACE_FLOW,"Poll axis %d\n", axisNo_); /* - We know that the motor resolution must not be zero. During the startup of the - IOC, polls can happen before the record is fully initialized. In that case, - all values are zero. - */ - if (motorRecResolution_ == 0) + The poll function might be called at IOC startup before the parameter + library has been fully initialized. In this case, calling getDoubleParam + returns the error status 10 (asynParamUndefined). Returning an asynError + from the poll method means that the poll is repeated. This is exactly what + we want, because this means that the poll will be repeated until the + parameter library has been initialized. + + asynStatus is defined as + + typedef enum { + asynSuccess,asynTimeout,asynOverflow,asynError,asynDisconnected,asynDisabled + }asynStatus; + + in asynDriver.h (see https://github.com/epics-modules/asyn/blob/master/asyn/asynDriver/asynDriver.h), + Therefore, it should only have the values 0 to 5. However, the enum value + range is extended in paramErrors.h (https://github.com/epics-modules/asyn/blob/master/asyn/asynPortDriver/paramErrors.h) + */ + if (status == asynParamUndefined) { + asynPrint(pC_->pasynUserSelf, ASYN_TRACE_FLOW, + "%s: Parameter library is not yet initialized. Repeating poll on axis %d\n", functionName, axisNo_); + return asynError; + } + else if (status != asynSuccess) + { + asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, + "%s: Reading the motor resolution failed for axis %d\n (asynStatus = %d)", functionName, axisNo_, status); return asynError; } + /* Assume that the axis does not have a status problem. If it does have a problem, this value will be overwritten further below. Setting this value