Parcourir la source

M111 - Debug Level

- Add `M111` as a standard option to set the debug level
- Implement `DEBUG_ECHO` in `process_commands`
- Other debug levels (e.g., `DEBUG_DRYRUN`) need more work
Scott Lahteine il y a 9 ans
Parent
révision
d43cc2dd5f
4 fichiers modifiés avec 55 ajouts et 22 suppressions
  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 Voir le fichier

@@ -223,6 +223,18 @@ void Stop();
223 223
   void filrunout();
224 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 238
 extern bool Running;
227 239
 inline bool IsRunning() { return  Running; }
228 240
 inline bool IsStopped() { return !Running; }

+ 39
- 20
Marlin/Marlin_main.cpp Voir le fichier

@@ -138,6 +138,7 @@
138 138
  * M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating
139 139
  *        Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling
140 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 142
  * M112 - Emergency stop
142 143
  * M114 - Output current position to serial port
143 144
  * M115 - Capabilities string
@@ -218,6 +219,8 @@
218 219
 
219 220
 bool Running = true;
220 221
 
222
+uint8_t marlin_debug_flags = DEBUG_INFO|DEBUG_ERRORS;
223
+
221 224
 static float feedrate = 1500.0, next_feedrate, saved_feedrate;
222 225
 float current_position[NUM_AXIS] = { 0.0 };
223 226
 static float destination[NUM_AXIS] = { 0.0 };
@@ -749,9 +752,10 @@ void get_command() {
749 752
         gcode_N = (strtol(strchr_pointer + 1, NULL, 10));
750 753
         if (gcode_N != gcode_LastN + 1 && strstr_P(command, PSTR("M110")) == NULL) {
751 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 759
           FlushSerialRequestResend();
756 760
           serial_count = 0;
757 761
           return;
@@ -3337,12 +3341,17 @@ inline void gcode_M109() {
3337 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 3355
 #ifdef BARICUDA
3347 3356
 
3348 3357
   #if HAS_HEATER_1
@@ -4781,6 +4790,12 @@ inline void gcode_T() {
4781 4790
  * This is called from the main loop()
4782 4791
  */
4783 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 4799
   if (code_seen('G')) {
4785 4800
 
4786 4801
     int gCode = code_value_short();
@@ -4919,34 +4934,38 @@ void process_commands() {
4919 4934
         gcode_M104();
4920 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 4942
         gcode_M112();
4924 4943
         break;
4925 4944
 
4926
-      case 140: // M140 Set bed temp
4945
+      case 140: // M140: Set bed temp
4927 4946
         gcode_M140();
4928 4947
         break;
4929 4948
 
4930
-      case 105: // M105 Read current temperature
4949
+      case 105: // M105: Read current temperature
4931 4950
         gcode_M105();
4932 4951
         return;
4933 4952
         break;
4934 4953
 
4935
-      case 109: // M109 Wait for temperature
4954
+      case 109: // M109: Wait for temperature
4936 4955
         gcode_M109();
4937 4956
         break;
4938 4957
 
4939 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 4960
           gcode_M190();
4942 4961
           break;
4943 4962
       #endif // HAS_TEMP_BED
4944 4963
 
4945 4964
       #if HAS_FAN
4946
-        case 106: //M106 Fan On
4965
+        case 106: // M106: Fan On
4947 4966
           gcode_M106();
4948 4967
           break;
4949
-        case 107: //M107 Fan Off
4968
+        case 107: // M107: Fan Off
4950 4969
           gcode_M107();
4951 4970
           break;
4952 4971
       #endif // HAS_FAN
@@ -4954,20 +4973,20 @@ void process_commands() {
4954 4973
       #ifdef BARICUDA
4955 4974
         // PWM for HEATER_1_PIN
4956 4975
         #if HAS_HEATER_1
4957
-          case 126: // M126 valve open
4976
+          case 126: // M126: valve open
4958 4977
             gcode_M126();
4959 4978
             break;
4960
-          case 127: // M127 valve closed
4979
+          case 127: // M127: valve closed
4961 4980
             gcode_M127();
4962 4981
             break;
4963 4982
         #endif // HAS_HEATER_1
4964 4983
 
4965 4984
         // PWM for HEATER_2_PIN
4966 4985
         #if HAS_HEATER_2
4967
-          case 128: // M128 valve open
4986
+          case 128: // M128: valve open
4968 4987
             gcode_M128();
4969 4988
             break;
4970
-          case 129: // M129 valve closed
4989
+          case 129: // M129: valve closed
4971 4990
             gcode_M129();
4972 4991
             break;
4973 4992
         #endif // HAS_HEATER_2
@@ -4975,13 +4994,13 @@ void process_commands() {
4975 4994
 
4976 4995
       #if HAS_POWER_SWITCH
4977 4996
 
4978
-        case 80: // M80 - Turn on Power Supply
4997
+        case 80: // M80: Turn on Power Supply
4979 4998
           gcode_M80();
4980 4999
           break;
4981 5000
 
4982 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 5004
         gcode_M81();
4986 5005
         break;
4987 5006
 
@@ -4991,7 +5010,7 @@ void process_commands() {
4991 5010
       case 83:
4992 5011
         gcode_M83();
4993 5012
         break;
4994
-      case 18: //compatibility
5013
+      case 18: // (for compatibility)
4995 5014
       case 84: // M84
4996 5015
         gcode_M18_M84();
4997 5016
         break;

+ 2
- 1
Marlin/configurator/config/language.h Voir le fichier

@@ -122,7 +122,8 @@
122 122
 #define MSG_PLANNER_BUFFER_BYTES            "  PlannerBufferBytes: "
123 123
 #define MSG_OK                              "ok"
124 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 127
 #define MSG_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
127 128
 #define MSG_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
128 129
 #define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: "

+ 2
- 1
Marlin/language.h Voir le fichier

@@ -122,7 +122,8 @@
122 122
 #define MSG_PLANNER_BUFFER_BYTES            "  PlannerBufferBytes: "
123 123
 #define MSG_OK                              "ok"
124 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 127
 #define MSG_ERR_CHECKSUM_MISMATCH           "checksum mismatch, Last Line: "
127 128
 #define MSG_ERR_NO_CHECKSUM                 "No Checksum with line number, Last Line: "
128 129
 #define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: "

Chargement…
Annuler
Enregistrer