Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/emc/motion/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,19 @@ static void update_status(void)
}
#endif
joint_status->flag = joint->flag;
joint_status->homing = get_homing(joint_num);
if(!(joint_status->homing && !get_homing(joint_num) && get_homing_is_active())) {
// Prevent race condition.
// (See also emc/motion/homing.c: base_write_homing_out_pins())
// The homing status variable turns false before get_homing_is_active()
// turns false. This means that a new homing command on a joint might
// fail due to the homing state machine being active while all joints
// already are in the 'not homing' state.
// Solution:
// Do not update the homing status when going from homing --> not homing
// and the state machine is still active. The homing status deassertion
// must be delayed until the state machine is done.
joint_status->homing = get_homing(joint_num);
}
joint_status->homed = get_homed(joint_num);
joint_status->pos_cmd = joint->pos_cmd;
joint_status->pos_fb = joint->pos_fb;
Expand Down Expand Up @@ -2209,4 +2221,4 @@ static void update_status(void)
old_motion_flag = emcmotStatus->motionFlag;
}
#endif
}
}
13 changes: 13 additions & 0 deletions src/emc/motion/homing.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,19 @@ static void base_write_homing_out_pins(int njoints)
one_joint_home_data_t *addr;
for (jno = 0; jno < njoints; jno++) {
addr = &(joint_home_data->jhd[jno]);
if(!(*(addr->homing) && !H[jno].homing && homing_active)) {
// Prevent race condition.
// (See also emc/motion/control.c: update_status())
// The homing status variable turns false before homing_active state
// turns false. This means that a new homing command on a joint might
// fail due to the homing state machine being active while all joints
// already are in the 'not homing' state.
// Solution:
// Do not update the homing status when going from homing --> not homing
// and the state machine is still active. The homing status deassertion
// must be delayed until the state machine is done.
*(addr->homing) = H[jno].homing;
}
*(addr->homing) = H[jno].homing; // OUT
*(addr->homed) = H[jno].homed; // OUT
*(addr->home_state) = H[jno].home_state; // OUT
Expand Down
Loading