Share

Enhanced Machine Controller

Tracker: Bugs

5 Parameters corrupted by subroutine return command - ID: 1772411
Last Update: Comment added ( jepler )

When a subroutine returns using the Oxxx return command to a calling
subroutine, the parameters in the calling subroutine become corrupted.

For example, if S1 calls S2, when S2 returns using the Oxxx return command,
the #1, #2, etc. parameters in S1 become corrupted.

SAMPLE GCODE
------------

(DUMMY SUBROUTINE)
O100 sub
O100 return
O100 endsub

(MAIN SUBROUTINE)
O200 sub
G00 X#1 Y#2 Z#3
O100 call
(#1 #2 and #3 are now corrupted upon return from dummy subroutine)
G00 X#1 Y#2 Z#3
O200 endsub

(MAIN)
O200 call [1] [2] [3]
M02


Nobody/Anonymous ( nobody ) - 2007-08-11 20:31

5

Closed

Fixed

Kenneth Lerman

G-code Interpreter

None

Public


Comments ( 3 )




Date: 2007-08-17 13:57
Sender: jeplerProject Admin


lerman's change does fix the test case, and I've committed it to the CVS
version of emc. The fix will be in the next release of emc, whether it's
2.1.8 or 2.2.0.


Date: 2007-08-17 12:17
Sender: jeplerProject Admin


I've added a test case to the CVS version of emc, and next i'll try
applying the change that lerman suggests.


Date: 2007-08-12 18:43
Sender: lerman


Sorry about that. I've identified the problem and the cure (I think).

In file rs274ngc/interp_o_word.cc around line 492, change:
case O_return:
if(settings->call_level == 0)
{
// this is in the definition
break;
}

// if we were skipping, no longer
settings->skipping_o = 0;

// in a call -- must do a return
// restore old values of parameters
// restore file position from context

settings->call_level--;

for(i=0; i<INTERP_SUB_PARAMS; i++)
{
settings->parameters[i] =
settings->sub_context[settings->call_level].saved_params[i];
}

To:
case O_return:
if(settings->call_level == 0)
{
// this is in the definition
break;
}

// if we were skipping, no longer
settings->skipping_o = 0;

// in a call -- must do a return
// restore old values of parameters
// restore file position from context

settings->call_level--;

for(i=0; i<INTERP_SUB_PARAMS; i++)
{
settings->parameters[i+INTERP_FIRST_SUBROUTINE_PARAM] =
settings->sub_context[settings->call_level].saved_params[i];
}
[Unfortunately, I don't have a machine currently containing EMC2, so I
can't try this out. I also don't know how current the source I'm looking at
is, so the line number might be off. I expect to have a new machine on line
in a week or two. (lerman)]

Thank you for reporting the bug.



Log in to comment.

Attached File

No Files Currently Attached

Changes ( 4 )

Field Old Value Date By
status_id Open 2007-08-17 13:57 jepler
resolution_id None 2007-08-17 13:57 jepler
close_date - 2007-08-17 13:57 jepler
assigned_to nobody 2007-08-12 18:43 lerman