In the poll method, it is now checked whether the parameter library has

been initialized. If this isn't the case, the poll is repeated (this is
triggered by returning an error from the poll method)
This commit is contained in:
2024-09-20 13:13:13 +02:00
parent 4272ed2f50
commit 9ca5af4507

View File

@ -55,7 +55,7 @@ asynStatus C804Axis::poll(bool *moving)
// function should be called at the end of a poll implementation. // function should be called at the end of a poll implementation.
asynStatus status_callback = callParamCallbacks(); asynStatus status_callback = callParamCallbacks();
if (status_callback != asynSuccess) if (status_callback != asynSuccess)
{d {
asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR, asynPrint(pC_->pasynUserSelf, ASYN_TRACE_ERROR,
"%s: Updating the parameter library failed for axis %d\n", functionName, axisNo_); "%s: Updating the parameter library failed for axis %d\n", functionName, axisNo_);
return status_callback; return status_callback;
@ -131,19 +131,41 @@ asynStatus C804Axis::poll_no_param_lib_update(bool *moving)
save the read result to the member variable earlier), since the parameter library save the read result to the member variable earlier), since the parameter library
is updated at a later stage! 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 The poll function might be called at IOC startup before the parameter
IOC, polls can happen before the record is fully initialized. In that case, library has been fully initialized. In this case, calling getDoubleParam
all values are zero. 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 (motorRecResolution_ == 0) 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; 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 Assume that the axis does not have a status problem. If it does have a