Procházet zdrojové kódy

Fix broken M100_dump_routine

Scott Lahteine před 4 roky
rodič
revize
deff538909
2 změnil soubory, kde provedl 11 přidání a 10 odebrání
  1. 9
    8
      Marlin/src/gcode/calibrate/M100.cpp
  2. 2
    2
      Marlin/src/gcode/gcode.cpp

+ 9
- 8
Marlin/src/gcode/calibrate/M100.cpp Zobrazit soubor

@@ -51,7 +51,7 @@
51 51
  * Also, there are two support functions that can be called from a developer's C code.
52 52
  *
53 53
  *    uint16_t check_for_free_memory_corruption(PGM_P const free_memory_start);
54
- *    void M100_dump_routine(PGM_P const title, char *start, char *end);
54
+ *    void M100_dump_routine(PGM_P const title, const char * const start, const char * const end);
55 55
  *
56 56
  * Initial version by Roxy-3D
57 57
  */
@@ -151,8 +151,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
151 151
     // Start and end the dump on a nice 16 byte boundary
152 152
     // (even though the values are not 16-byte aligned).
153 153
     //
154
-    start_free_memory = (char*)((ptr_int_t)((uint32_t)start_free_memory & 0xFFFFFFF0)); // Align to 16-byte boundary
155
-    end_free_memory  = (char*)((ptr_int_t)((uint32_t)end_free_memory  | 0x0000000F)); // Align end_free_memory to the 15th byte (at or above end_free_memory)
154
+    start_free_memory = (char*)(ptr_int_t(uint32_t(start_free_memory) & ~0xFUL)); // Align to 16-byte boundary
155
+    end_free_memory   = (char*)(ptr_int_t(uint32_t(end_free_memory)   |  0xFUL)); // Align end_free_memory to the 15th byte (at or above end_free_memory)
156 156
 
157 157
     // Dump command main loop
158 158
     while (start_free_memory < end_free_memory) {
@@ -177,15 +177,16 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
177 177
     }
178 178
   }
179 179
 
180
-  void M100_dump_routine(PGM_P const title, char *start, char *end) {
180
+  void M100_dump_routine(PGM_P const title, const char * const start, const char * const end) {
181 181
     serialprintPGM(title);
182 182
     SERIAL_EOL();
183 183
     //
184 184
     // Round the start and end locations to produce full lines of output
185 185
     //
186
-    start = (char*)((ptr_int_t)((uint32_t)start & 0xFFFFFFF0)); // Align to 16-byte boundary
187
-    end   = (char*)((ptr_int_t)((uint32_t)end   | 0x0000000F)); // Align end_free_memory to the 15th byte (at or above end_free_memory)
188
-    dump_free_memory(start, end);
186
+    dump_free_memory(
187
+      (char*)(ptr_int_t(uint32_t(start) & ~0xFUL)), // Align to 16-byte boundary
188
+      (char*)(ptr_int_t(uint32_t(end)   |  0xFUL))  // Align end_free_memory to the 15th byte (at or above end_free_memory)
189
+    );
189 190
   }
190 191
 
191 192
 #endif // M100_FREE_MEMORY_DUMPER
@@ -211,7 +212,7 @@ inline int check_for_free_memory_corruption(PGM_P const title) {
211 212
     //   idle();
212 213
     serial_delay(20);
213 214
     #if ENABLED(M100_FREE_MEMORY_DUMPER)
214
-      M100_dump_routine(PSTR("   Memory corruption detected with end_free_memory<Heap\n"), (char*)0x1B80, (char*)0x21FF);
215
+      M100_dump_routine(PSTR("   Memory corruption detected with end_free_memory<Heap\n"), (const char*)0x1B80, (const char*)0x21FF);
215 216
     #endif
216 217
   }
217 218
 

+ 2
- 2
Marlin/src/gcode/gcode.cpp Zobrazit soubor

@@ -209,7 +209,7 @@ void GcodeSuite::dwell(millis_t time) {
209 209
 // Placeholders for non-migrated codes
210 210
 //
211 211
 #if ENABLED(M100_FREE_MEMORY_WATCHER)
212
-  extern void M100_dump_routine(PGM_P const title, char *start, char *end);
212
+  extern void M100_dump_routine(PGM_P const title, const char * const start, const char * const end);
213 213
 #endif
214 214
 
215 215
 /**
@@ -865,7 +865,7 @@ void GcodeSuite::process_next_command() {
865 865
     SERIAL_ECHOLN(current_command);
866 866
     #if ENABLED(M100_FREE_MEMORY_DUMPER)
867 867
       SERIAL_ECHOPAIR("slot:", queue.index_r);
868
-      M100_dump_routine(PSTR("   Command Queue:"), queue.command_buffer, queue.command_buffer + sizeof(queue.command_buffer));
868
+      M100_dump_routine(PSTR("   Command Queue:"), &queue.command_buffer[0][0], &queue.command_buffer[BUFSIZE - 1][MAX_CMD_SIZE - 1]);
869 869
     #endif
870 870
   }
871 871
 

Loading…
Zrušit
Uložit