Commit | Line | Data |
---|---|---|
58baeec1 MM |
1 | /* |
2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). | |
3 | Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | |
4 | Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. | |
cd011f58 AW |
6 | */ |
7 | ||
8 | ||
0325af12 | 9 | #include "SimpleShell.h" |
ba8da804 | 10 | #include "libs/Kernel.h" |
0325af12 AW |
11 | #include "libs/nuts_bolts.h" |
12 | #include "libs/utils.h" | |
423df6df | 13 | #include "libs/SerialMessage.h" |
838b33b4 | 14 | #include "libs/StreamOutput.h" |
3fceb8eb | 15 | #include "modules/robot/Conveyor.h" |
172d42d9 | 16 | #include "DirHandle.h" |
0f0b1656 | 17 | #include "mri.h" |
582559c6 | 18 | #include "version.h" |
8293d443 | 19 | #include "PublicDataRequest.h" |
4fed9ba1 | 20 | #include "AppendFileStream.h" |
618c9b0f | 21 | #include "FileStream.h" |
61134a65 JM |
22 | #include "checksumm.h" |
23 | #include "PublicData.h" | |
24 | #include "Gcode.h" | |
564cf1f0 | 25 | #include "Robot.h" |
40843ebc JM |
26 | #include "ToolManagerPublicAccess.h" |
27 | #include "GcodeDispatch.h" | |
2577a122 | 28 | #include "BaseSolution.h" |
586cc733 | 29 | #include "StepperMotor.h" |
3e54c9fc | 30 | #include "Configurator.h" |
61134a65 | 31 | |
40843ebc | 32 | #include "TemperatureControlPublicAccess.h" |
9339253b | 33 | #include "EndstopsPublicAccess.h" |
d4ee6ee2 | 34 | #include "NetworkPublicAccess.h" |
a200fc31 | 35 | #include "platform_memory.h" |
ae91dea4 | 36 | #include "SwitchPublicAccess.h" |
3704585b | 37 | #include "SDFAT.h" |
1f8dab1a | 38 | #include "Thermistor.h" |
d55d551b | 39 | #include "md5.h" |
1aa3d42f | 40 | #include "utils.h" |
47339e4a | 41 | |
61134a65 JM |
42 | #include "system_LPC17xx.h" |
43 | #include "LPC17xx.h" | |
44 | ||
23eb804b JM |
45 | #include "mbed.h" // for wait_ms() |
46 | ||
6187a020 JM |
47 | extern unsigned int g_maximumHeapAddress; |
48 | ||
ecc610a4 JM |
49 | #include <malloc.h> |
50 | #include <mri.h> | |
51 | #include <stdio.h> | |
52 | #include <stdint.h> | |
53 | ||
54 | extern "C" uint32_t __end__; | |
55 | extern "C" uint32_t __malloc_free_list; | |
56 | extern "C" uint32_t _sbrk(int size); | |
57 | ||
9e403697 | 58 | // command lookup table |
7e81f138 JM |
59 | const SimpleShell::ptentry_t SimpleShell::commands_table[] = { |
60 | {"ls", SimpleShell::ls_command}, | |
61 | {"cd", SimpleShell::cd_command}, | |
62 | {"pwd", SimpleShell::pwd_command}, | |
63 | {"cat", SimpleShell::cat_command}, | |
64 | {"rm", SimpleShell::rm_command}, | |
6d877d9b JM |
65 | {"mv", SimpleShell::mv_command}, |
66 | {"upload", SimpleShell::upload_command}, | |
7e81f138 JM |
67 | {"reset", SimpleShell::reset_command}, |
68 | {"dfu", SimpleShell::dfu_command}, | |
69 | {"break", SimpleShell::break_command}, | |
70 | {"help", SimpleShell::help_command}, | |
71 | {"?", SimpleShell::help_command}, | |
72 | {"version", SimpleShell::version_command}, | |
73 | {"mem", SimpleShell::mem_command}, | |
74 | {"get", SimpleShell::get_command}, | |
75 | {"set_temp", SimpleShell::set_temp_command}, | |
ae91dea4 | 76 | {"switch", SimpleShell::switch_command}, |
7e81f138 JM |
77 | {"net", SimpleShell::net_command}, |
78 | {"load", SimpleShell::load_command}, | |
79 | {"save", SimpleShell::save_command}, | |
6d877d9b | 80 | {"remount", SimpleShell::remount_command}, |
1f8dab1a | 81 | {"calc_thermistor", SimpleShell::calc_thermistor_command}, |
4c8f5447 | 82 | {"thermistors", SimpleShell::print_thermistors_command}, |
d55d551b | 83 | {"md5sum", SimpleShell::md5sum_command}, |
9e403697 JM |
84 | |
85 | // unknown command | |
7e81f138 | 86 | {NULL, NULL} |
9e403697 | 87 | }; |
ecc610a4 | 88 | |
6d877d9b | 89 | int SimpleShell::reset_delay_secs = 0; |
7e81f138 | 90 | |
ecc610a4 | 91 | // Adam Greens heap walk from http://mbed.org/forum/mbed/topic/2701/?page=4#comment-22556 |
0c683b26 | 92 | static uint32_t heapWalk(StreamOutput *stream, bool verbose) |
ecc610a4 JM |
93 | { |
94 | uint32_t chunkNumber = 1; | |
95 | // The __end__ linker symbol points to the beginning of the heap. | |
96 | uint32_t chunkCurr = (uint32_t)&__end__; | |
97 | // __malloc_free_list is the head pointer to newlib-nano's link list of free chunks. | |
98 | uint32_t freeCurr = __malloc_free_list; | |
99 | // Calling _sbrk() with 0 reserves no more memory but it returns the current top of heap. | |
100 | uint32_t heapEnd = _sbrk(0); | |
101 | // accumulate totals | |
9e403697 JM |
102 | uint32_t freeSize = 0; |
103 | uint32_t usedSize = 0; | |
ecc610a4 JM |
104 | |
105 | stream->printf("Used Heap Size: %lu\n", heapEnd - chunkCurr); | |
106 | ||
107 | // Walk through the chunks until we hit the end of the heap. | |
9e403697 | 108 | while (chunkCurr < heapEnd) { |
ecc610a4 JM |
109 | // Assume the chunk is in use. Will update later. |
110 | int isChunkFree = 0; | |
111 | // The first 32-bit word in a chunk is the size of the allocation. newlib-nano over allocates by 8 bytes. | |
112 | // 4 bytes for this 32-bit chunk size and another 4 bytes to allow for 8 byte-alignment of returned pointer. | |
9e403697 | 113 | uint32_t chunkSize = *(uint32_t *)chunkCurr; |
ecc610a4 JM |
114 | // The start of the next chunk is right after the end of this one. |
115 | uint32_t chunkNext = chunkCurr + chunkSize; | |
116 | ||
117 | // The free list is sorted by address. | |
118 | // Check to see if we have found the next free chunk in the heap. | |
9e403697 | 119 | if (chunkCurr == freeCurr) { |
ecc610a4 JM |
120 | // Chunk is free so flag it as such. |
121 | isChunkFree = 1; | |
122 | // The second 32-bit word in a free chunk is a pointer to the next free chunk (again sorted by address). | |
9e403697 | 123 | freeCurr = *(uint32_t *)(freeCurr + 4); |
ecc610a4 JM |
124 | } |
125 | ||
126 | // Skip past the 32-bit size field in the chunk header. | |
127 | chunkCurr += 4; | |
128 | // 8-byte align the data pointer. | |
129 | chunkCurr = (chunkCurr + 7) & ~7; | |
130 | // newlib-nano over allocates by 8 bytes, 4 bytes for the 32-bit chunk size and another 4 bytes to allow for 8 | |
131 | // byte-alignment of the returned pointer. | |
132 | chunkSize -= 8; | |
9e403697 | 133 | if (verbose) |
ecc610a4 JM |
134 | stream->printf(" Chunk: %lu Address: 0x%08lX Size: %lu %s\n", chunkNumber, chunkCurr, chunkSize, isChunkFree ? "CHUNK FREE" : ""); |
135 | ||
9e403697 | 136 | if (isChunkFree) freeSize += chunkSize; |
ecc610a4 JM |
137 | else usedSize += chunkSize; |
138 | ||
139 | chunkCurr = chunkNext; | |
140 | chunkNumber++; | |
141 | } | |
142 | stream->printf("Allocated: %lu, Free: %lu\r\n", usedSize, freeSize); | |
0c683b26 | 143 | return freeSize; |
ecc610a4 JM |
144 | } |
145 | ||
146 | ||
9e403697 JM |
147 | void SimpleShell::on_module_loaded() |
148 | { | |
0325af12 | 149 | this->register_for_event(ON_CONSOLE_LINE_RECEIVED); |
48afc62a | 150 | this->register_for_event(ON_GCODE_RECEIVED); |
151 | this->register_for_event(ON_SECOND_TICK); | |
c4e56997 | 152 | |
7e81f138 | 153 | reset_delay_secs = 0; |
ead17727 JM |
154 | } |
155 | ||
9e403697 JM |
156 | void SimpleShell::on_second_tick(void *) |
157 | { | |
ead17727 | 158 | // we are timing out for the reset |
7e81f138 JM |
159 | if (reset_delay_secs > 0) { |
160 | if (--reset_delay_secs == 0) { | |
ead17727 JM |
161 | system_reset(false); |
162 | } | |
163 | } | |
0325af12 AW |
164 | } |
165 | ||
9e403697 JM |
166 | void SimpleShell::on_gcode_received(void *argument) |
167 | { | |
168 | Gcode *gcode = static_cast<Gcode *>(argument); | |
6d877d9b | 169 | string args = get_arguments(gcode->get_command()); |
c4e56997 JM |
170 | |
171 | if (gcode->has_m) { | |
172 | if (gcode->m == 20) { // list sd card | |
c4e56997 JM |
173 | gcode->stream->printf("Begin file list\r\n"); |
174 | ls_command("/sd", gcode->stream); | |
175 | gcode->stream->printf("End file list\r\n"); | |
d4ee6ee2 JM |
176 | |
177 | } else if (gcode->m == 30) { // remove file | |
01a8d21a JM |
178 | if(!args.empty() && !THEKERNEL->is_grbl_mode()) |
179 | rm_command("/sd/" + args, gcode->stream); | |
3a238fdc | 180 | } |
c4e56997 JM |
181 | } |
182 | } | |
183 | ||
7e81f138 | 184 | bool SimpleShell::parse_command(const char *cmd, string args, StreamOutput *stream) |
9e403697 | 185 | { |
7e81f138 JM |
186 | for (const ptentry_t *p = commands_table; p->command != NULL; ++p) { |
187 | if (strncasecmp(cmd, p->command, strlen(p->command)) == 0) { | |
188 | p->func(args, stream); | |
9e403697 JM |
189 | return true; |
190 | } | |
191 | } | |
192 | ||
193 | return false; | |
194 | } | |
195 | ||
0325af12 | 196 | // When a new line is received, check if it is a command, and if it is, act upon it |
9e403697 JM |
197 | void SimpleShell::on_console_line_received( void *argument ) |
198 | { | |
199 | SerialMessage new_message = *static_cast<SerialMessage *>(argument); | |
6c0193b3 | 200 | string possible_command = new_message.message; |
7f613782 | 201 | |
6c0193b3 JM |
202 | // ignore anything that is not lowercase or a $ as it is not a command |
203 | if(possible_command.size() == 0 || (!islower(possible_command[0]) && possible_command[0] != '$')) { | |
204 | return; | |
205 | } | |
7f613782 | 206 | |
6c0193b3 JM |
207 | // it is a grbl compatible command |
208 | if(possible_command[0] == '$' && possible_command.size() >= 2) { | |
209 | switch(possible_command[1]) { | |
210 | case 'G': | |
211 | // issue get state | |
212 | get_command("state", new_message.stream); | |
543c4b6d | 213 | new_message.stream->printf("ok\n"); |
6c0193b3 JM |
214 | break; |
215 | ||
216 | case 'X': | |
217 | THEKERNEL->call_event(ON_HALT, (void *)1); // clears on_halt | |
543c4b6d | 218 | new_message.stream->printf("[Caution: Unlocked]\nok\n"); |
6c0193b3 JM |
219 | break; |
220 | ||
221 | case '#': | |
222 | grblDP_command("", new_message.stream); | |
543c4b6d | 223 | new_message.stream->printf("ok\n"); |
6c0193b3 JM |
224 | break; |
225 | ||
226 | case 'H': | |
07186543 | 227 | if(THEKERNEL->is_grbl_mode()) { |
31c6c2c2 | 228 | THEKERNEL->call_event(ON_HALT, (void *)1); // clears on_halt |
8ad60a4c | 229 | // issue G28.2 which is force homing cycle |
53ece53b | 230 | Gcode gcode("G28.2", new_message.stream); |
6c0193b3 | 231 | THEKERNEL->call_event(ON_GCODE_RECEIVED, &gcode); |
07186543 JM |
232 | }else{ |
233 | new_message.stream->printf("error:only supported in GRBL mode\n"); | |
6c0193b3 JM |
234 | } |
235 | break; | |
0325af12 | 236 | |
6c0193b3 | 237 | default: |
07186543 | 238 | new_message.stream->printf("error:Invalid statement\n"); |
6c0193b3 JM |
239 | break; |
240 | } | |
241 | ||
242 | }else{ | |
6187a020 | 243 | |
6c0193b3 JM |
244 | //new_message.stream->printf("Received %s\r\n", possible_command.c_str()); |
245 | string cmd = shift_parameter(possible_command); | |
246 | ||
3e54c9fc JM |
247 | // Configurator commands |
248 | if (cmd == "config-get"){ | |
249 | THEKERNEL->configurator->config_get_command( possible_command, new_message.stream ); | |
250 | ||
251 | } else if (cmd == "config-set"){ | |
252 | THEKERNEL->configurator->config_set_command( possible_command, new_message.stream ); | |
253 | ||
254 | } else if (cmd == "config-load"){ | |
255 | THEKERNEL->configurator->config_load_command( possible_command, new_message.stream ); | |
256 | ||
257 | } else if (cmd == "play" || cmd == "progress" || cmd == "abort" || cmd == "suspend" || cmd == "resume") { | |
01a8d21a | 258 | // these are handled by Player module |
93f20a8c JM |
259 | |
260 | } else if (cmd == "ok") { | |
261 | // probably an echo so reply ok | |
262 | new_message.stream->printf("ok\n"); | |
3e54c9fc JM |
263 | |
264 | }else if(!parse_command(cmd.c_str(), possible_command, new_message.stream)) { | |
42bbc035 | 265 | new_message.stream->printf("error:Unsupported command - %s\n", cmd.c_str()); |
6c0193b3 JM |
266 | } |
267 | } | |
0325af12 AW |
268 | } |
269 | ||
0325af12 AW |
270 | // Act upon an ls command |
271 | // Convert the first parameter into an absolute path, then list the files in that path | |
9e403697 JM |
272 | void SimpleShell::ls_command( string parameters, StreamOutput *stream ) |
273 | { | |
3579deea JM |
274 | string path, opts; |
275 | while(!parameters.empty()) { | |
6d877d9b | 276 | string s = shift_parameter( parameters ); |
3579deea JM |
277 | if(s.front() == '-') { |
278 | opts.append(s); | |
279 | } else { | |
6d877d9b JM |
280 | path = s; |
281 | if(!parameters.empty()) { | |
3579deea JM |
282 | path.append(" "); |
283 | path.append(parameters); | |
284 | } | |
285 | break; | |
286 | } | |
287 | } | |
b557a801 | 288 | |
6d877d9b | 289 | path = absolute_from_relative(path); |
3579deea | 290 | |
9e403697 JM |
291 | DIR *d; |
292 | struct dirent *p; | |
3579deea | 293 | d = opendir(path.c_str()); |
9e403697 JM |
294 | if (d != NULL) { |
295 | while ((p = readdir(d)) != NULL) { | |
3579deea | 296 | stream->printf("%s", lc(string(p->d_name)).c_str()); |
6d877d9b | 297 | if(p->d_isdir) { |
3579deea | 298 | stream->printf("/"); |
6d877d9b | 299 | } else if(opts.find("-s", 0, 2) != string::npos) { |
3579deea JM |
300 | stream->printf(" %d", p->d_fsize); |
301 | } | |
302 | stream->printf("\r\n"); | |
9e403697 | 303 | } |
ed7c5844 | 304 | closedir(d); |
0325af12 | 305 | } else { |
3579deea | 306 | stream->printf("Could not open directory %s\r\n", path.c_str()); |
0325af12 AW |
307 | } |
308 | } | |
309 | ||
3704585b | 310 | extern SDFAT mounter; |
311 | ||
312 | void SimpleShell::remount_command( string parameters, StreamOutput *stream ) | |
313 | { | |
314 | mounter.remount(); | |
48afc62a | 315 | stream->printf("remounted\r\n"); |
12fb447a | 316 | } |
3704585b | 317 | |
9e403697 JM |
318 | // Delete a file |
319 | void SimpleShell::rm_command( string parameters, StreamOutput *stream ) | |
320 | { | |
6d877d9b | 321 | const char *fn = absolute_from_relative(shift_parameter( parameters )).c_str(); |
9e403697 JM |
322 | int s = remove(fn); |
323 | if (s != 0) stream->printf("Could not delete %s \r\n", fn); | |
324 | } | |
325 | ||
6d877d9b JM |
326 | // Rename a file |
327 | void SimpleShell::mv_command( string parameters, StreamOutput *stream ) | |
328 | { | |
329 | string from = absolute_from_relative(shift_parameter( parameters )); | |
a940483b | 330 | string to = absolute_from_relative(shift_parameter(parameters)); |
6d877d9b JM |
331 | int s = rename(from.c_str(), to.c_str()); |
332 | if (s != 0) stream->printf("Could not rename %s to %s\r\n", from.c_str(), to.c_str()); | |
333 | else stream->printf("renamed %s to %s\r\n", from.c_str(), to.c_str()); | |
334 | } | |
335 | ||
0325af12 | 336 | // Change current absolute path to provided path |
9e403697 JM |
337 | void SimpleShell::cd_command( string parameters, StreamOutput *stream ) |
338 | { | |
75f4581c | 339 | string folder = absolute_from_relative( parameters ); |
6bcd4886 | 340 | |
0325af12 | 341 | DIR *d; |
0325af12 | 342 | d = opendir(folder.c_str()); |
9e403697 | 343 | if (d == NULL) { |
58baeec1 | 344 | stream->printf("Could not open directory %s \r\n", folder.c_str() ); |
9e403697 | 345 | } else { |
75f4581c | 346 | THEKERNEL->current_path = folder; |
ed7c5844 | 347 | closedir(d); |
0325af12 AW |
348 | } |
349 | } | |
350 | ||
b7250484 | 351 | // Responds with the present working directory |
9e403697 JM |
352 | void SimpleShell::pwd_command( string parameters, StreamOutput *stream ) |
353 | { | |
75f4581c | 354 | stream->printf("%s\r\n", THEKERNEL->current_path.c_str()); |
b7250484 L |
355 | } |
356 | ||
0325af12 | 357 | // Output the contents of a file, first parameter is the filename, second is the limit ( in number of lines to output ) |
9e403697 JM |
358 | void SimpleShell::cat_command( string parameters, StreamOutput *stream ) |
359 | { | |
58baeec1 | 360 | // Get parameters ( filename and line limit ) |
75f4581c | 361 | string filename = absolute_from_relative(shift_parameter( parameters )); |
1f61f177 | 362 | string limit_parameter = shift_parameter( parameters ); |
0325af12 | 363 | int limit = -1; |
1f61f177 | 364 | int delay= 0; |
2ab3fca6 | 365 | bool send_eof= false; |
1f61f177 JM |
366 | if ( limit_parameter == "-d" ) { |
367 | string d= shift_parameter( parameters ); | |
9e403697 | 368 | char *e = NULL; |
1f61f177 | 369 | delay = strtol(d.c_str(), &e, 10); |
01e97c58 | 370 | if (e <= d.c_str()) { |
1f61f177 JM |
371 | delay = 0; |
372 | ||
01e97c58 JM |
373 | } else { |
374 | send_eof= true; // we need to terminate file send with an eof | |
375 | } | |
376 | ||
1f61f177 JM |
377 | }else if ( limit_parameter != "" ) { |
378 | char *e = NULL; | |
379 | limit = strtol(limit_parameter.c_str(), &e, 10); | |
380 | if (e <= limit_parameter.c_str()) | |
f7e6f459 MM |
381 | limit = -1; |
382 | } | |
58baeec1 | 383 | |
1f61f177 | 384 | // we have been asked to delay before cat, probably to allow time to issue upload command |
1aa3d42f JM |
385 | if(delay > 0) { |
386 | safe_delay(delay*1000); | |
1f61f177 JM |
387 | } |
388 | ||
58baeec1 | 389 | // Open file |
0325af12 | 390 | FILE *lp = fopen(filename.c_str(), "r"); |
9e403697 | 391 | if (lp == NULL) { |
58baeec1 MM |
392 | stream->printf("File not found: %s\r\n", filename.c_str()); |
393 | return; | |
9ed670c5 | 394 | } |
0325af12 AW |
395 | string buffer; |
396 | int c; | |
58baeec1 | 397 | int newlines = 0; |
6d877d9b | 398 | int linecnt = 0; |
0325af12 | 399 | // Print each line of the file |
9e403697 | 400 | while ((c = fgetc (lp)) != EOF) { |
58baeec1 | 401 | buffer.append((char *)&c, 1); |
2ab3fca6 JM |
402 | if ( c == '\n' || ++linecnt > 80) { |
403 | if(c == '\n') newlines++; | |
d728799b | 404 | stream->puts(buffer.c_str()); |
58baeec1 | 405 | buffer.clear(); |
6d877d9b | 406 | if(linecnt > 80) linecnt = 0; |
6757ce1a JM |
407 | // we need to kick things or they die |
408 | THEKERNEL->call_event(ON_IDLE); | |
68b7afb4 | 409 | } |
9e403697 JM |
410 | if ( newlines == limit ) { |
411 | break; | |
412 | } | |
58baeec1 | 413 | }; |
0325af12 | 414 | fclose(lp); |
2ab3fca6 JM |
415 | |
416 | if(send_eof) { | |
417 | stream->puts("\032"); // ^Z terminates the upload | |
418 | } | |
6d877d9b JM |
419 | } |
420 | ||
421 | void SimpleShell::upload_command( string parameters, StreamOutput *stream ) | |
422 | { | |
423 | // this needs to be a hack. it needs to read direct from serial and not allow on_main_loop run until done | |
424 | // NOTE this will block all operation until the upload is complete, so do not do while printing | |
425 | if(!THEKERNEL->conveyor->is_queue_empty()) { | |
426 | stream->printf("upload not allowed while printing or busy\n"); | |
427 | return; | |
428 | } | |
429 | ||
430 | // open file to upload to | |
431 | string upload_filename = absolute_from_relative( parameters ); | |
432 | FILE *fd = fopen(upload_filename.c_str(), "w"); | |
433 | if(fd != NULL) { | |
434 | stream->printf("uploading to file: %s, send control-D or control-Z to finish\r\n", upload_filename.c_str()); | |
435 | } else { | |
436 | stream->printf("failed to open file: %s.\r\n", upload_filename.c_str()); | |
437 | return; | |
438 | } | |
0325af12 | 439 | |
6d877d9b JM |
440 | int cnt = 0; |
441 | bool uploading = true; | |
442 | while(uploading) { | |
443 | if(!stream->ready()) { | |
444 | // we need to kick things or they die | |
445 | THEKERNEL->call_event(ON_IDLE); | |
446 | continue; | |
447 | } | |
448 | ||
449 | char c = stream->_getc(); | |
450 | if( c == 4 || c == 26) { // ctrl-D or ctrl-Z | |
451 | uploading = false; | |
452 | // close file | |
453 | fclose(fd); | |
454 | stream->printf("uploaded %d bytes\n", cnt); | |
455 | return; | |
456 | ||
457 | } else { | |
458 | // write character to file | |
459 | cnt++; | |
460 | if(fputc(c, fd) != c) { | |
461 | // error writing to file | |
462 | stream->printf("error writing to file. ignoring all characters until EOF\r\n"); | |
463 | fclose(fd); | |
464 | fd = NULL; | |
465 | uploading= false; | |
466 | ||
467 | } else { | |
468 | if ((cnt%400) == 0) { | |
469 | // HACK ALERT to get around fwrite corruption close and re open for append | |
470 | fclose(fd); | |
471 | fd = fopen(upload_filename.c_str(), "a"); | |
6757ce1a JM |
472 | // we need to kick things or they die |
473 | THEKERNEL->call_event(ON_IDLE); | |
6d877d9b JM |
474 | } |
475 | } | |
476 | } | |
477 | } | |
478 | // we got an error so ignore everything until EOF | |
479 | char c; | |
480 | do { | |
481 | if(stream->ready()) { | |
482 | c= stream->_getc(); | |
483 | }else{ | |
484 | THEKERNEL->call_event(ON_IDLE); | |
485 | c= 0; | |
486 | } | |
487 | } while(c != 4 && c != 26); | |
0325af12 AW |
488 | } |
489 | ||
618c9b0f JM |
490 | // loads the specified config-override file |
491 | void SimpleShell::load_command( string parameters, StreamOutput *stream ) | |
492 | { | |
493 | // Get parameters ( filename ) | |
75f4581c | 494 | string filename = absolute_from_relative(parameters); |
618c9b0f JM |
495 | if(filename == "/") { |
496 | filename = THEKERNEL->config_override_filename(); | |
497 | } | |
498 | ||
6d877d9b | 499 | FILE *fp = fopen(filename.c_str(), "r"); |
618c9b0f JM |
500 | if(fp != NULL) { |
501 | char buf[132]; | |
502 | stream->printf("Loading config override file: %s...\n", filename.c_str()); | |
503 | while(fgets(buf, sizeof buf, fp) != NULL) { | |
504 | stream->printf(" %s", buf); | |
505 | if(buf[0] == ';') continue; // skip the comments | |
c0b50fa8 JM |
506 | // NOTE only Gcodes and Mcodes can be in the config-override |
507 | Gcode *gcode = new Gcode(buf, &StreamOutput::NullStream); | |
508 | THEKERNEL->call_event(ON_GCODE_RECEIVED, gcode); | |
509 | delete gcode; | |
510 | THEKERNEL->call_event(ON_IDLE); | |
618c9b0f JM |
511 | } |
512 | stream->printf("config override file executed\n"); | |
513 | fclose(fp); | |
514 | ||
6d877d9b | 515 | } else { |
618c9b0f JM |
516 | stream->printf("File not found: %s\n", filename.c_str()); |
517 | } | |
518 | } | |
519 | ||
520 | // saves the specified config-override file | |
521 | void SimpleShell::save_command( string parameters, StreamOutput *stream ) | |
522 | { | |
523 | // Get parameters ( filename ) | |
75f4581c | 524 | string filename = absolute_from_relative(parameters); |
618c9b0f JM |
525 | if(filename == "/") { |
526 | filename = THEKERNEL->config_override_filename(); | |
527 | } | |
528 | ||
23eb804b JM |
529 | THEKERNEL->conveyor->wait_for_empty_queue(); //just to be safe as it can take a while to run |
530 | ||
06afe68b JM |
531 | //remove(filename.c_str()); // seems to cause a hang every now and then |
532 | { | |
533 | FileStream fs(filename.c_str()); | |
534 | fs.printf("; DO NOT EDIT THIS FILE\n"); | |
535 | // this also will truncate the existing file instead of deleting it | |
536 | } | |
537 | ||
23eb804b | 538 | // stream that appends to file |
4fed9ba1 JM |
539 | AppendFileStream *gs = new AppendFileStream(filename.c_str()); |
540 | // if(!gs->is_open()) { | |
541 | // stream->printf("Unable to open File %s for write\n", filename.c_str()); | |
542 | // return; | |
543 | // } | |
618c9b0f | 544 | |
7acfedab | 545 | __disable_irq(); |
618c9b0f JM |
546 | // issue a M500 which will store values in the file stream |
547 | Gcode *gcode = new Gcode("M500", gs); | |
548 | THEKERNEL->call_event(ON_GCODE_RECEIVED, gcode ); | |
549 | delete gs; | |
550 | delete gcode; | |
7acfedab | 551 | __enable_irq(); |
618c9b0f JM |
552 | |
553 | stream->printf("Settings Stored to %s\r\n", filename.c_str()); | |
554 | } | |
555 | ||
6187a020 | 556 | // show free memory |
9e403697 JM |
557 | void SimpleShell::mem_command( string parameters, StreamOutput *stream) |
558 | { | |
078f76e0 | 559 | bool verbose = shift_parameter( parameters ).find_first_of("Vv") != string::npos; |
9e403697 JM |
560 | unsigned long heap = (unsigned long)_sbrk(0); |
561 | unsigned long m = g_maximumHeapAddress - heap; | |
ecc610a4 JM |
562 | stream->printf("Unused Heap: %lu bytes\r\n", m); |
563 | ||
6d877d9b | 564 | uint32_t f = heapWalk(stream, verbose); |
0c683b26 | 565 | stream->printf("Total Free RAM: %lu bytes\r\n", m + f); |
a200fc31 | 566 | |
0c683b26 | 567 | stream->printf("Free AHB0: %lu, AHB1: %lu\r\n", AHB0.free(), AHB1.free()); |
6d877d9b | 568 | if (verbose) { |
1803076a MM |
569 | AHB0.debug(stream); |
570 | AHB1.debug(stream); | |
571 | } | |
6187a020 JM |
572 | } |
573 | ||
9e403697 JM |
574 | static uint32_t getDeviceType() |
575 | { | |
576 | #define IAP_LOCATION 0x1FFF1FF1 | |
01f35bcc JM |
577 | uint32_t command[1]; |
578 | uint32_t result[5]; | |
9e403697 | 579 | typedef void (*IAP)(uint32_t *, uint32_t *); |
01f35bcc JM |
580 | IAP iap = (IAP) IAP_LOCATION; |
581 | ||
582 | __disable_irq(); | |
583 | ||
584 | command[0] = 54; | |
585 | iap(command, result); | |
586 | ||
587 | __enable_irq(); | |
588 | ||
589 | return result[1]; | |
590 | } | |
591 | ||
d4ee6ee2 JM |
592 | // get network config |
593 | void SimpleShell::net_command( string parameters, StreamOutput *stream) | |
594 | { | |
595 | void *returned_data; | |
6d877d9b | 596 | bool ok = PublicData::get_value( network_checksum, get_ipconfig_checksum, &returned_data ); |
d4ee6ee2 | 597 | if(ok) { |
6d877d9b | 598 | char *str = (char *)returned_data; |
d4ee6ee2 JM |
599 | stream->printf("%s\r\n", str); |
600 | free(str); | |
601 | ||
6d877d9b | 602 | } else { |
d4ee6ee2 JM |
603 | stream->printf("No network detected\n"); |
604 | } | |
605 | } | |
606 | ||
582559c6 | 607 | // print out build version |
9e403697 JM |
608 | void SimpleShell::version_command( string parameters, StreamOutput *stream) |
609 | { | |
582559c6 | 610 | Version vers; |
9e403697 JM |
611 | uint32_t dev = getDeviceType(); |
612 | const char *mcu = (dev & 0x00100000) ? "LPC1769" : "LPC1768"; | |
01f35bcc | 613 | stream->printf("Build version: %s, Build date: %s, MCU: %s, System Clock: %ldMHz\r\n", vers.get_build(), vers.get_build_date(), mcu, SystemCoreClock / 1000000); |
582559c6 JM |
614 | } |
615 | ||
77983aa1 | 616 | // Reset the system |
9e403697 JM |
617 | void SimpleShell::reset_command( string parameters, StreamOutput *stream) |
618 | { | |
ead17727 | 619 | stream->printf("Smoothie out. Peace. Rebooting in 5 seconds...\r\n"); |
7e81f138 | 620 | reset_delay_secs = 5; // reboot in 5 seconds |
2742fca9 JM |
621 | } |
622 | ||
623 | // go into dfu boot mode | |
9e403697 JM |
624 | void SimpleShell::dfu_command( string parameters, StreamOutput *stream) |
625 | { | |
ed7c5844 JM |
626 | stream->printf("Entering boot mode...\r\n"); |
627 | system_reset(true); | |
77983aa1 L |
628 | } |
629 | ||
0f0b1656 | 630 | // Break out into the MRI debugging system |
9e403697 JM |
631 | void SimpleShell::break_command( string parameters, StreamOutput *stream) |
632 | { | |
0f0b1656 L |
633 | stream->printf("Entering MRI debug mode...\r\n"); |
634 | __debugbreak(); | |
635 | } | |
636 | ||
40843ebc JM |
637 | static int get_active_tool() |
638 | { | |
335957f5 | 639 | void *returned_data; |
40843ebc JM |
640 | bool ok = PublicData::get_value(tool_manager_checksum, get_active_tool_checksum, &returned_data); |
641 | if (ok) { | |
335957f5 JM |
642 | int active_tool= *static_cast<int *>(returned_data); |
643 | return active_tool; | |
40843ebc JM |
644 | } else { |
645 | return 0; | |
646 | } | |
647 | } | |
648 | ||
6c0193b3 JM |
649 | void SimpleShell::grblDP_command( string parameters, StreamOutput *stream) |
650 | { | |
651 | /* | |
652 | [G54:95.000,40.000,-23.600] | |
653 | [G55:0.000,0.000,0.000] | |
654 | [G56:0.000,0.000,0.000] | |
655 | [G57:0.000,0.000,0.000] | |
656 | [G58:0.000,0.000,0.000] | |
657 | [G59:0.000,0.000,0.000] | |
658 | [G28:0.000,0.000,0.000] | |
659 | [G30:0.000,0.000,0.000] | |
660 | [G92:0.000,0.000,0.000] | |
661 | [TLO:0.000] | |
662 | [PRB:0.000,0.000,0.000:0] | |
663 | */ | |
078f76e0 JM |
664 | |
665 | bool verbose = shift_parameter( parameters ).find_first_of("Vv") != string::npos; | |
666 | ||
6c0193b3 | 667 | std::vector<Robot::wcs_t> v= THEKERNEL->robot->get_wcs_state(); |
078f76e0 JM |
668 | if(verbose) { |
669 | char current_wcs= std::get<0>(v[0]); | |
670 | stream->printf("[current WCS: %s]\n", wcs2gcode(current_wcs).c_str()); | |
671 | } | |
672 | ||
6c0193b3 JM |
673 | int n= std::get<1>(v[0]); |
674 | for (int i = 1; i <= n; ++i) { | |
31c6c2c2 | 675 | stream->printf("[%s:%1.4f,%1.4f,%1.4f]\n", wcs2gcode(i-1).c_str(), std::get<0>(v[i]), std::get<1>(v[i]), std::get<2>(v[i])); |
6c0193b3 JM |
676 | } |
677 | ||
9339253b JM |
678 | float *rd; |
679 | PublicData::get_value( endstops_checksum, saved_position_checksum, &rd ); | |
31c6c2c2 JM |
680 | stream->printf("[G28:%1.4f,%1.4f,%1.4f]\n", rd[0], rd[1], rd[2]); |
681 | stream->printf("[G30:%1.4f,%1.4f,%1.4f]\n", 0.0F, 0.0F, 0.0F); // not implemented | |
9339253b | 682 | |
31c6c2c2 | 683 | stream->printf("[G92:%1.4f,%1.4f,%1.4f]\n", std::get<0>(v[n+1]), std::get<1>(v[n+1]), std::get<2>(v[n+1])); |
078f76e0 JM |
684 | if(verbose) { |
685 | stream->printf("[Tool Offset:%1.4f,%1.4f,%1.4f]\n", std::get<0>(v[n+2]), std::get<1>(v[n+2]), std::get<2>(v[n+2])); | |
686 | }else{ | |
687 | stream->printf("[TL0:%1.4f]\n", std::get<2>(v[n+2])); | |
688 | } | |
6c0193b3 | 689 | |
4440e123 JM |
690 | // this is the last probe position, updated when a probe completes, also stores the number of steps moved after a homing cycle |
691 | float px, py, pz; | |
692 | uint8_t ps; | |
693 | std::tie(px, py, pz, ps) = THEKERNEL->robot->get_last_probe_position(); | |
31c6c2c2 | 694 | stream->printf("[PRB:%1.4f,%1.4f,%1.4f:%d]\n", px, py, pz, ps); |
6c0193b3 JM |
695 | } |
696 | ||
9e403697 JM |
697 | void SimpleShell::get_command( string parameters, StreamOutput *stream) |
698 | { | |
7e81f138 | 699 | string what = shift_parameter( parameters ); |
c4e56997 | 700 | |
7e81f138 | 701 | if (what == "temp") { |
3bfb2639 | 702 | struct pad_temperature temp; |
9e403697 | 703 | string type = shift_parameter( parameters ); |
56a6c8c1 JM |
704 | if(type.empty()) { |
705 | // scan all temperature controls | |
706 | std::vector<struct pad_temperature> controllers; | |
707 | bool ok = PublicData::get_value(temperature_control_checksum, poll_controls_checksum, &controllers); | |
708 | if (ok) { | |
709 | for (auto &c : controllers) { | |
710 | stream->printf("%s (%d) temp: %f/%f @%d\r\n", c.designator.c_str(), c.id, c.current_temperature, c.target_temperature, c.pwm); | |
711 | } | |
b55cfff1 | 712 | |
56a6c8c1 JM |
713 | } else { |
714 | stream->printf("no heaters found\r\n"); | |
715 | } | |
716 | ||
717 | }else{ | |
718 | bool ok = PublicData::get_value( temperature_control_checksum, current_temperature_checksum, get_checksum(type), &temp ); | |
719 | ||
720 | if (ok) { | |
721 | stream->printf("%s temp: %f/%f @%d\r\n", type.c_str(), temp.current_temperature, temp.target_temperature, temp.pwm); | |
722 | } else { | |
723 | stream->printf("%s is not a known temperature device\r\n", type.c_str()); | |
724 | } | |
b55cfff1 | 725 | } |
c4e56997 | 726 | |
70021ec9 | 727 | } else if (what == "fk" || what == "ik") { |
2577a122 | 728 | string p= shift_parameter( parameters ); |
70021ec9 | 729 | bool move= false; |
8ff7a960 | 730 | if(p == "-m") { |
70021ec9 JM |
731 | move= true; |
732 | p= shift_parameter( parameters ); | |
733 | } | |
734 | ||
735 | std::vector<float> v= parse_number_list(p.c_str()); | |
586cc733 JM |
736 | if(p.empty() || v.size() < 1) { |
737 | stream->printf("error:usage: get [fk|ik] [-m] x[,y,z]\n"); | |
70021ec9 JM |
738 | return; |
739 | } | |
2577a122 | 740 | |
70021ec9 | 741 | float x= v[0]; |
586cc733 JM |
742 | float y= (v.size() > 1) ? v[1] : x; |
743 | float z= (v.size() > 2) ? v[2] : y; | |
70021ec9 JM |
744 | |
745 | if(what == "fk") { | |
8ff7a960 | 746 | // do forward kinematics on the given actuator position and display the cartesian coordinates |
70021ec9 JM |
747 | ActuatorCoordinates apos{x, y, z}; |
748 | float pos[3]; | |
749 | THEKERNEL->robot->arm_solution->actuator_to_cartesian(apos, pos); | |
586cc733 JM |
750 | stream->printf("cartesian= X %f, Y %f, Z %f, Steps= A %lu, B %lu, C %lu\n", |
751 | pos[0], pos[1], pos[2], | |
752 | lroundf(x*THEKERNEL->robot->actuators[0]->get_steps_per_mm()), | |
753 | lroundf(y*THEKERNEL->robot->actuators[1]->get_steps_per_mm()), | |
754 | lroundf(z*THEKERNEL->robot->actuators[2]->get_steps_per_mm())); | |
70021ec9 JM |
755 | x= pos[0]; |
756 | y= pos[1]; | |
757 | z= pos[2]; | |
8ff7a960 | 758 | |
70021ec9 | 759 | }else{ |
8ff7a960 | 760 | // do inverse kinematics on the given cartesian position and display the actuator coordinates |
70021ec9 JM |
761 | float pos[3]{x, y, z}; |
762 | ActuatorCoordinates apos; | |
763 | THEKERNEL->robot->arm_solution->cartesian_to_actuator(pos, apos); | |
764 | stream->printf("actuator= A %f, B %f, C %f\n", apos[0], apos[1], apos[2]); | |
765 | } | |
766 | ||
767 | if(move) { | |
8ff7a960 | 768 | // move to the calculated, or given, XYZ |
70021ec9 JM |
769 | char cmd[64]; |
770 | snprintf(cmd, sizeof(cmd), "G53 G0 X%f Y%f Z%f", x, y, z); | |
771 | struct SerialMessage message; | |
772 | message.message = cmd; | |
773 | message.stream = &(StreamOutput::NullStream); | |
774 | THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message ); | |
775 | THEKERNEL->conveyor->wait_for_empty_queue(); | |
776 | } | |
2577a122 JM |
777 | |
778 | } else if (what == "pos") { | |
e03f2747 JM |
779 | // convenience to call all the various M114 variants |
780 | char buf[64]; | |
781 | THEKERNEL->robot->print_position(0, buf, sizeof buf); stream->printf("last %s\n", buf); | |
782 | THEKERNEL->robot->print_position(1, buf, sizeof buf); stream->printf("realtime %s\n", buf); | |
783 | THEKERNEL->robot->print_position(2, buf, sizeof buf); stream->printf("%s\n", buf); | |
784 | THEKERNEL->robot->print_position(3, buf, sizeof buf); stream->printf("%s\n", buf); | |
785 | THEKERNEL->robot->print_position(4, buf, sizeof buf); stream->printf("%s\n", buf); | |
786 | THEKERNEL->robot->print_position(5, buf, sizeof buf); stream->printf("%s\n", buf); | |
34210908 JM |
787 | |
788 | } else if (what == "wcs") { | |
789 | // print the wcs state | |
078f76e0 | 790 | grblDP_command("-v", stream); |
40843ebc JM |
791 | |
792 | } else if (what == "state") { | |
6c0193b3 | 793 | // also $G |
40843ebc | 794 | // [G0 G54 G17 G21 G90 G94 M0 M5 M9 T0 F0.] |
31c6c2c2 | 795 | stream->printf("[G%d %s G%d G%d G%d G94 M0 M5 M9 T%d F%1.4f]\n", |
40843ebc JM |
796 | THEKERNEL->gcode_dispatch->get_modal_command(), |
797 | wcs2gcode(THEKERNEL->robot->get_current_wcs()).c_str(), | |
798 | THEKERNEL->robot->plane_axis_0 == X_AXIS && THEKERNEL->robot->plane_axis_1 == Y_AXIS && THEKERNEL->robot->plane_axis_2 == Z_AXIS ? 17 : | |
799 | THEKERNEL->robot->plane_axis_0 == X_AXIS && THEKERNEL->robot->plane_axis_1 == Z_AXIS && THEKERNEL->robot->plane_axis_2 == Y_AXIS ? 18 : | |
800 | THEKERNEL->robot->plane_axis_0 == Y_AXIS && THEKERNEL->robot->plane_axis_1 == Z_AXIS && THEKERNEL->robot->plane_axis_2 == X_AXIS ? 19 : 17, | |
801 | THEKERNEL->robot->inch_mode ? 20 : 21, | |
802 | THEKERNEL->robot->absolute_mode ? 90 : 91, | |
803 | get_active_tool(), | |
804 | THEKERNEL->robot->get_feed_rate()); | |
6c0193b3 | 805 | |
a9e8c04b JM |
806 | } else if (what == "status") { |
807 | // also ? on serial and usb | |
808 | stream->printf("%s\n", THEKERNEL->get_query_string().c_str()); | |
809 | ||
6c0193b3 | 810 | } else { |
07186543 | 811 | stream->printf("error:unknown option %s\n", what.c_str()); |
b55cfff1 | 812 | } |
8293d443 JM |
813 | } |
814 | ||
77047e76 | 815 | // used to test out the get public data events |
9e403697 JM |
816 | void SimpleShell::set_temp_command( string parameters, StreamOutput *stream) |
817 | { | |
818 | string type = shift_parameter( parameters ); | |
819 | string temp = shift_parameter( parameters ); | |
04211969 | 820 | float t = temp.empty() ? 0.0 : strtof(temp.c_str(), NULL); |
75e6428d | 821 | bool ok = PublicData::set_value( temperature_control_checksum, get_checksum(type), &t ); |
991d98cc | 822 | |
9e403697 | 823 | if (ok) { |
991d98cc | 824 | stream->printf("%s temp set to: %3.1f\r\n", type.c_str(), t); |
9e403697 | 825 | } else { |
991d98cc JM |
826 | stream->printf("%s is not a known temperature device\r\n", type.c_str()); |
827 | } | |
77047e76 JM |
828 | } |
829 | ||
4c8f5447 JM |
830 | void SimpleShell::print_thermistors_command( string parameters, StreamOutput *stream) |
831 | { | |
832 | Thermistor::print_predefined_thermistors(stream); | |
833 | } | |
834 | ||
1f8dab1a JM |
835 | void SimpleShell::calc_thermistor_command( string parameters, StreamOutput *stream) |
836 | { | |
bbb839c1 JM |
837 | string s = shift_parameter( parameters ); |
838 | int saveto= -1; | |
839 | // see if we have -sn as first argument | |
840 | if(s.find("-s", 0, 2) != string::npos) { | |
841 | // save the results to thermistor n | |
842 | saveto= strtol(s.substr(2).c_str(), nullptr, 10); | |
843 | }else{ | |
844 | parameters= s; | |
845 | } | |
846 | ||
1f8dab1a JM |
847 | std::vector<float> trl= parse_number_list(parameters.c_str()); |
848 | if(trl.size() == 6) { | |
849 | // calculate the coefficients | |
850 | float c1, c2, c3; | |
851 | std::tie(c1, c2, c3) = Thermistor::calculate_steinhart_hart_coefficients(trl[0], trl[1], trl[2], trl[3], trl[4], trl[5]); | |
852 | stream->printf("Steinhart Hart coefficients: I%1.18f J%1.18f K%1.18f\n", c1, c2, c3); | |
bbb839c1 JM |
853 | if(saveto == -1) { |
854 | stream->printf(" Paste the above in the M305 S0 command, then save with M500\n"); | |
855 | }else{ | |
856 | char buf[80]; | |
857 | int n = snprintf(buf, sizeof(buf), "M305 S%d I%1.18f J%1.18f K%1.18f", saveto, c1, c2, c3); | |
858 | string g(buf, n); | |
859 | Gcode gcode(g, &(StreamOutput::NullStream)); | |
860 | THEKERNEL->call_event(ON_GCODE_RECEIVED, &gcode ); | |
861 | stream->printf(" Setting Thermistor %d to those settings, save with M500\n", saveto); | |
862 | } | |
1f8dab1a JM |
863 | |
864 | }else{ | |
865 | // give help | |
866 | stream->printf("Usage: calc_thermistor T1,R1,T2,R2,T3,R3\n"); | |
867 | } | |
868 | } | |
869 | ||
ae91dea4 JM |
870 | // used to test out the get public data events for switch |
871 | void SimpleShell::switch_command( string parameters, StreamOutput *stream) | |
872 | { | |
873 | string type = shift_parameter( parameters ); | |
874 | string value = shift_parameter( parameters ); | |
6d877d9b | 875 | bool ok = false; |
ae91dea4 | 876 | if(value == "on" || value == "off") { |
6d877d9b | 877 | bool b = value == "on"; |
ae91dea4 | 878 | ok = PublicData::set_value( switch_checksum, get_checksum(type), state_checksum, &b ); |
6d877d9b | 879 | } else { |
ae91dea4 JM |
880 | float v = strtof(value.c_str(), NULL); |
881 | ok = PublicData::set_value( switch_checksum, get_checksum(type), value_checksum, &v ); | |
882 | } | |
883 | if (ok) { | |
884 | stream->printf("switch %s set to: %s\r\n", type.c_str(), value.c_str()); | |
885 | } else { | |
886 | stream->printf("%s is not a known switch device\r\n", type.c_str()); | |
887 | } | |
888 | } | |
889 | ||
d55d551b JM |
890 | void SimpleShell::md5sum_command( string parameters, StreamOutput *stream ) |
891 | { | |
892 | string filename = absolute_from_relative(parameters); | |
893 | ||
894 | // Open file | |
895 | FILE *lp = fopen(filename.c_str(), "r"); | |
896 | if (lp == NULL) { | |
897 | stream->printf("File not found: %s\r\n", filename.c_str()); | |
898 | return; | |
899 | } | |
900 | MD5 md5; | |
901 | uint8_t buf[64]; | |
902 | do { | |
903 | size_t n= fread(buf, 1, sizeof buf, lp); | |
904 | if(n > 0) md5.update(buf, n); | |
2a95b07e | 905 | THEKERNEL->call_event(ON_IDLE); |
d55d551b JM |
906 | } while(!feof(lp)); |
907 | ||
908 | stream->printf("%s %s\n", md5.finalize().hexdigest().c_str(), filename.c_str()); | |
909 | fclose(lp); | |
910 | } | |
911 | ||
912 | ||
913 | ||
9e403697 JM |
914 | void SimpleShell::help_command( string parameters, StreamOutput *stream ) |
915 | { | |
ed7c5844 | 916 | stream->printf("Commands:\r\n"); |
582559c6 | 917 | stream->printf("version\r\n"); |
ecc610a4 | 918 | stream->printf("mem [-v]\r\n"); |
3579deea | 919 | stream->printf("ls [-s] [folder]\r\n"); |
ed7c5844 | 920 | stream->printf("cd folder\r\n"); |
c4e56997 | 921 | stream->printf("pwd\r\n"); |
6c0193b3 | 922 | stream->printf("cat file [limit] [-d 10]\r\n"); |
9e403697 | 923 | stream->printf("rm file\r\n"); |
6d877d9b | 924 | stream->printf("mv file newfile\r\n"); |
12fb447a | 925 | stream->printf("remount\r\n"); |
4eb0e279 | 926 | stream->printf("play file [-v]\r\n"); |
ed7c5844 JM |
927 | stream->printf("progress - shows progress of current play\r\n"); |
928 | stream->printf("abort - abort currently playing file\r\n"); | |
c4e56997 JM |
929 | stream->printf("reset - reset smoothie\r\n"); |
930 | stream->printf("dfu - enter dfu boot loader\r\n"); | |
931 | stream->printf("break - break into debugger\r\n"); | |
ed7c5844 JM |
932 | stream->printf("config-get [<configuration_source>] <configuration_setting>\r\n"); |
933 | stream->printf("config-set [<configuration_source>] <configuration_setting> <value>\r\n"); | |
a9e8c04b | 934 | stream->printf("get [pos|wcs|state|status|fk|ik]\r\n"); |
5647f709 | 935 | stream->printf("get temp [bed|hotend]\r\n"); |
991d98cc | 936 | stream->printf("set_temp bed|hotend 185\r\n"); |
d4ee6ee2 | 937 | stream->printf("net\r\n"); |
618c9b0f JM |
938 | stream->printf("load [file] - loads a configuration override file from soecified name or config-override\r\n"); |
939 | stream->printf("save [file] - saves a configuration override file as specified filename or as config-override\r\n"); | |
bbb839c1 JM |
940 | stream->printf("upload filename - saves a stream of text to the named file\r\n"); |
941 | stream->printf("calc_thermistor [-s0] T1,R1,T2,R2,T3,R3 - calculate the Steinhart Hart coefficients for a thermistor\r\n"); | |
4c8f5447 | 942 | stream->printf("thermistors - print out the predefined thermistors\r\n"); |
d55d551b | 943 | stream->printf("md5sum file - prints md5 sum of the given file\r\n"); |
235a7435 JM |
944 | } |
945 |