|
@@ -491,23 +491,20 @@ extern "C" {
|
491
|
491
|
*/
|
492
|
492
|
static bool drain_queued_commands_P() {
|
493
|
493
|
if (queued_commands_P != NULL) {
|
494
|
|
- // Get the next gcode to run
|
495
|
494
|
size_t i = 0;
|
496
|
|
- char c;
|
497
|
|
- while ((c = queued_commands_P[i++]) && c != '\n') { };
|
498
|
|
- if (i > 1) {
|
499
|
|
- char cmd[i];
|
500
|
|
- strncpy_P(cmd, queued_commands_P, i - 1);
|
501
|
|
- cmd[i - 1] = '\0';
|
502
|
|
- if (enqueue_and_echo_command(cmd)) { // buffer was not full (else we will retry later)
|
503
|
|
- if (c)
|
504
|
|
- queued_commands_P += i; // move to next command
|
505
|
|
- else
|
506
|
|
- queued_commands_P = NULL; // no more commands in the sequence
|
507
|
|
- }
|
|
495
|
+ char c, cmd[30];
|
|
496
|
+ strncpy_P(cmd, queued_commands_P, sizeof(cmd) - 1);
|
|
497
|
+ cmd[sizeof(cmd) - 1] = '\0';
|
|
498
|
+ while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command
|
|
499
|
+ cmd[i] = '\0';
|
|
500
|
+ if (enqueue_and_echo_command(cmd)) { // success?
|
|
501
|
+ if (c) // newline char?
|
|
502
|
+ queued_commands_P += i + 1; // advance to the next command
|
|
503
|
+ else
|
|
504
|
+ queued_commands_P = NULL; // nul char? no more commands
|
508
|
505
|
}
|
509
|
506
|
}
|
510
|
|
- return (queued_commands_P != NULL); // any more left to add?
|
|
507
|
+ return (queued_commands_P != NULL); // return whether any more remain
|
511
|
508
|
}
|
512
|
509
|
|
513
|
510
|
/**
|