MCPcopy Create free account
hub / github.com/MarlinFirmware/Marlin / D

Method D

Marlin/src/gcode/gcode_d.cpp:50–294  ·  view source on GitHub ↗

* Dn: G-code for development and testing * * See https://reprap.org/wiki/G-code#D:_Debug_codes * * Put whatever else you need here to test ongoing development. */

Source from the content-addressed store, hash-verified

48 * Put whatever else you need here to test ongoing development.
49 */
50void GcodeSuite::D(const int16_t dcode) {
51 switch (dcode) {
52
53 case -1:
54 for (;;) { /* loop forever (watchdog reset) */ }
55
56 case 0:
57 hal.reboot();
58 break;
59
60 case 10:
61 kill(F("D10"), F("KILL TEST"), parser.seen_test('P'));
62 break;
63
64 case 1: {
65 // Zero or pattern-fill the EEPROM data
66 #if ENABLED(EEPROM_SETTINGS)
67 persistentStore.access_start();
68 size_t total = persistentStore.capacity();
69 int pos = 0;
70 const uint8_t value = 0x0;
71 while (total--) persistentStore.write_data(pos, &value, 1);
72 persistentStore.access_finish();
73 #else
74 settings.reset();
75 settings.save();
76 #endif
77 hal.reboot();
78 } break;
79
80 case 2: { // D2 Read / Write SRAM
81 #define SRAM_SIZE 8192
82 uint8_t *pointer = parser.hex_adr_val('A');
83 uint16_t len = parser.ushortval('C', 1);
84 uintptr_t addr = (uintptr_t)pointer;
85 NOMORE(addr, size_t(SRAM_SIZE - 1));
86 NOMORE(len, SRAM_SIZE - addr);
87 if (parser.seenval('X')) {
88 // Write the hex bytes after the X
89 uint16_t val = parser.hex_val('X');
90 while (len--) {
91 *pointer = val;
92 pointer++;
93 }
94 }
95 else {
96 while (len--) print_hex_byte(*(pointer++));
97 SERIAL_EOL();
98 }
99 } break;
100
101 #if ENABLED(EEPROM_SETTINGS)
102
103 case 3: { // D3 Read / Write EEPROM
104 uint8_t *pointer = parser.hex_adr_val('A');
105 uint16_t len = parser.ushortval('C', 1);
106 uintptr_t addr = (uintptr_t)pointer;
107 NOMORE(addr, size_t(persistentStore.capacity() - 1));

Callers

nothing calls this directly

Calls 15

killFunction · 0.85
NOMOREFunction · 0.85
print_hex_byteFunction · 0.85
SERIAL_EOLFunction · 0.85
gtnFunction · 0.85
delayFunction · 0.85
seen_testMethod · 0.80
hex_adr_valMethod · 0.80
ushortvalMethod · 0.80
seenvalMethod · 0.80
hex_valMethod · 0.80

Tested by

no test coverage detected