Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/docs/man/man1/linuxcncrsh.1 b/docs/man/man1/linuxcncrsh.1
- index 94cbd54..215d0f4 100644
- --- a/docs/man/man1/linuxcncrsh.1
- +++ b/docs/man/man1/linuxcncrsh.1
- @@ -515,6 +515,11 @@ With set, step the program one line.
- With get, returns the name of the currently opened program, or "none".
- .RE
- .P
- +\fBprogram_length\fR
- +.RS
- +With get, returns the number of lines of the currently opened program or 0.
- +.RE
- +.P
- \fBprogram_line\fR
- .RS
- With get, returns the currently executing line of the program.
- diff --git a/src/emc/usr_intf/emcrsh.cc b/src/emc/usr_intf/emcrsh.cc
- index f1bda64..29e5d4e 100644
- --- a/src/emc/usr_intf/emcrsh.cc
- +++ b/src/emc/usr_intf/emcrsh.cc
- @@ -431,7 +431,7 @@ typedef enum {
- scLoadToolTable, scHome, scJogStop, scJog, scJogIncr, scFeedOverride,
- scAbsCmdPos, scAbsActPos, scRelCmdPos, scRelActPos, scJointPos, scPosOffset,
- scJointLimit, scJointFault, scJointHomed, scMDI, scTskPlanInit, scOpen, scRun
- ,
- - scPause, scResume, scStep, scAbort, scProgram, scProgramLine, scProgramStatus
- ,
- + scPause, scResume, scStep, scAbort, scProgram, scProgramLength, scProgramLine
- , scProgramStatus,
- scProgramCodes, scJointType, scJointUnits, scProgramUnits, scProgramLinearUni
- ts,
- scProgramAngularUnits, scUserLinearUnits, scUserAngularUnits, scDisplayLinear
- Units,
- scDisplayAngularUnits, scLinearUnitConversion, scAngularUnitConversion, scPr
- obeClear,
- @@ -480,7 +480,7 @@ const char *setCommands[] = {
- "JOG_STOP", "JOG", "JOG_INCR", "FEED_OVERRIDE", "ABS_CMD_POS", "ABS_ACT_POS",
- "REL_CMD_POS", "REL_ACT_POS", "JOINT_POS", "POS_OFFSET", "JOINT_LIMIT",
- "JOINT_FAULT", "JOINT_HOMED", "MDI", "TASK_PLAN_INIT", "OPEN", "RUN", "PAUSE"
- ,
- - "RESUME", "STEP", "ABORT", "PROGRAM", "PROGRAM_LINE", "PROGRAM_STATUS", "PROG
- RAM_CODES",
- + "RESUME", "STEP", "ABORT", "PROGRAM", "PROGRAM_LENGTH", "PROGRAM_LINE", "PROG
- RAM_STATUS", "PROGRAM_CODES",
- "JOINT_TYPE", "JOINT_UNITS", "PROGRAM_UNITS", "PROGRAM_LINEAR_UNITS", "PROGRA
- M_ANGULAR_UNITS",
- "USER_LINEAR_UNITS", "USER_ANGULAR_UNITS", "DISPLAY_LINEAR_UNITS", "DISPLAY_A
- NGULAR_UNITS",
- "LINEAR_UNIT_CONVERSION", "ANGULAR_UNIT_CONVERSION", "PROBE_CLEAR", "PROBE_TR
- IPPED",
- @@ -1268,6 +1268,7 @@ int commandSet(connectionRecType *context)
- case scAbort: ret = setAbort(pch, context); break;
- case scStep: ret = setStep(pch, context); break;
- case scProgram:ret = rtStandardError; break;
- + case scProgramLength: ret = rtStandardError; break;
- case scProgramLine: ret = rtStandardError; break;
- case scProgramStatus: ret = rtStandardError; break;
- case scProgramCodes: ret = rtStandardError; break;
- @@ -1911,6 +1912,29 @@ static cmdResponseType getProgram(char *s, connectionRecT
- ype *context)
- return rtNoError;
- }
- +static cmdResponseType getProgramLength(char *s, connectionRecType *context)
- +{
- + const char *pProgramLength = "PROGRAM_LENGTH %d";
- + if (emcStatus->task.file[0] == 0) {
- + sprintf(context->outBuf, pProgramLength, 0);
- + } else {
- + FILE *prg;
- + prg = fopen(emcStatus->task.file,"r");
- + if (!prg) {
- + sprintf(context->outBuf, pProgramLength, 0);
- + } else {
- + char buf[80];
- + int count = 0;
- + while (fgets(buf, 80, prg)) {
- + int len = strlen(buf);
- + if (buf[len-1] == '\n') count++;
- + }
- + fclose(prg);
- + sprintf(context->outBuf, pProgramLength, count);
- + }
- + }
- + return rtNoError;
- +}
- static cmdResponseType getProgramLine(char *s, connectionRecType *context)
- {
- const char *pProgramLine = "PROGRAM_LINE %d";
- @@ -2319,6 +2343,7 @@ int commandGet(connectionRecType *context)
- case scStep: ret = rtStandardError; break;
- case scAbort: ret = rtStandardError; break;
- case scProgram: ret = getProgram(pch, context); break;
- + case scProgramLength: ret = getProgramLength(pch, context); break;
- case scProgramLine: ret = getProgramLine(pch, context); break;
- case scProgramStatus: ret = getProgramStatus(pch, context); break;
- case scProgramCodes: ret = getProgramCodes(pch, context); break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement