Skip to content

Commit 87f66fe

Browse files
committed
task: disallow task mode change if jogging
Realtime mpg (wheel) jogging is not controlled through task, so task must detect jogging status provided by motion to disallow a task mode change Ref: https://forum.linuxcnc.org/24-hal-components/45991-jogwheel-start-of-any-gcode-motion-causes-following-error#243898
1 parent 35c8b48 commit 87f66fe

7 files changed

Lines changed: 38 additions & 1 deletion

File tree

src/emc/motion/control.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,27 @@ void emcmotController(void *arg, long period)
302302
prototypes"
303303
*/
304304

305+
bool axis_jog_is_active(void)
306+
{
307+
int n;
308+
for (n = 0; n < EMCMOT_MAX_AXIS; n++) {
309+
if ( (&axes[n])->kb_ajog_active || (&axes[n])->wheel_ajog_active) {
310+
return true;
311+
}
312+
}
313+
return false;
314+
}
315+
316+
bool joint_jog_is_active(void)
317+
{
318+
int n;
319+
for (n = 0; n < EMCMOT_MAX_JOINTS; n++) {
320+
if ( (&joints[n])->kb_jjog_active || (&joints[n])->wheel_jjog_active) {
321+
return true;
322+
}
323+
}
324+
return false;
325+
}
305326
static void process_inputs(void)
306327
{
307328
int joint_num, spindle_num;
@@ -2166,6 +2187,8 @@ static void update_status(void)
21662187
/* check to see if we should pause in order to implement
21672188
single emcmotDebug->stepping */
21682189

2190+
emcmotStatus->jogging_active = axis_jog_is_active()
2191+
|| joint_jog_is_active();
21692192
if (emcmotDebug->stepping && emcmotDebug->idForStep != emcmotStatus->id) {
21702193
tpPause(&emcmotDebug->coord_tp);
21712194
emcmotDebug->stepping = 0;

src/emc/motion/motion.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ to another.
7878
#include "kinematics.h"
7979
#include "simple_tp.h"
8080
#include "rtapi_limits.h"
81+
#include "rtapi_bool.h"
8182
#include <stdarg.h>
8283

8384

@@ -738,7 +739,7 @@ Suggestion: Split this in to an Error and a Status flag register..
738739
unsigned char tail; /* flag count for mutex detect */
739740
int external_offsets_applied;
740741
EmcPose eoffset_pose;
741-
742+
bool jogging_active;
742743
} emcmot_status_t;
743744

744745
/*********************************

src/emc/nml_intf/emc_nml.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,7 @@ class EMC_MOTION_STAT:public EMC_MOTION_STAT_MSG {
12221222
int on_soft_limit;
12231223
int external_offsets_applied;
12241224
EmcPose eoffset_pose;
1225+
bool jogging_active;
12251226
};
12261227

12271228
// declarations for EMC_TASK classes

src/emc/task/emctask.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ int emcTaskSetMode(int mode)
231231
{
232232
int retval = 0;
233233

234+
if (jogging_is_active()) {
235+
emcOperatorError(0, "Ignoring task mode change while jogging");
236+
return 0;
237+
}
238+
234239
switch (mode) {
235240
case EMC_TASK_MODE_MANUAL:
236241
// go to manual mode

src/emc/task/emctaskmain.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ int all_homed(void) {
154154
return 1;
155155
}
156156

157+
bool jogging_is_active(void) {
158+
return emcStatus->motion.jogging_active;
159+
}
160+
157161
void emctask_quit(int sig)
158162
{
159163
// set main's done flag

src/emc/task/task.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern int emcRunHalFiles(const char *filename);
2727

2828
// Returns 0 if all joints are homed, 1 if any joints are un-homed.
2929
int all_homed(void);
30+
bool jogging_is_active(void);
3031

3132
int emcTaskInit();
3233
int emcTaskHalt();

src/emc/task/taskintf.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,6 +1968,8 @@ int emcMotionUpdate(EMC_MOTION_STAT * stat)
19681968
stat->analog_output[aio] = emcmotStatus.analog_output[aio];
19691969
}
19701970

1971+
stat->jogging_active = emcmotStatus.jogging_active;
1972+
19711973
// set the status flag
19721974
error = 0;
19731975
exec = 0;

0 commit comments

Comments
 (0)