Browse Source

Merge pull request #1973 from thinkyhead/m111_debug_level

M111 - Debug Level
Scott Lahteine 9 years ago
parent
commit
01bedd17c9
4 changed files with 55 additions and 22 deletions
  1. 12
    0
      Marlin/Marlin.h
  2. 39
    20
      Marlin/Marlin_main.cpp
  3. 2
    1
      Marlin/configurator/config/language.h
  4. 2
    1
      Marlin/language.h

+ 12
- 0
Marlin/Marlin.h View File

223
   void filrunout();
223
   void filrunout();
224
 #endif
224
 #endif
225
 
225
 
226
+/**
227
+ * Debug flags - not yet widely applied
228
+ */
229
+enum DebugFlags {
230
+  DEBUG_ECHO          = BIT(0),
231
+  DEBUG_INFO          = BIT(1),
232
+  DEBUG_ERRORS        = BIT(2),
233
+  DEBUG_DRYRUN        = BIT(3),
234
+  DEBUG_COMMUNICATION = BIT(4)
235
+};
236
+extern uint8_t marlin_debug_flags;
237
+
226
 extern bool Running;
238
 extern bool Running;
227
 inline bool IsRunning() { return  Running; }
239
 inline bool IsRunning() { return  Running; }
228
 inline bool IsStopped() { return !Running; }
240
 inline bool IsStopped() { return !Running; }

+ 39
- 20
Marlin/Marlin_main.cpp View File

138
  * M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating
138
  * M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating
139
  *        Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling
139
  *        Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling
140
  *        IF AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
140
  *        IF AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
141
+ * M111 - Set debug flags with S<mask>. See flag bits defined in Marlin.h.
141
  * M112 - Emergency stop
142
  * M112 - Emergency stop
142
  * M114 - Output current position to serial port
143
  * M114 - Output current position to serial port
143
  * M115 - Capabilities string
144
  * M115 - Capabilities string
218
 
219
 
219
 bool Running = true;
220
 bool Running = true;
220
 
221
 
222
+uint8_t marlin_debug_flags = DEBUG_INFO|DEBUG_ERRORS;
223
+
221
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
224
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
222
 float current_position[NUM_AXIS] = { 0.0 };
225
 float current_position[NUM_AXIS] = { 0.0 };
223
 static float destination[NUM_AXIS] = { 0.0 };
226
 static float destination[NUM_AXIS] = { 0.0 };
749
         gcode_N = (strtol(strchr_pointer + 1, NULL, 10));
752
         gcode_N = (strtol(strchr_pointer + 1, NULL, 10));
750
         if (gcode_N != gcode_LastN + 1 && strstr_P(command, PSTR("M110")) == NULL) {
753
         if (gcode_N != gcode_LastN + 1 && strstr_P(command, PSTR("M110")) == NULL) {
751
           SERIAL_ERROR_START;
754
           SERIAL_ERROR_START;
752
-          SERIAL_ERRORPGM(MSG_ERR_LINE_NO);
753
-          SERIAL_ERRORLN(gcode_LastN);
754
-          //Serial.println(gcode_N);
755
+          SERIAL_ERRORPGM(MSG_ERR_LINE_NO1);
756
+          SERIAL_ERROR(gcode_LastN + 1);
757
+          SERIAL_ERRORPGM(MSG_ERR_LINE_NO2);
758
+          SERIAL_ERRORLN(gcode_N);
755
           FlushSerialRequestResend();
759
           FlushSerialRequestResend();
756
           serial_count = 0;
760
           serial_count = 0;
757
           return;
761
           return;
3337
 #endif // HAS_TEMP_BED
3341
 #endif // HAS_TEMP_BED
3338
 
3342
 
3339
 /**
3343
 /**
3340
- * M112: Emergency Stop
3344
+ * M111: Set the debug level
3341
  */
3345
  */
3342
-inline void gcode_M112() {
3343
-  kill();
3346
+inline void gcode_M111() {
3347
+  marlin_debug_flags = code_seen('S') ? code_value_short() : DEBUG_INFO|DEBUG_ERRORS;
3344
 }
3348
 }
3345
 
3349
 
3350
+/**
3351
+ * M112: Emergency Stop
3352
+ */
3353
+inline void gcode_M112() { kill(); }
3354
+
3346
 #ifdef BARICUDA
3355
 #ifdef BARICUDA
3347
 
3356
 
3348
   #if HAS_HEATER_1
3357
   #if HAS_HEATER_1
4781
  * This is called from the main loop()
4790
  * This is called from the main loop()
4782
  */
4791
  */
4783
 void process_commands() {
4792
 void process_commands() {
4793
+
4794
+  if ((marlin_debug_flags & DEBUG_ECHO)) {
4795
+    SERIAL_ECHO_START;
4796
+    SERIAL_ECHOLN(command_queue[cmd_queue_index_r]);
4797
+  }
4798
+
4784
   if (code_seen('G')) {
4799
   if (code_seen('G')) {
4785
 
4800
 
4786
     int gCode = code_value_short();
4801
     int gCode = code_value_short();
4919
         gcode_M104();
4934
         gcode_M104();
4920
         break;
4935
         break;
4921
 
4936
 
4922
-      case 112: //  M112 Emergency Stop
4937
+      case 111: //  M111: Set debug level
4938
+        gcode_M111();
4939
+        break;
4940
+
4941
+      case 112: //  M112: Emergency Stop
4923
         gcode_M112();
4942
         gcode_M112();
4924
         break;
4943
         break;
4925
 
4944
 
4926
-      case 140: // M140 Set bed temp
4945
+      case 140: // M140: Set bed temp
4927
         gcode_M140();
4946
         gcode_M140();
4928
         break;
4947
         break;
4929
 
4948
 
4930
-      case 105: // M105 Read current temperature
4949
+      case 105: // M105: Read current temperature
4931
         gcode_M105();
4950
         gcode_M105();
4932
         return;
4951
         return;
4933
         break;
4952
         break;
4934
 
4953
 
4935
-      case 109: // M109 Wait for temperature
4954
+      case 109: // M109: Wait for temperature
4936
         gcode_M109();
4955
         gcode_M109();
4937
         break;
4956
         break;
4938
 
4957
 
4939
       #if HAS_TEMP_BED
4958
       #if HAS_TEMP_BED
4940
-        case 190: // M190 - Wait for bed heater to reach target.
4959
+        case 190: // M190: Wait for bed heater to reach target
4941
           gcode_M190();
4960
           gcode_M190();
4942
           break;
4961
           break;
4943
       #endif // HAS_TEMP_BED
4962
       #endif // HAS_TEMP_BED
4944
 
4963
 
4945
       #if HAS_FAN
4964
       #if HAS_FAN
4946
-        case 106: //M106 Fan On
4965
+        case 106: // M106: Fan On
4947
           gcode_M106();
4966
           gcode_M106();
4948
           break;
4967
           break;
4949
-        case 107: //M107 Fan Off
4968
+        case 107: // M107: Fan Off
4950
           gcode_M107();
4969
           gcode_M107();
4951
           break;
4970
           break;
4952
       #endif // HAS_FAN
4971
       #endif // HAS_FAN
4954
       #ifdef BARICUDA
4973
       #ifdef BARICUDA
4955
         // PWM for HEATER_1_PIN
4974
         // PWM for HEATER_1_PIN
4956
         #if HAS_HEATER_1
4975
         #if HAS_HEATER_1
4957
-          case 126: // M126 valve open
4976
+          case 126: // M126: valve open
4958
             gcode_M126();
4977
             gcode_M126();
4959
             break;
4978
             break;
4960
-          case 127: // M127 valve closed
4979
+          case 127: // M127: valve closed
4961
             gcode_M127();
4980
             gcode_M127();
4962
             break;
4981
             break;
4963
         #endif // HAS_HEATER_1
4982
         #endif // HAS_HEATER_1
4964
 
4983
 
4965
         // PWM for HEATER_2_PIN
4984
         // PWM for HEATER_2_PIN
4966
         #if HAS_HEATER_2
4985
         #if HAS_HEATER_2
4967
-          case 128: // M128 valve open
4986
+          case 128: // M128: valve open
4968
             gcode_M128();
4987
             gcode_M128();
4969
             break;
4988
             break;
4970
-          case 129: // M129 valve closed
4989
+          case 129: // M129: valve closed
4971
             gcode_M129();
4990
             gcode_M129();
4972
             break;
4991
             break;
4973
         #endif // HAS_HEATER_2
4992
         #endif // HAS_HEATER_2
4975
 
4994
 
4976
       #if HAS_POWER_SWITCH
4995
       #if HAS_POWER_SWITCH
4977
 
4996
 
4978
-        case 80: // M80 - Turn on Power Supply
4997
+        case 80: // M80: Turn on Power Supply
4979
           gcode_M80();
4998
           gcode_M80();
4980
           break;
4999
           break;
4981
 
5000
 
4982
       #endif // HAS_POWER_SWITCH
5001
       #endif // HAS_POWER_SWITCH
4983
 
5002
 
4984
-      case 81: // M81 - Turn off Power, including Power Supply, if possible
5003
+      case 81: // M81: Turn off Power, including Power Supply, if possible
4985
         gcode_M81();
5004
         gcode_M81();
4986
         break;
5005
         break;
4987
 
5006
 
4991
       case 83:
5010
       case 83:
4992
         gcode_M83();
5011
         gcode_M83();
4993
         break;
5012
         break;
4994
-      case 18: //compatibility
5013
+      case 18: // (for compatibility)
4995
       case 84: // M84
5014
       case 84: // M84
4996
         gcode_M18_M84();
5015
         gcode_M18_M84();
4997
         break;
5016
         break;

+ 2
- 1
Marlin/configurator/config/language.h View File

122
 #define MSG_PLANNER_BUFFER_BYTES            "  PlannerBufferBytes: "
122
 #define MSG_PLANNER_BUFFER_BYTES            "  PlannerBufferBytes: "
123
 #define MSG_OK                              "ok"
123
 #define MSG_OK                              "ok"
124
 #define MSG_FILE_SAVED                      "Done saving file."
124
 #define MSG_FILE_SAVED                      "Done saving file."
125
-#define MSG_ERR_LINE_NO                     "Line Number is not Last Line Number+1, Last Line: "
125
+#define MSG_ERR_LINE_NO1                    "Line Number out of sequence. Expected: "
126
+#define MSG_ERR_LINE_NO2                    " Got: "
126
 #define MSG_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
127
 #define MSG_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
127
 #define MSG_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
128
 #define MSG_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
128
 #define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: "
129
 #define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: "

+ 2
- 1
Marlin/language.h View File

122
 #define MSG_PLANNER_BUFFER_BYTES            "  PlannerBufferBytes: "
122
 #define MSG_PLANNER_BUFFER_BYTES            "  PlannerBufferBytes: "
123
 #define MSG_OK                              "ok"
123
 #define MSG_OK                              "ok"
124
 #define MSG_FILE_SAVED                      "Done saving file."
124
 #define MSG_FILE_SAVED                      "Done saving file."
125
-#define MSG_ERR_LINE_NO                     "Line Number is not Last Line Number+1, Last Line: "
125
+#define MSG_ERR_LINE_NO1                    "Line Number out of sequence. Expected: "
126
+#define MSG_ERR_LINE_NO2                    " Got: "
126
 #define MSG_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
127
 #define MSG_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
127
 #define MSG_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
128
 #define MSG_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
128
 #define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: "
129
 #define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: "

Loading…
Cancel
Save