From 9ef0943eb9680773bea4f726790b3a4e577d92f1 Mon Sep 17 00:00:00 2001 From: Chad Woitas Date: Thu, 11 Sep 2025 10:23:57 -0600 Subject: [PATCH 1/2] Add Stepping Status to emcmodule --- docs/src/config/python-interface.adoc | 3 +++ src/emc/nml_intf/emc_nml.hh | 1 + src/emc/task/emctaskmain.cc | 9 +++++++++ src/emc/usr_intf/axis/extensions/emcmodule.cc | 1 + 4 files changed, 14 insertions(+) diff --git a/docs/src/config/python-interface.adoc b/docs/src/config/python-interface.adoc index bf4d96203e7..213f510416d 100644 --- a/docs/src/config/python-interface.adoc +++ b/docs/src/config/python-interface.adoc @@ -278,6 +278,9 @@ see <> for an example. *paused*:: '(returns boolean)' - `motion paused` flag. +*stepping*:: '(returns boolean)' - + `motion stepping` flag. + *pocket_prepped*:: '(returns integer)' - A Tx command completed, and this pocket is prepared. -1 if no prepared pocket. diff --git a/src/emc/nml_intf/emc_nml.hh b/src/emc/nml_intf/emc_nml.hh index 9f58782ed80..380f5bc3422 100644 --- a/src/emc/nml_intf/emc_nml.hh +++ b/src/emc/nml_intf/emc_nml.hh @@ -984,6 +984,7 @@ class EMC_TRAJ_STAT:public EMC_TRAJ_STAT_MSG { bool queueFull; // non-zero means can't accept another motion int id; // id of the currently executing motion bool paused; // non-zero means motion paused + bool stepping; // non-zero means motion stepping single block double scale; // velocity scale factor double rapid_scale; // rapid scale factor //double spindle_scale; // moved to EMC_SPINDLE_STAT diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 34ee1fec4bb..694c55b8325 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -1174,6 +1174,7 @@ static int emcTaskPlan(void) break; case EMC_TASK_PLAN_STEP_TYPE: + emcStatus->motion.traj.stepping = 1; stepping = 1; // set stepping mode in case it's not steppingWait = 0; // clear the wait break; @@ -1249,6 +1250,7 @@ static int emcTaskPlan(void) break; case EMC_TASK_PLAN_STEP_TYPE: + emcStatus->motion.traj.stepping = 1; stepping = 1; steppingWait = 0; if (emcStatus->motion.traj.paused && @@ -1324,6 +1326,7 @@ static int emcTaskPlan(void) break; case EMC_TASK_PLAN_STEP_TYPE: + emcStatus->motion.traj.stepping = 1; stepping = 1; // set stepping mode in case it's not steppingWait = 0; // clear the wait break; @@ -2123,6 +2126,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) // clear out the interpreter state emcStatus->task.interpState = EMC_TASK_INTERP::IDLE; emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcStatus->motion.traj.stepping = 0; stepping = 0; steppingWait = 0; @@ -2217,6 +2221,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) break; case EMC_TASK_PLAN_EXECUTE_TYPE: + emcStatus->motion.traj.stepping = 0; stepping = 0; steppingWait = 0; execute_msg = (EMC_TASK_PLAN_EXECUTE *) cmd; @@ -2312,6 +2317,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) retval = -1; break; } + emcStatus->motion.traj.stepping = 0; stepping = 0; steppingWait = 0; if (!taskplanopen && emcStatus->task.file[0] != 0) { @@ -2360,6 +2366,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) emcTrajResume(); emcStatus->task.interpState = interpResumeState; emcStatus->task.task_paused = 0; + emcStatus->motion.traj.stepping = 0; stepping = 0; steppingWait = 0; retval = 0; @@ -2590,6 +2597,7 @@ static int emcTaskExecute(void) // clear out the interpreter state emcStatus->task.interpState = EMC_TASK_INTERP::IDLE; emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcStatus->motion.traj.stepping = 0; stepping = 0; steppingWait = 0; @@ -3497,6 +3505,7 @@ int main(int argc, char *argv[]) // clear out the interpreter state emcStatus->task.interpState = EMC_TASK_INTERP::IDLE; emcStatus->task.execState = EMC_TASK_EXEC::DONE; + emcStatus->motion.traj.stepping = 0; stepping = 0; steppingWait = 0; diff --git a/src/emc/usr_intf/axis/extensions/emcmodule.cc b/src/emc/usr_intf/axis/extensions/emcmodule.cc index 8846327f28b..d1f5ff85082 100644 --- a/src/emc/usr_intf/axis/extensions/emcmodule.cc +++ b/src/emc/usr_intf/axis/extensions/emcmodule.cc @@ -466,6 +466,7 @@ static PyMemberDef Stat_members[] = { {(char*)"queue_full", T_BOOL, O(motion.traj.queueFull), READONLY, NULL}, {(char*)"motion_id", T_INT, O(motion.traj.id), READONLY, NULL}, {(char*)"paused", T_BOOL, O(motion.traj.paused), READONLY, NULL}, + {(char*)"stepping", T_BOOL, O(motion.traj.stepping), READONLY, NULL}, {(char*)"feedrate", T_DOUBLE, O(motion.traj.scale), READONLY, NULL}, {(char*)"rapidrate", T_DOUBLE, O(motion.traj.rapid_scale), READONLY, NULL}, {(char*)"velocity", T_DOUBLE, O(motion.traj.velocity), READONLY, NULL}, From 5ac53b4998a199cb6513194e482cff1f80f03d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=B6ftner?= Date: Thu, 22 Jan 2026 17:51:05 +0100 Subject: [PATCH 2/2] renamed variable, added missing update in CMS --- docs/src/config/python-interface.adoc | 4 +- src/emc/nml_intf/emc.cc | 1 + src/emc/nml_intf/emc_nml.hh | 16 ++--- src/emc/task/emctaskmain.cc | 62 +++++++++---------- src/emc/usr_intf/axis/extensions/emcmodule.cc | 4 +- 5 files changed, 44 insertions(+), 43 deletions(-) diff --git a/docs/src/config/python-interface.adoc b/docs/src/config/python-interface.adoc index 213f510416d..6fd6e6f1c28 100644 --- a/docs/src/config/python-interface.adoc +++ b/docs/src/config/python-interface.adoc @@ -278,8 +278,8 @@ see <> for an example. *paused*:: '(returns boolean)' - `motion paused` flag. -*stepping*:: '(returns boolean)' - - `motion stepping` flag. +*single_stepping*:: '(returns boolean)' - + `motion single_stepping` flag. *pocket_prepped*:: '(returns integer)' - A Tx command completed, and this pocket is prepared. -1 if no diff --git a/src/emc/nml_intf/emc.cc b/src/emc/nml_intf/emc.cc index 0b4117b229f..96e32295c4c 100644 --- a/src/emc/nml_intf/emc.cc +++ b/src/emc/nml_intf/emc.cc @@ -1702,6 +1702,7 @@ void EMC_TRAJ_STAT::update(CMS * cms) cms->update(queueFull); cms->update(id); cms->update(paused); + cms->update(single_stepping); cms->update(scale); cms->update(rapid_scale); EmcPose_update(cms, &position); diff --git a/src/emc/nml_intf/emc_nml.hh b/src/emc/nml_intf/emc_nml.hh index 380f5bc3422..2c2ffbc35d2 100644 --- a/src/emc/nml_intf/emc_nml.hh +++ b/src/emc/nml_intf/emc_nml.hh @@ -794,8 +794,8 @@ class EMC_TRAJ_SET_TERM_COND:public EMC_TRAJ_CMD_MSG { void update(CMS * cms); int cond; - double tolerance; // used to set the precision/tolerance of path deviation - // during CONTINUOUS motion mode. + double tolerance; // used to set the precision/tolerance of path deviation + // during CONTINUOUS motion mode. }; class EMC_TRAJ_SET_SPINDLESYNC:public EMC_TRAJ_CMD_MSG { @@ -984,7 +984,7 @@ class EMC_TRAJ_STAT:public EMC_TRAJ_STAT_MSG { bool queueFull; // non-zero means can't accept another motion int id; // id of the currently executing motion bool paused; // non-zero means motion paused - bool stepping; // non-zero means motion stepping single block + bool single_stepping; // non-zero means motion stepping single block double scale; // velocity scale factor double rapid_scale; // rapid scale factor //double spindle_scale; // moved to EMC_SPINDLE_STAT @@ -1380,7 +1380,7 @@ class EMC_TASK_PLAN_SET_OPTIONAL_STOP:public EMC_TASK_CMD_MSG { // Sub-class update() calls base-class update() // cppcheck-suppress duplInheritedMember void update(CMS * cms); - + bool state; //state == ON, optional stop is on (e.g. we stop on any stops) }; @@ -1395,7 +1395,7 @@ class EMC_TASK_PLAN_SET_BLOCK_DELETE:public EMC_TASK_CMD_MSG { // Sub-class update() calls base-class update() // cppcheck-suppress duplInheritedMember void update(CMS * cms); - + bool state; //state == ON, block delete is on, we ignore lines starting with "/" }; @@ -1409,7 +1409,7 @@ class EMC_TASK_PLAN_OPTIONAL_STOP:public EMC_TASK_CMD_MSG { // Sub-class update() calls base-class update() // cppcheck-suppress duplInheritedMember void update(CMS * cms); - + }; @@ -1461,7 +1461,7 @@ class EMC_TASK_STAT:public EMC_TASK_STAT_MSG { double activeSettings[ACTIVE_SETTINGS]; CANON_UNITS programUnits; // CANON_UNITS_INCHES, MM, CM - int interpreter_errcode; // return value from rs274ngc function + int interpreter_errcode; // return value from rs274ngc function // (only useful for new interpreter.) int task_paused; // non-zero means task is paused double delayLeft; // delay time left of G4, M66.. @@ -1748,7 +1748,7 @@ class EMC_SPINDLE_ORIENT:public EMC_SPINDLE_CMD_MSG { int spindle; double orientation; // desired spindle position - int mode; + int mode; }; class EMC_SPINDLE_WAIT_ORIENT_COMPLETE:public EMC_SPINDLE_CMD_MSG { diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 694c55b8325..51b3fc4fd7e 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -7,7 +7,7 @@ * Author: * License: GPL Version 2 * System: Linux -* +* * Copyright (c) 2004 All rights reserved. * ********************************************************************/ @@ -217,7 +217,7 @@ int emcOperatorError(const char *fmt, ...) error_msg.error[0] = 0; // append error string va_start(ap, fmt); - vsnprintf(&error_msg.error[strlen(error_msg.error)], + vsnprintf(&error_msg.error[strlen(error_msg.error)], sizeof(error_msg.error) - strlen(error_msg.error), fmt, ap); va_end(ap); @@ -466,7 +466,7 @@ static int checkInterpList(NML_INTERP_LIST * il, EMC_STAT * /*stat*/) emcOperatorError("%s", error_msg->error); break; } - + //FIXME: there was limit checking tests below, see if they were needed case EMC_TRAJ_LINEAR_MOVE_TYPE: break; @@ -535,7 +535,7 @@ void readahead_reading(void) EMC_TASK_INTERP::WAITING; interp_list.clear(); emcAbortCleanup(EMC_ABORT::INTERPRETER_ERROR, - "interpreter error"); + "interpreter error"); } else if (execRetval == -1 || execRetval == INTERP_EXIT ) { emcStatus->task.interpState = @@ -585,7 +585,7 @@ void readahead_reading(void) if (emcStatus->task.readLine < programStartLine && emcTaskPlanLevel() == 0) { - + //update the position with our current position, as the other positions are only skipped through CANON_UPDATE_END_POINT(emcStatus->motion.traj.actualPosition.tran.x, emcStatus->motion.traj.actualPosition.tran.y, @@ -648,7 +648,7 @@ static void mdi_execute_hook(void) emcTaskCommand == 0 && emcStatus->task.execState == EMC_TASK_EXEC::DONE) { - emcTaskPlanClearWait(); + emcTaskPlanClearWait(); mdi_execute_wait = 0; mdi_execute_hook(); } @@ -670,11 +670,11 @@ static void mdi_execute_hook(void) // determine when a MDI command actually finishes normally. if (interp_list.len() == 0 && emcTaskCommand == 0 && - emcStatus->task.execState == EMC_TASK_EXEC::DONE && - emcStatus->task.interpState != EMC_TASK_INTERP::IDLE && + emcStatus->task.execState == EMC_TASK_EXEC::DONE && + emcStatus->task.interpState != EMC_TASK_INTERP::IDLE && emcStatus->motion.traj.queue == 0 && - emcStatus->io.status == RCS_STATUS::DONE && - !mdi_execute_wait && + emcStatus->io.status == RCS_STATUS::DONE && + !mdi_execute_wait && !mdi_execute_next) { // finished. Check for dequeuing of queued MDI command is done in emcTaskPlan(). @@ -1076,7 +1076,7 @@ static int emcTaskPlan(void) case EMC_TASK_PLAN_STEP_TYPE: // handles case where first action is to step the program taskPlanRunCmd.line = 0; // run from start - /*! \todo FIXME-- can have GUI set this; send a run instead of a + /*! \todo FIXME-- can have GUI set this; send a run instead of a step */ retval = emcTaskIssueCommand(&taskPlanRunCmd); if(retval != 0) break; @@ -1174,7 +1174,7 @@ static int emcTaskPlan(void) break; case EMC_TASK_PLAN_STEP_TYPE: - emcStatus->motion.traj.stepping = 1; + emcStatus->motion.traj.single_stepping = 1; stepping = 1; // set stepping mode in case it's not steppingWait = 0; // clear the wait break; @@ -1189,7 +1189,7 @@ static int emcTaskPlan(void) // handle interp readahead logic readahead_reading(); - + break; // EMC_TASK_INTERP::READING case EMC_TASK_INTERP::PAUSED: // ON, AUTO, PAUSED @@ -1250,7 +1250,7 @@ static int emcTaskPlan(void) break; case EMC_TASK_PLAN_STEP_TYPE: - emcStatus->motion.traj.stepping = 1; + emcStatus->motion.traj.single_stepping = 1; stepping = 1; steppingWait = 0; if (emcStatus->motion.traj.paused && @@ -1326,7 +1326,7 @@ static int emcTaskPlan(void) break; case EMC_TASK_PLAN_STEP_TYPE: - emcStatus->motion.traj.stepping = 1; + emcStatus->motion.traj.single_stepping = 1; stepping = 1; // set stepping mode in case it's not steppingWait = 0; // clear the wait break; @@ -1895,10 +1895,10 @@ static int emcTaskIssueCommand(NMLmsg * cmd) case EMC_TRAJ_PROBE_TYPE: retval = emcTrajProbe( - ((EMC_TRAJ_PROBE *) cmd)->pos, + ((EMC_TRAJ_PROBE *) cmd)->pos, ((EMC_TRAJ_PROBE *) cmd)->type, ((EMC_TRAJ_PROBE *) cmd)->vel, - ((EMC_TRAJ_PROBE *) cmd)->ini_maxvel, + ((EMC_TRAJ_PROBE *) cmd)->ini_maxvel, ((EMC_TRAJ_PROBE *) cmd)->acc, ((EMC_TRAJ_PROBE *) cmd)->probe_type); break; @@ -1910,7 +1910,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) emcAuxInputWaitIndex = -1; taskExecDelayTimeout = 0.0; } else { - emcAuxInputWaitType = emcAuxInputWaitMsg->wait_type; // remember what we are waiting for + emcAuxInputWaitType = emcAuxInputWaitMsg->wait_type; // remember what we are waiting for emcAuxInputWaitIndex = emcAuxInputWaitMsg->index; // remember the input to look at emcStatus->task.input_timeout = 2; // set timeout flag, gets cleared if input changes before timeout happens // set the timeout clock to expire at 'now' + delay time @@ -1927,7 +1927,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) emcTrajUpdateTag(((EMC_TRAJ_LINEAR_MOVE *) cmd)->tag); retval = emcTrajRigidTap(((EMC_TRAJ_RIGID_TAP *) cmd)->pos, ((EMC_TRAJ_RIGID_TAP *) cmd)->vel, - ((EMC_TRAJ_RIGID_TAP *) cmd)->ini_maxvel, + ((EMC_TRAJ_RIGID_TAP *) cmd)->ini_maxvel, ((EMC_TRAJ_RIGID_TAP *) cmd)->acc, ((EMC_TRAJ_RIGID_TAP *) cmd)->scale); break; @@ -2126,7 +2126,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) // clear out the interpreter state emcStatus->task.interpState = EMC_TASK_INTERP::IDLE; emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcStatus->motion.traj.stepping = 0; + emcStatus->motion.traj.single_stepping = 0; stepping = 0; steppingWait = 0; @@ -2221,7 +2221,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) break; case EMC_TASK_PLAN_EXECUTE_TYPE: - emcStatus->motion.traj.stepping = 0; + emcStatus->motion.traj.single_stepping = 0; stepping = 0; steppingWait = 0; execute_msg = (EMC_TASK_PLAN_EXECUTE *) cmd; @@ -2317,7 +2317,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) retval = -1; break; } - emcStatus->motion.traj.stepping = 0; + emcStatus->motion.traj.single_stepping = 0; stepping = 0; steppingWait = 0; if (!taskplanopen && emcStatus->task.file[0] != 0) { @@ -2366,7 +2366,7 @@ static int emcTaskIssueCommand(NMLmsg * cmd) emcTrajResume(); emcStatus->task.interpState = interpResumeState; emcStatus->task.task_paused = 0; - emcStatus->motion.traj.stepping = 0; + emcStatus->motion.traj.single_stepping = 0; stepping = 0; steppingWait = 0; retval = 0; @@ -2597,7 +2597,7 @@ static int emcTaskExecute(void) // clear out the interpreter state emcStatus->task.interpState = EMC_TASK_INTERP::IDLE; emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcStatus->motion.traj.stepping = 0; + emcStatus->motion.traj.single_stepping = 0; stepping = 0; steppingWait = 0; @@ -2746,7 +2746,7 @@ static int emcTaskExecute(void) } // delay can be also be because we wait for an input // if the index is set (not -1) - if (emcAuxInputWaitIndex >= 0) { + if (emcAuxInputWaitIndex >= 0) { switch (emcAuxInputWaitType) { case WAIT_MODE_HIGH: if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] != 0) { @@ -2757,12 +2757,12 @@ static int emcTaskExecute(void) } break; - case WAIT_MODE_RISE: + case WAIT_MODE_RISE: if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] == 0) { emcAuxInputWaitType = WAIT_MODE_HIGH; } break; - + case WAIT_MODE_LOW: if (emcStatus->motion.synch_di[emcAuxInputWaitIndex] == 0) { emcStatus->task.input_timeout = 0; // clear timeout flag @@ -2784,7 +2784,7 @@ static int emcTaskExecute(void) emcStatus->task.execState = EMC_TASK_EXEC::DONE; emcStatus->task.delayLeft = 0; break; - + default: emcOperatorError("Unknown Wait Mode"); } @@ -3443,7 +3443,7 @@ int main(int argc, char *argv[]) // check for subordinate errors, and halt task if so if ( emcStatus->motion.status == RCS_STATUS::ERROR - && emcStatus->motion.on_soft_limit) { + && emcStatus->motion.on_soft_limit) { if (!gave_soft_limit_message) { emcOperatorError("On Soft Limit"); // if gui does not provide a means to switch to joint mode @@ -3472,7 +3472,7 @@ int main(int argc, char *argv[]) } // motion already should have reported this condition (and set RCS_STATUS::ERROR?) // an M19 orient failed to complete within timeout - // if ((emcStatus->motion.status == RCS_STATUS::ERROR) && + // if ((emcStatus->motion.status == RCS_STATUS::ERROR) && // (emcStatus->motion.spindle.orient_state == EMCMOT_ORIENT_FAULTED) && // (emcStatus->motion.spindle.orient_fault != 0)) { // emcOperatorError("wait for orient complete timed out"); @@ -3505,7 +3505,7 @@ int main(int argc, char *argv[]) // clear out the interpreter state emcStatus->task.interpState = EMC_TASK_INTERP::IDLE; emcStatus->task.execState = EMC_TASK_EXEC::DONE; - emcStatus->motion.traj.stepping = 0; + emcStatus->motion.traj.single_stepping = 0; stepping = 0; steppingWait = 0; diff --git a/src/emc/usr_intf/axis/extensions/emcmodule.cc b/src/emc/usr_intf/axis/extensions/emcmodule.cc index d1f5ff85082..068f652c593 100644 --- a/src/emc/usr_intf/axis/extensions/emcmodule.cc +++ b/src/emc/usr_intf/axis/extensions/emcmodule.cc @@ -466,7 +466,7 @@ static PyMemberDef Stat_members[] = { {(char*)"queue_full", T_BOOL, O(motion.traj.queueFull), READONLY, NULL}, {(char*)"motion_id", T_INT, O(motion.traj.id), READONLY, NULL}, {(char*)"paused", T_BOOL, O(motion.traj.paused), READONLY, NULL}, - {(char*)"stepping", T_BOOL, O(motion.traj.stepping), READONLY, NULL}, + {(char*)"single_stepping", T_BOOL, O(motion.traj.single_stepping), READONLY, NULL}, {(char*)"feedrate", T_DOUBLE, O(motion.traj.scale), READONLY, NULL}, {(char*)"rapidrate", T_DOUBLE, O(motion.traj.rapid_scale), READONLY, NULL}, {(char*)"velocity", T_DOUBLE, O(motion.traj.velocity), READONLY, NULL}, @@ -2593,7 +2593,7 @@ static struct PyModuleDef linuxcnc_moduledef = { PyMODINIT_FUNC PyInit_linuxcnc(void); PyMODINIT_FUNC PyInit_linuxcnc(void) { - + verbose_nml_error_messages = 0; clear_rcs_print_flag(~0);