epics-modules / motor

APS BCDA synApps module: motor
https://epics-modules.github.io/motor/
20 stars 47 forks source link

devMotorAsyn.c: Set encoder ratio to 1 if ERES is 0 to avoid dividing by 0 #214

Closed kmpeters closed 7 months ago

kmpeters commented 7 months ago

Set encoder ratio to 1 if ERES is 0 in devMotorAsyn.c to avoid dividing by 0.

Fixes #213

kmpeters commented 7 months ago

This is a trivial change that doesn't really need a review. I'm trying to get into the habit of keeping people in the loop as changes happen.

kmpeters commented 7 months ago

There is a check for ERES=0 in the motor record already:

https://github.com/epics-modules/motor/blob/81662468d0ab2ff0896eb6fbfab214165122ceb2/motorApp/MotorSrc/motorRecord.cc#L692-L696

I'm not sure why this wasn't sufficient protection in the case of the Gailil controller.

MarkRivers commented 7 months ago

I think the problem is that the encoder ratio is set in devMotorAsyn::init_controller https://github.com/epics-modules/motor/blob/81662468d0ab2ff0896eb6fbfab214165122ceb2/motorApp/MotorSrc/devMotorAsyn.c#L185, which is called from devMotorAsyn::init_record https://github.com/epics-modules/motor/blob/81662468d0ab2ff0896eb6fbfab214165122ceb2/motorApp/MotorSrc/devMotorAsyn.c#L418. But in the motor_record.cc the device support init_record is called https://github.com/epics-modules/motor/blob/81662468d0ab2ff0896eb6fbfab214165122ceb2/motorApp/MotorSrc/motorRecord.cc#L647 before the check for ERES=0 https://github.com/epics-modules/motor/blob/81662468d0ab2ff0896eb6fbfab214165122ceb2/motorApp/MotorSrc/motorRecord.cc#L692