diff --git a/ecmc_plugin_grbl/ecmcGrbl.cpp b/ecmc_plugin_grbl/ecmcGrbl.cpp index 1a17c35..d746852 100644 --- a/ecmc_plugin_grbl/ecmcGrbl.cpp +++ b/ecmc_plugin_grbl/ecmcGrbl.cpp @@ -731,7 +731,7 @@ int ecmcGrbl::setReset(int reset) { if(!resetCmd_ && reset) { mc_reset(); } - resetCmd_ = reset; + resetCmd_ = reset; return 0; } @@ -739,6 +739,14 @@ int ecmcGrbl::getBusy() { return getEcmcEpicsIOCState()!=16 || writerBusy_ || stepperInterruptEnable; } +int ecmcGrbl::getParserBusy() { + return getEcmcEpicsIOCState()!=16 || writerBusy_; +} + +int ecmcGrbl::getCodeRowNum() { + return grblCommandBufferIndex_; +} + // Avoid issues with std:to_string() std::string ecmcGrbl::to_string(int value) { std::ostringstream os; diff --git a/ecmc_plugin_grbl/ecmcGrbl.h b/ecmc_plugin_grbl/ecmcGrbl.h index 1cbab41..d986346 100644 --- a/ecmc_plugin_grbl/ecmcGrbl.h +++ b/ecmc_plugin_grbl/ecmcGrbl.h @@ -52,7 +52,9 @@ class ecmcGrbl : public asynPortDriver { int setResume(int resume); int setReset(int reset); int getBusy(); - + int getParserBusy(); + int getCodeRowNum(); + private: void parseConfigStr(char *configStr); void preExeAxes(); diff --git a/ecmc_plugin_grbl/ecmcGrblWrap.cpp b/ecmc_plugin_grbl/ecmcGrblWrap.cpp index 962b27b..8f950e7 100644 --- a/ecmc_plugin_grbl/ecmcGrblWrap.cpp +++ b/ecmc_plugin_grbl/ecmcGrblWrap.cpp @@ -99,6 +99,21 @@ int getBusy() { return 0; } +int getParserBusy() { + if(grbl){ + return grbl->getParserBusy(); + } + return 0; +} + +int getCodeRowNum() { + if(grbl){ + return grbl->getCodeRowNum(); + } + return 0; +} + + int setReset(int reset) { if(grbl){ return grbl->setReset(reset); diff --git a/ecmc_plugin_grbl/ecmcGrblWrap.h b/ecmc_plugin_grbl/ecmcGrblWrap.h index 6e0bb5b..7e841d6 100644 --- a/ecmc_plugin_grbl/ecmcGrblWrap.h +++ b/ecmc_plugin_grbl/ecmcGrblWrap.h @@ -58,6 +58,15 @@ int setReset(int reset); */ int getBusy(); +/** \brief get grbl g-code parser busy\n + */ +int getParserBusy(); + +/** \brief get grbl g-code row number\n + */ +int getCodeRowNum(); + + // Delete object void deleteGrbl(); diff --git a/ecmc_plugin_grbl/ecmcPluginGrbl.c b/ecmc_plugin_grbl/ecmcPluginGrbl.c index 4238649..fd20d39 100644 --- a/ecmc_plugin_grbl/ecmcPluginGrbl.c +++ b/ecmc_plugin_grbl/ecmcPluginGrbl.c @@ -119,12 +119,21 @@ double grbl_mc_reset(double halt) { return setReset((int)halt); } - // Plc function for reset grbl double grbl_get_busy() { return getBusy(); } +// Plc function for reset grbl +double grbl_get_parser_busy() { + return getParserBusy(); +} + +// Plc function for reset grbl +double grbl_get_code_row_num() { + return getCodeRowNum(); +} + // Register data for plugin so ecmc know what to use struct ecmcPluginData pluginDataDef = { // Allways use ECMC_PLUG_VERSION_MAGIC @@ -248,11 +257,11 @@ struct ecmcPluginData pluginDataDef = { .funcGenericObj = NULL, }, .funcs[4] = - { /*----can_connect----*/ + { /*----grbl_get_busy----*/ // Function name (this is the name you use in ecmc plc-code) .funcName = "grbl_get_busy", // Function description - .funcDesc = "double grbl_get_busy() : Get grbl system busy", + .funcDesc = "double grbl_get_busy() : Get grbl system busy (still executing motion code)", /** * 7 different prototypes allowed (only doubles since reg in plc). * Only funcArg${argCount} func shall be assigned the rest set to NULL. @@ -270,8 +279,53 @@ struct ecmcPluginData pluginDataDef = { .funcArg10 = NULL, .funcGenericObj = NULL, }, - - .funcs[5] = {0}, // last element set all to zero.. + .funcs[5] = + { /*----grbl_get_parser_busy----*/ + // Function name (this is the name you use in ecmc plc-code) + .funcName = "grbl_get_parser_busy", + // Function description + .funcDesc = "double grbl_get_parser_busy() : Get g-code parser busy.", + /** + * 7 different prototypes allowed (only doubles since reg in plc). + * Only funcArg${argCount} func shall be assigned the rest set to NULL. + **/ + .funcArg0 = grbl_get_parser_busy, + .funcArg1 = NULL, + .funcArg2 = NULL, + .funcArg3 = NULL, + .funcArg4 = NULL, + .funcArg5 = NULL, + .funcArg6 = NULL, + .funcArg7 = NULL, + .funcArg8 = NULL, + .funcArg9 = NULL, + .funcArg10 = NULL, + .funcGenericObj = NULL, + }, + .funcs[6] = + { /*----grbl_get_code_row_num----*/ + // Function name (this is the name you use in ecmc plc-code) + .funcName = "grbl_get_code_row_num", + // Function description + .funcDesc = "double grbl_get_code_row_num() : Get g-code row number currently preparing for exe.", + /** + * 7 different prototypes allowed (only doubles since reg in plc). + * Only funcArg${argCount} func shall be assigned the rest set to NULL. + **/ + .funcArg0 = grbl_get_code_row_num, + .funcArg1 = NULL, + .funcArg2 = NULL, + .funcArg3 = NULL, + .funcArg4 = NULL, + .funcArg5 = NULL, + .funcArg6 = NULL, + .funcArg7 = NULL, + .funcArg8 = NULL, + .funcArg9 = NULL, + .funcArg10 = NULL, + .funcGenericObj = NULL, + }, + .funcs[7] = {0}, // last element set all to zero.. // PLC consts .consts[0] = {0}, // last element set all to zero.. };