Advertisement
Guest User

linuxcncrsh mods.

a guest
Jul 7th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. diff --git a/docs/man/man1/linuxcncrsh.1 b/docs/man/man1/linuxcncrsh.1
  2. index 94cbd54..215d0f4 100644
  3. --- a/docs/man/man1/linuxcncrsh.1
  4. +++ b/docs/man/man1/linuxcncrsh.1
  5. @@ -515,6 +515,11 @@ With set, step the program one line.
  6. With get, returns the name of the currently opened program, or "none".
  7. .RE
  8. .P
  9. +\fBprogram_length\fR
  10. +.RS
  11. +With get, returns the number of lines of the currently opened program or 0.
  12. +.RE
  13. +.P
  14. \fBprogram_line\fR
  15. .RS
  16. With get, returns the currently executing line of the program.
  17. diff --git a/src/emc/usr_intf/emcrsh.cc b/src/emc/usr_intf/emcrsh.cc
  18. index f1bda64..29e5d4e 100644
  19. --- a/src/emc/usr_intf/emcrsh.cc
  20. +++ b/src/emc/usr_intf/emcrsh.cc
  21. @@ -431,7 +431,7 @@ typedef enum {
  22. scLoadToolTable, scHome, scJogStop, scJog, scJogIncr, scFeedOverride,
  23. scAbsCmdPos, scAbsActPos, scRelCmdPos, scRelActPos, scJointPos, scPosOffset,
  24. scJointLimit, scJointFault, scJointHomed, scMDI, scTskPlanInit, scOpen, scRun
  25. ,
  26. - scPause, scResume, scStep, scAbort, scProgram, scProgramLine, scProgramStatus
  27. ,
  28. + scPause, scResume, scStep, scAbort, scProgram, scProgramLength, scProgramLine
  29. , scProgramStatus,
  30. scProgramCodes, scJointType, scJointUnits, scProgramUnits, scProgramLinearUni
  31. ts,
  32. scProgramAngularUnits, scUserLinearUnits, scUserAngularUnits, scDisplayLinear
  33. Units,
  34. scDisplayAngularUnits, scLinearUnitConversion, scAngularUnitConversion, scPr
  35. obeClear,
  36. @@ -480,7 +480,7 @@ const char *setCommands[] = {
  37. "JOG_STOP", "JOG", "JOG_INCR", "FEED_OVERRIDE", "ABS_CMD_POS", "ABS_ACT_POS",
  38. "REL_CMD_POS", "REL_ACT_POS", "JOINT_POS", "POS_OFFSET", "JOINT_LIMIT",
  39. "JOINT_FAULT", "JOINT_HOMED", "MDI", "TASK_PLAN_INIT", "OPEN", "RUN", "PAUSE"
  40. ,
  41. - "RESUME", "STEP", "ABORT", "PROGRAM", "PROGRAM_LINE", "PROGRAM_STATUS", "PROG
  42. RAM_CODES",
  43. + "RESUME", "STEP", "ABORT", "PROGRAM", "PROGRAM_LENGTH", "PROGRAM_LINE", "PROG
  44. RAM_STATUS", "PROGRAM_CODES",
  45. "JOINT_TYPE", "JOINT_UNITS", "PROGRAM_UNITS", "PROGRAM_LINEAR_UNITS", "PROGRA
  46. M_ANGULAR_UNITS",
  47. "USER_LINEAR_UNITS", "USER_ANGULAR_UNITS", "DISPLAY_LINEAR_UNITS", "DISPLAY_A
  48. NGULAR_UNITS",
  49. "LINEAR_UNIT_CONVERSION", "ANGULAR_UNIT_CONVERSION", "PROBE_CLEAR", "PROBE_TR
  50. IPPED",
  51. @@ -1268,6 +1268,7 @@ int commandSet(connectionRecType *context)
  52. case scAbort: ret = setAbort(pch, context); break;
  53. case scStep: ret = setStep(pch, context); break;
  54. case scProgram:ret = rtStandardError; break;
  55. + case scProgramLength: ret = rtStandardError; break;
  56. case scProgramLine: ret = rtStandardError; break;
  57. case scProgramStatus: ret = rtStandardError; break;
  58. case scProgramCodes: ret = rtStandardError; break;
  59. @@ -1911,6 +1912,29 @@ static cmdResponseType getProgram(char *s, connectionRecT
  60. ype *context)
  61. return rtNoError;
  62. }
  63.  
  64. +static cmdResponseType getProgramLength(char *s, connectionRecType *context)
  65. +{
  66. + const char *pProgramLength = "PROGRAM_LENGTH %d";
  67. + if (emcStatus->task.file[0] == 0) {
  68. + sprintf(context->outBuf, pProgramLength, 0);
  69. + } else {
  70. + FILE *prg;
  71. + prg = fopen(emcStatus->task.file,"r");
  72. + if (!prg) {
  73. + sprintf(context->outBuf, pProgramLength, 0);
  74. + } else {
  75. + char buf[80];
  76. + int count = 0;
  77. + while (fgets(buf, 80, prg)) {
  78. + int len = strlen(buf);
  79. + if (buf[len-1] == '\n') count++;
  80. + }
  81. + fclose(prg);
  82. + sprintf(context->outBuf, pProgramLength, count);
  83. + }
  84. + }
  85. + return rtNoError;
  86. +}
  87. static cmdResponseType getProgramLine(char *s, connectionRecType *context)
  88. {
  89. const char *pProgramLine = "PROGRAM_LINE %d";
  90. @@ -2319,6 +2343,7 @@ int commandGet(connectionRecType *context)
  91. case scStep: ret = rtStandardError; break;
  92. case scAbort: ret = rtStandardError; break;
  93. case scProgram: ret = getProgram(pch, context); break;
  94. + case scProgramLength: ret = getProgramLength(pch, context); break;
  95. case scProgramLine: ret = getProgramLine(pch, context); break;
  96. case scProgramStatus: ret = getProgramStatus(pch, context); break;
  97. case scProgramCodes: ret = getProgramCodes(pch, context); break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement