diff --git a/g2core/canonical_machine.h b/g2core/canonical_machine.h index 8ec1a5f1..a557d608 100644 --- a/g2core/canonical_machine.h +++ b/g2core/canonical_machine.h @@ -189,6 +189,8 @@ typedef enum { // these are in order to optimized CASE NEXT_ACTION_MARLIN_SET_FAN_SPEED, // M106 NEXT_ACTION_MARLIN_STOP_FAN, // M107 NEXT_ACTION_MARLIN_DISABLE_MOTORS, // M84 + NEXT_ACTION_MARLIN_RESET_LINE_NUMBERS, // M110 + NEXT_ACTION_MARLIN_REPORT_VERSION, // M115 NEXT_ACTION_MARLIN_DISPLAY_ON_SCREEN, // M117 #endif } cmNextAction; diff --git a/g2core/gcode_parser.cpp b/g2core/gcode_parser.cpp index 427fe985..eb65febb 100644 --- a/g2core/gcode_parser.cpp +++ b/g2core/gcode_parser.cpp @@ -206,7 +206,7 @@ stat_t gcode_parser(char *block) stat_t _verify_checksum(char *str) { #if MARLIN_COMPAT_ENABLED == true - if (true == cm.gmx.marlin_flavor) { + if (MARLIN_COMM_MODE == js.json_mode) { return marlin_verify_checksum(str); } #endif @@ -751,6 +751,11 @@ stat_t _parse_gcode_block(char *buf, char *active_comment) case 117: return STAT_OK; //SET_NON_MODAL (next_action, NEXT_ACTION_MARLIN_DISPLAY_ON_SCREEN); case 84: SET_NON_MODAL (next_action, NEXT_ACTION_MARLIN_DISABLE_MOTORS); + + case 110: SET_NON_MODAL (next_action, NEXT_ACTION_MARLIN_RESET_LINE_NUMBERS); + case 111: return STAT_OK; // ignore M111, and don't process contents of the line further + + case 115: SET_NON_MODAL (next_action, NEXT_ACTION_MARLIN_REPORT_VERSION); #endif // MARLIN_COMPAT_ENABLED default: status = STAT_MCODE_COMMAND_UNSUPPORTED; @@ -936,6 +941,16 @@ stat_t _execute_gcode_block(char *active_comment) // ignore for now return status; } + case NEXT_ACTION_MARLIN_REPORT_VERSION: { // M115 + js.json_mode = MARLIN_COMM_MODE; + ritorno(marlin_report_version()); + break; + } + case NEXT_ACTION_MARLIN_RESET_LINE_NUMBERS:{ // M110 + js.json_mode = MARLIN_COMM_MODE; + // TODO: care about line numbers + break; + } case NEXT_ACTION_DEFAULT: { if (cm.gmx.marlin_flavor) { // adjust G0 to almost always be the same as G1 @@ -953,7 +968,7 @@ stat_t _execute_gcode_block(char *active_comment) } break; } - } + } // switch (gv.next_action) #endif // MARLIN_COMPAT_ENABLED EXEC_FUNC(cm_set_spindle_speed, S_word); // S diff --git a/g2core/marlin_compatibility.cpp b/g2core/marlin_compatibility.cpp index f8b4a409..dd85ea7b 100644 --- a/g2core/marlin_compatibility.cpp +++ b/g2core/marlin_compatibility.cpp @@ -27,11 +27,12 @@ #include "gcode_parser.h" #include "canonical_machine.h" #include "util.h" -#include "xio.h" // for char definitions -#include "temperature.h" // for temperature controls +#include "xio.h" // for char definitions +#include "temperature.h" // for temperature controls #include "json_parser.h" #include "planner.h" -#include "MotateTimers.h" // for char definitions +#include "MotateTimers.h" // for char definitions +#include "MotateUniqueID.h" // for Motate::UUID // Structures used enum STK500 { @@ -388,7 +389,7 @@ stat_t marlin_callback() *str++ = 0; temperature_update_timeout.set(1000); // every second - + xio_writeline(buffer); } // temperature updates @@ -494,4 +495,65 @@ stat_t marlin_disable_motors() return (STAT_OK); } + + +/* + * marlin_report_version() - M115 + * + */ + +stat_t marlin_report_version() +{ + char buffer[128]; + char *str = buffer; + + str_concat(str, "ok FIRMWARE_NAME:Marlin g2core-"); + str_concat(str, G2CORE_FIRMWARE_BUILD_STRING); + *str = 0; + xio_writeline(buffer); + str = buffer; + *str = 0; + + str_concat(str, " SOURCE_CODE_URL:https://github.com/synthetos/g2"); + *str = 0; + xio_writeline(buffer); + str = buffer; *str = 0; + + str_concat(str, " PROTOCOL_VERSION:1.0"); + *str = 0; + xio_writeline(buffer); + str = buffer; *str = 0; + + str_concat(str, " MACHINE_TYPE:"); +#ifdef SETTINGS_FILE +#define settings_file_string1(s) #s +#define settings_file_string2(s) settings_file_string1(s) + str_concat(str, settings_file_string2(SETTINGS_FILE)); +#undef settings_file_string1 +#undef settings_file_string2 +#else + str_concat(str, ""); +#endif + *str = 0; + xio_writeline(buffer); + str = buffer; *str = 0; + + // TODO: make this configurable, based on the tool table + str_concat(str, " EXTRUDER_COUNT:1"); + *str = 0; + xio_writeline(buffer); + str = buffer; *str = 0; + + str_concat(str, " UUID:"); + const char *uuid = Motate::UUID; + strncpy(str, uuid, Motate::strlen(uuid)); + str += Motate::strlen(uuid); + str_concat(str, "\n"); + *str = 0; + xio_writeline(buffer); + str = buffer; *str = 0; + + return (STAT_OK); +} + #endif // MARLIN_COMPAT_ENABLED == true diff --git a/g2core/marlin_compatibility.h b/g2core/marlin_compatibility.h index 36a031a7..d1673ff0 100644 --- a/g2core/marlin_compatibility.h +++ b/g2core/marlin_compatibility.h @@ -48,4 +48,6 @@ stat_t cm_marlin_set_extruder_mode(const uint8_t mode); // M82, M82 stat_t marlin_set_fan_speed(const uint8_t fan, float speed); // M106, M107 stat_t marlin_disable_motors(); // M84 + +stat_t marlin_report_version(); // M115 #endif // End of include guard: MARLIN_COMPAT_H_ONCE