Here is my polling function for the MCS2 driver I am developing:
asynStatus SmarActMCS2Axis::poll(bool* moving_p){
int64_t val;
comStatus_=getp(channel_,&val);
if(comStatus_!=asynSuccess){
*moving_p=false;
asynPrint(c_p_->pasynUserSelf,ASYN_TRACE_ERROR,"Error reading axis, channel=%d, comstatus=%d!\n", channel_,comStatus_);
//c_p_ is a pointer to the controller object
//setIntegerParam(c_p_->motorStatusProblem_,1);
setIntegerParam(c_p_->motorStatusCommsError_,1);
callParamCallbacks();
return asynError;
}
val=val/1000;
setDoubleParam(c_p_->motorEncoderPosition_,(double)val);
setDoubleParam(c_p_->motorPosition_,(double)val);
if(is_moving(channel_)==true){
*moving_p=true;
}
else{
*moving_p=false;
}
setIntegerParam(c_p_->motorStatusProblem_,0);
setIntegerParam(c_p_->motorStatusCommsError_,0);
setIntegerParam(c_p_->motorStatusMoving_,*moving_p);
setIntegerParam(c_p_->motorStatusDone_, ! *moving_p);
callParamCallbacks();
return asynSuccess;
}
Notice that “setIntegerParam(c_p_->motorStatusProblem_,1);” is commented out because when I uncomment it, it causes the IOC to have a segmentation fault when I attempt to move an axis that is not connected. Surprisingly, “setIntegerParam(c_p_->motorStatusCommsError_,1);”
does not cause the IOC to have a segmentation fault, and as expected raises a COMM alarm when I attempt to move an axis that is not connected. motorStatusProblem and motorStatusCommsError are not referenced anywhere else inside my code. What is causing the
segmentation fault to occur?
Alex