@@ -1405,7 +1405,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
14051405 break ;
14061406
14071407 case EMCMOT_JOINT_UNHOME :
1408- /* unhome the specified joint, or all joints if -1 */
1408+ /* unhome the specified joint, or all joints if -1, or volatile joints if -2 */
14091409 rtapi_print_msg (RTAPI_MSG_DBG , "JOINT_UNHOME" );
14101410 rtapi_print_msg (RTAPI_MSG_DBG , " %d" , joint_num );
14111411
@@ -1415,8 +1415,22 @@ void emcmotCommandHandler_locked(void *arg, long servo_period)
14151415 return ;
14161416 }
14171417
1418- //Negative joint_num specifies unhome_method (-1,-2)
1419- set_unhomed (joint_num ,emcmotStatus -> motion_state );
1418+ // For configs that require homing and have joints configured as VOLATILE_HOME
1419+ // 'get_allhomed()' will change from TRUE to FALSE. If that happens we need to
1420+ // switch motion mode to 'free'.
1421+ if ( get_allhomed () && (joint_num == -2 ) ) {
1422+ set_unhomed (joint_num ,emcmotStatus -> motion_state );
1423+ if (!get_allhomed ()) {
1424+ emcmotInternal -> teleoperating = 0 ;
1425+ SET_MOTION_TELEOP_FLAG (0 );
1426+ emcmotInternal -> coordinating = 0 ;
1427+ SET_MOTION_COORD_FLAG (0 );
1428+ }
1429+ }
1430+ else {
1431+ set_unhomed (joint_num ,emcmotStatus -> motion_state );
1432+ }
1433+
14201434 break ;
14211435
14221436 case EMCMOT_CLEAR_PROBE_FLAGS :
0 commit comments