|
@@ -462,6 +462,7 @@ static bool send_ok[BUFSIZE];
|
462
|
462
|
* ***************************************************************************
|
463
|
463
|
*/
|
464
|
464
|
|
|
465
|
+void get_available_commands();
|
465
|
466
|
void process_next_command();
|
466
|
467
|
|
467
|
468
|
void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
|
|
@@ -804,7 +805,7 @@ void setup() {
|
804
|
805
|
* - Call LCD update
|
805
|
806
|
*/
|
806
|
807
|
void loop() {
|
807
|
|
- if (commands_in_queue < BUFSIZE) get_command();
|
|
808
|
+ if (commands_in_queue < BUFSIZE) get_available_commands();
|
808
|
809
|
|
809
|
810
|
#if ENABLED(SDSUPPORT)
|
810
|
811
|
card.checkautostart(false);
|
|
@@ -856,24 +857,16 @@ void gcode_line_error(const char* err, bool doFlush = true) {
|
856
|
857
|
serial_count = 0;
|
857
|
858
|
}
|
858
|
859
|
|
859
|
|
-/**
|
860
|
|
- * Add to the circular command queue the next command from:
|
861
|
|
- * - The command-injection queue (queued_commands_P)
|
862
|
|
- * - The active serial input (usually USB)
|
863
|
|
- * - The SD card file being actively printed
|
864
|
|
- */
|
865
|
|
-void get_command() {
|
866
|
|
-
|
|
860
|
+inline void get_serial_commands() {
|
867
|
861
|
static char serial_line_buffer[MAX_CMD_SIZE];
|
868
|
862
|
static boolean serial_comment_mode = false;
|
869
|
863
|
|
870
|
|
- if (drain_queued_commands_P()) return; // priority is given to non-serial commands
|
871
|
|
-
|
|
864
|
+ // If the command buffer is empty for too long,
|
|
865
|
+ // send "wait" to indicate Marlin is still waiting.
|
872
|
866
|
#if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
|
873
|
867
|
static millis_t last_command_time = 0;
|
874
|
868
|
millis_t ms = millis();
|
875
|
|
-
|
876
|
|
- if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > NO_TIMEOUTS) {
|
|
869
|
+ if (commands_in_queue == 0 && !MYSERIAL.available() && ms > last_command_time + NO_TIMEOUTS) {
|
877
|
870
|
SERIAL_ECHOLNPGM(MSG_WAIT);
|
878
|
871
|
last_command_time = ms;
|
879
|
872
|
}
|
|
@@ -988,9 +981,11 @@ void get_command() {
|
988
|
981
|
}
|
989
|
982
|
|
990
|
983
|
} // queue has space, serial has data
|
|
984
|
+}
|
991
|
985
|
|
992
|
|
- #if ENABLED(SDSUPPORT)
|
|
986
|
+#if ENABLED(SDSUPPORT)
|
993
|
987
|
|
|
988
|
+ inline void get_sdcard_commands() {
|
994
|
989
|
static bool stop_buffering = false,
|
995
|
990
|
sd_comment_mode = false;
|
996
|
991
|
|
|
@@ -1050,8 +1045,26 @@ void get_command() {
|
1050
|
1045
|
if (!sd_comment_mode) command_queue[cmd_queue_index_w][sd_count++] = sd_char;
|
1051
|
1046
|
}
|
1052
|
1047
|
}
|
|
1048
|
+ }
|
1053
|
1049
|
|
1054
|
|
- #endif // SDSUPPORT
|
|
1050
|
+#endif // SDSUPPORT
|
|
1051
|
+
|
|
1052
|
+/**
|
|
1053
|
+ * Add to the circular command queue the next command from:
|
|
1054
|
+ * - The command-injection queue (queued_commands_P)
|
|
1055
|
+ * - The active serial input (usually USB)
|
|
1056
|
+ * - The SD card file being actively printed
|
|
1057
|
+ */
|
|
1058
|
+void get_available_commands() {
|
|
1059
|
+
|
|
1060
|
+ // if any immediate commands remain, don't get other commands yet
|
|
1061
|
+ if (drain_queued_commands_P()) return;
|
|
1062
|
+
|
|
1063
|
+ get_serial_commands();
|
|
1064
|
+
|
|
1065
|
+ #if ENABLED(SDSUPPORT)
|
|
1066
|
+ get_sdcard_commands();
|
|
1067
|
+ #endif
|
1055
|
1068
|
}
|
1056
|
1069
|
|
1057
|
1070
|
bool code_has_value() {
|
|
@@ -7362,7 +7375,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
7362
|
7375
|
filrunout();
|
7363
|
7376
|
#endif
|
7364
|
7377
|
|
7365
|
|
- if (commands_in_queue < BUFSIZE) get_command();
|
|
7378
|
+ if (commands_in_queue < BUFSIZE) get_available_commands();
|
7366
|
7379
|
|
7367
|
7380
|
millis_t ms = millis();
|
7368
|
7381
|
|