Browse Source

Fix broken M100_dump_routine

Scott Lahteine 5 years ago
parent
commit
deff538909
2 changed files with 11 additions and 10 deletions
  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 View File

51
  * Also, there are two support functions that can be called from a developer's C code.
51
  * Also, there are two support functions that can be called from a developer's C code.
52
  *
52
  *
53
  *    uint16_t check_for_free_memory_corruption(PGM_P const free_memory_start);
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
  * Initial version by Roxy-3D
56
  * Initial version by Roxy-3D
57
  */
57
  */
151
     // Start and end the dump on a nice 16 byte boundary
151
     // Start and end the dump on a nice 16 byte boundary
152
     // (even though the values are not 16-byte aligned).
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
     // Dump command main loop
157
     // Dump command main loop
158
     while (start_free_memory < end_free_memory) {
158
     while (start_free_memory < end_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
     serialprintPGM(title);
181
     serialprintPGM(title);
182
     SERIAL_EOL();
182
     SERIAL_EOL();
183
     //
183
     //
184
     // Round the start and end locations to produce full lines of output
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
 #endif // M100_FREE_MEMORY_DUMPER
192
 #endif // M100_FREE_MEMORY_DUMPER
211
     //   idle();
212
     //   idle();
212
     serial_delay(20);
213
     serial_delay(20);
213
     #if ENABLED(M100_FREE_MEMORY_DUMPER)
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
     #endif
216
     #endif
216
   }
217
   }
217
 
218
 

+ 2
- 2
Marlin/src/gcode/gcode.cpp View File

209
 // Placeholders for non-migrated codes
209
 // Placeholders for non-migrated codes
210
 //
210
 //
211
 #if ENABLED(M100_FREE_MEMORY_WATCHER)
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
 #endif
213
 #endif
214
 
214
 
215
 /**
215
 /**
865
     SERIAL_ECHOLN(current_command);
865
     SERIAL_ECHOLN(current_command);
866
     #if ENABLED(M100_FREE_MEMORY_DUMPER)
866
     #if ENABLED(M100_FREE_MEMORY_DUMPER)
867
       SERIAL_ECHOPAIR("slot:", queue.index_r);
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
     #endif
869
     #endif
870
   }
870
   }
871
 
871
 

Loading…
Cancel
Save