From: Pavel Shramov <p...@lebu.psha.org.ru> When call returns INERP_EXECUTE_FINISH value check if call depth was changed and if so issue execute(0) commands until it returns to pre-call value.
Uses 0xff to mark command as NULL since it's not possible to set char[256] to NULL value. Signed-off-by: Pavel Shramov <shra...@mexmat.net> --- src/emc/task/emctaskmain.cc | 53 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 52 insertions(+), 1 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index ebea2de..ecf0495 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -383,6 +383,10 @@ int stepping = 0; int steppingWait = 0; static int steppedLine = 0; +// Variables to handle MDI call interrupts +static int mdi_execute_level = -1; +static int mdi_execute_queue = 0; + /* checkInterpList(NML_INTERP_LIST *il, EMC_STAT *stat) takes a pointer to an interpreter list and a pointer to the EMC status, pops each NML @@ -615,6 +619,33 @@ interpret_again: } // if interp len is less than max } +static void mdi_execute_hook(void) +{ + if (mdi_execute_level < 0) return; + + if (interp_list.len() > EMC_TASK_INTERP_MAX_LEN) return; + + if (emcTaskPlanIsWait()) { + // delay reading of next line until all is done + if (interp_list.len() == 0 && + emcTaskCommand == 0 && + emcStatus->task.execState == + EMC_TASK_EXEC_DONE) { + emcTaskPlanClearWait(); + mdi_execute_hook(); + } + return; + } + + if (!mdi_execute_queue) return; + mdi_execute_queue = 0; + + EMC_TASK_PLAN_EXECUTE msg; + msg.command[0] = (char) 0xff; + + interp_list.append(msg); +} + void readahead_waiting(void) { // now handle call logic @@ -1278,6 +1309,7 @@ static int emcTaskPlan(void) break; } // switch (type) in ON, MDI + mdi_execute_hook(); break; // case EMC_TASK_MODE_MDI @@ -1969,10 +2001,29 @@ static int emcTaskIssueCommand(NMLmsg * cmd) break; } if (execute_msg->command[0] != 0) { + int level = emcTaskPlanLevel(); if (emcStatus->task.mode == EMC_TASK_MODE_MDI) { interp_list.set_line_number(++pseudoMdiLineNumber); + if (mdi_execute_level < 0) + mdi_execute_level = level; + } + char * command = execute_msg->command; + if (command[0] == (char) 0xff) { + // Empty command recieved. Consider it is NULL + command = NULL; + } + execRetval = emcTaskPlanExecute(command, pseudoMdiLineNumber); + + level = emcTaskPlanLevel(); + + if (emcStatus->task.mode == EMC_TASK_MODE_MDI) { + if (mdi_execute_level == level) { + mdi_execute_level = -1; + } else if (level > 0) { + // Still insude call. Need another execute(0) call + mdi_execute_queue = 1; + } } - execRetval = emcTaskPlanExecute(execute_msg->command, pseudoMdiLineNumber); if (execRetval == INTERP_EXECUTE_FINISH) { // need to flush execution, so signify no more reading // until all is done -- 1.7.1 ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers