From: Chris R. <gi...@gi...> - 2009-07-20 18:43:00
|
stop being ridiculous and start counting properly from zero http://git.linuxcnc.org/?p=emc2.git;a=commitdiff;h=028dd2b --- src/emc/iotask/ioControl.cc | 25 ++++++++++++------------- src/emc/nml_intf/emc_nml.hh | 2 +- src/emc/nml_intf/emcops.cc | 4 ++-- src/emc/rs274ngc/interp_internal.hh | 2 +- src/emc/rs274ngc/rs274ngc_pre.cc | 4 ++-- src/emc/task/emccanon.cc | 4 ++-- src/emc/usr_intf/axis/extensions/emcmodule.cc | 2 +- 7 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/emc/iotask/ioControl.cc b/src/emc/iotask/ioControl.cc index f4e3bae..7d56521 100644 --- a/src/emc/iotask/ioControl.cc +++ b/src/emc/iotask/ioControl.cc @@ -74,7 +74,7 @@ static RCS_STAT_CHANNEL *emcioStatusBuffer = 0; static EMC_IO_STAT emcioStatus; static NML *emcErrorBuffer = 0; -static char *ttcomments[CANON_POCKETS_MAX+1]; +static char *ttcomments[CANON_POCKETS_MAX]; struct iocontrol_str { hal_bit_t *user_enable_out; /* output, TRUE when EMC wants stop */ @@ -281,7 +281,7 @@ static int loadToolTable(const char *filename, return -1; } // clear out tool table - for (t = 0; t <= CANON_POCKETS_MAX; t++) { + for (t = 0; t < CANON_POCKETS_MAX; t++) { // unused tools are 0, 0.0, 0.0 toolTable[t].toolno = 0; toolTable[t].zoffset = 0.0; @@ -329,7 +329,7 @@ static int loadToolTable(const char *filename, &pocket, &toolno, &zoffset, &xoffset, &diameter, &frontangle, &backangle, &orientation, comment)) && (scanned == 8 || scanned == 9)) { - if (pocket < 0 || pocket > CANON_POCKETS_MAX) { + if (pocket < 0 || pocket >= CANON_POCKETS_MAX) { printf("skipping tool: bad pocket number %d\n", pocket); continue; } else { @@ -347,7 +347,7 @@ static int loadToolTable(const char *filename, } else if ((scanned = sscanf(buffer, "%d %d %lf %lf %[^\n]", &pocket, &toolno, &zoffset, &diameter, comment)) && (scanned == 4 || scanned == 5)) { - if (pocket < 0 || pocket > CANON_POCKETS_MAX) { + if (pocket < 0 || pocket >= CANON_POCKETS_MAX) { printf("skipping tool: bad pocket number %d\n", pocket); continue; } else { @@ -396,7 +396,7 @@ static int saveToolTable(const char *filename, const char *name; int lathe_style = 0; - for(pocket=1; pocket <= CANON_POCKETS_MAX; pocket++) { + for(pocket=0; pocket < CANON_POCKETS_MAX; pocket++) { if(toolTable[pocket].orientation != 0) { lathe_style = 1; break; @@ -422,7 +422,7 @@ static int saveToolTable(const char *filename, "POCKET", "TOOLNO", "ZOFFSET", "XOFFSET", "DIAMETER", "FRONTANGLE", "BACKANGLE", "ORIENT", "COMMENT"); - for (pocket = 0; pocket <= CANON_POCKETS_MAX; pocket++) { + for (pocket = 0; pocket < CANON_POCKETS_MAX; pocket++) { if (toolTable[pocket].toolno) fprintf(fp, "%7d%7d%+11f%+11f%11f%+12f%+12f%7d %s\n", pocket, @@ -434,7 +434,7 @@ static int saveToolTable(const char *filename, } else { fprintf(fp, "%7s%7s%11s%11s %s\n\n", "POCKET", "TOOLNO", "LENGTH", "DIAMETER", "COMMENT"); - for (pocket = 0; pocket <= CANON_POCKETS_MAX; pocket++) { + for (pocket = 0; pocket < CANON_POCKETS_MAX; pocket++) { if (toolTable[pocket].toolno) fprintf(fp, "%7d%7d%+11f%11f %s\n", pocket, @@ -833,7 +833,7 @@ int main(int argc, char *argv[]) return -1; } - for(int i=0; i<CANON_POCKETS_MAX+1; i++) { + for(int i=0; i<CANON_POCKETS_MAX; i++) { ttcomments[i] = (char *)malloc(CANON_TOOL_ENTRY_LEN); } @@ -936,9 +936,8 @@ int main(int argc, char *argv[]) break; case EMC_TOOL_LOAD_TYPE: - rtapi_print_msg(RTAPI_MSG_ERR, "EMC_TOOL_LOAD loaded=%d prepped=%d\n", emcioStatus.tool.toolInSpindle, emcioStatus.tool.toolPrepped); - if ( emcioStatus.tool.toolInSpindle != emcioStatus.tool.toolPrepped - && emcioStatus.tool.toolPrepped != -1) { + rtapi_print_msg(RTAPI_MSG_DBG, "EMC_TOOL_LOAD loaded=%d prepped=%d\n", emcioStatus.tool.toolInSpindle, emcioStatus.tool.toolPrepped); + if (emcioStatus.tool.toolPrepped != -1) { //notify HW for toolchange *(iocontrol_data->tool_change) = 1; // the feedback logic is done inside read_hal_inputs() we only @@ -977,7 +976,7 @@ int main(int argc, char *argv[]) b = ((EMC_TOOL_SET_OFFSET *) emcioCommand)->backangle; o = ((EMC_TOOL_SET_OFFSET *) emcioCommand)->orientation; - rtapi_print_msg(RTAPI_MSG_ERR, + rtapi_print_msg(RTAPI_MSG_DBG, "EMC_TOOL_SET_OFFSET pocket=%d toolno=%d zoffset=%lf, xoffset=%lf, diameter=%lf," " frontangle=%lf, backangle=%lf, orientation=%d\n", p, t, z, x, d, f, b, o); @@ -1102,7 +1101,7 @@ int main(int argc, char *argv[]) emcioCommandBuffer = 0; } - for(int i=0; i<CANON_POCKETS_MAX+1; i++) { + for(int i=0; i<CANON_POCKETS_MAX; i++) { free(ttcomments[i]); } diff --git a/src/emc/nml_intf/emc_nml.hh b/src/emc/nml_intf/emc_nml.hh index c95010c..5f46e84 100644 --- a/src/emc/nml_intf/emc_nml.hh +++ b/src/emc/nml_intf/emc_nml.hh @@ -1541,7 +1541,7 @@ class EMC_TOOL_STAT:public EMC_TOOL_STAT_MSG { int toolPrepped; // tool ready for loading, 0 is no tool int toolInSpindle; // tool loaded, 0 is no tool - CANON_TOOL_TABLE toolTable[CANON_POCKETS_MAX + 1]; + CANON_TOOL_TABLE toolTable[CANON_POCKETS_MAX]; }; // EMC_AUX type declarations diff --git a/src/emc/nml_intf/emcops.cc b/src/emc/nml_intf/emcops.cc index d8581c1..ae8f8b0 100644 --- a/src/emc/nml_intf/emcops.cc +++ b/src/emc/nml_intf/emcops.cc @@ -151,7 +151,7 @@ EMC_TOOL_STAT_MSG(EMC_TOOL_STAT_TYPE, sizeof(EMC_TOOL_STAT)) toolPrepped = 0; toolInSpindle = 0; - for (t = 0; t <= CANON_POCKETS_MAX; t++) { + for (t = 0; t < CANON_POCKETS_MAX; t++) { toolTable[t].toolno = 0; toolTable[t].xoffset = 0.0; toolTable[t].zoffset = 0.0; @@ -201,7 +201,7 @@ EMC_TOOL_STAT EMC_TOOL_STAT::operator =(EMC_TOOL_STAT s) toolPrepped = s.toolPrepped; toolInSpindle = s.toolInSpindle; - for (t = 0; t <= CANON_POCKETS_MAX; t++) { + for (t = 0; t < CANON_POCKETS_MAX; t++) { toolTable[t].toolno = s.toolTable[t].toolno; toolTable[t].xoffset = s.toolTable[t].xoffset; toolTable[t].zoffset = s.toolTable[t].zoffset; diff --git a/src/emc/rs274ngc/interp_internal.hh b/src/emc/rs274ngc/interp_internal.hh index 6d401ec..ae5706a 100644 --- a/src/emc/rs274ngc/interp_internal.hh +++ b/src/emc/rs274ngc/interp_internal.hh @@ -432,7 +432,7 @@ typedef struct setup_struct double tool_xoffset; // current tool X offset double tool_woffset; // current tool W offset int pockets_max; // number of pockets in carousel (including pocket 0, the spindle) - CANON_TOOL_TABLE tool_table[CANON_POCKETS_MAX + 1]; // index is pocket number + CANON_TOOL_TABLE tool_table[CANON_POCKETS_MAX]; // index is pocket number double traverse_rate; // rate for traverse motions /* stuff for subroutines and control structures */ diff --git a/src/emc/rs274ngc/rs274ngc_pre.cc b/src/emc/rs274ngc/rs274ngc_pre.cc index 5ac0f0f..cc8a51b 100644 --- a/src/emc/rs274ngc/rs274ngc_pre.cc +++ b/src/emc/rs274ngc/rs274ngc_pre.cc @@ -619,10 +619,10 @@ int Interp::load_tool_table() int n; CHKS((_setup.pockets_max > CANON_POCKETS_MAX), NCE_POCKET_MAX_TOO_LARGE); - for (n = 0; n <= _setup.pockets_max; n++) { + for (n = 0; n < _setup.pockets_max; n++) { _setup.tool_table[n] = GET_EXTERNAL_TOOL_TABLE(n); } - for (; n <= CANON_POCKETS_MAX; n++) { + for (; n < CANON_POCKETS_MAX; n++) { _setup.tool_table[n].toolno = 0; _setup.tool_table[n].xoffset = 0; _setup.tool_table[n].zoffset = 0; diff --git a/src/emc/task/emccanon.cc b/src/emc/task/emccanon.cc index d86e89e..ff7c201 100644 --- a/src/emc/task/emccanon.cc +++ b/src/emc/task/emccanon.cc @@ -2369,7 +2369,7 @@ void CANON_ERROR(const char *fmt, ...) GET_EXTERNAL_TOOL_TABLE(int pocket) Returns the tool table structure associated with pocket. Note that - pocket can run from 0 (by definition, no tool), to pocket CANON_POCKETS_MAX - 1. + pocket can run from 0 (by definition, the spindle), to pocket CANON_POCKETS_MAX - 1. Tool table is always in machine units. @@ -2378,7 +2378,7 @@ CANON_TOOL_TABLE GET_EXTERNAL_TOOL_TABLE(int pocket) { CANON_TOOL_TABLE retval; - if (pocket < 1 || pocket >= CANON_POCKETS_MAX) { + if (pocket < 0 || pocket >= CANON_POCKETS_MAX) { retval.toolno = 0; retval.xoffset = 0.0; retval.zoffset = 0.0; diff --git a/src/emc/usr_intf/axis/extensions/emcmodule.cc b/src/emc/usr_intf/axis/extensions/emcmodule.cc index 88b66df..d8ef599 100644 --- a/src/emc/usr_intf/axis/extensions/emcmodule.cc +++ b/src/emc/usr_intf/axis/extensions/emcmodule.cc @@ -568,7 +568,7 @@ static PyTypeObject ToolResultType; static PyObject *Stat_tool_table(pyStatChannel *s) { PyObject *res = PyTuple_New(CANON_POCKETS_MAX); int j=0; - for(int i=1; i<=CANON_POCKETS_MAX; i++) { + for(int i=0; i<CANON_POCKETS_MAX; i++) { struct CANON_TOOL_TABLE &t = s->status.io.tool.toolTable[i]; if(t.toolno == 0) continue; PyObject *tool = PyStructSequence_New(&ToolResultType); |