Split get_command into units, rename to get_available_commands
This commit is contained in:
parent
545f7997ea
commit
0b8ef5eba6
@ -109,7 +109,6 @@ void serial_echopair_P(const char* s_P, float v);
|
|||||||
void serial_echopair_P(const char* s_P, double v);
|
void serial_echopair_P(const char* s_P, double v);
|
||||||
void serial_echopair_P(const char* s_P, unsigned long v);
|
void serial_echopair_P(const char* s_P, unsigned long v);
|
||||||
|
|
||||||
|
|
||||||
// Things to write to serial from Program memory. Saves 400 to 2k of RAM.
|
// Things to write to serial from Program memory. Saves 400 to 2k of RAM.
|
||||||
FORCE_INLINE void serialprintPGM(const char* str) {
|
FORCE_INLINE void serialprintPGM(const char* str) {
|
||||||
char ch;
|
char ch;
|
||||||
@ -119,8 +118,6 @@ FORCE_INLINE void serialprintPGM(const char* str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_command();
|
|
||||||
|
|
||||||
void idle(
|
void idle(
|
||||||
#if ENABLED(FILAMENTCHANGEENABLE)
|
#if ENABLED(FILAMENTCHANGEENABLE)
|
||||||
bool no_stepper_sleep=false // pass true to keep steppers from disabling on timeout
|
bool no_stepper_sleep=false // pass true to keep steppers from disabling on timeout
|
||||||
|
@ -462,6 +462,7 @@ static bool send_ok[BUFSIZE];
|
|||||||
* ***************************************************************************
|
* ***************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void get_available_commands();
|
||||||
void process_next_command();
|
void process_next_command();
|
||||||
|
|
||||||
void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
|
void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
|
||||||
@ -804,7 +805,7 @@ void setup() {
|
|||||||
* - Call LCD update
|
* - Call LCD update
|
||||||
*/
|
*/
|
||||||
void loop() {
|
void loop() {
|
||||||
if (commands_in_queue < BUFSIZE) get_command();
|
if (commands_in_queue < BUFSIZE) get_available_commands();
|
||||||
|
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
card.checkautostart(false);
|
card.checkautostart(false);
|
||||||
@ -856,24 +857,16 @@ void gcode_line_error(const char* err, bool doFlush = true) {
|
|||||||
serial_count = 0;
|
serial_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
inline void get_serial_commands() {
|
||||||
* Add to the circular command queue the next command from:
|
|
||||||
* - The command-injection queue (queued_commands_P)
|
|
||||||
* - The active serial input (usually USB)
|
|
||||||
* - The SD card file being actively printed
|
|
||||||
*/
|
|
||||||
void get_command() {
|
|
||||||
|
|
||||||
static char serial_line_buffer[MAX_CMD_SIZE];
|
static char serial_line_buffer[MAX_CMD_SIZE];
|
||||||
static boolean serial_comment_mode = false;
|
static boolean serial_comment_mode = false;
|
||||||
|
|
||||||
if (drain_queued_commands_P()) return; // priority is given to non-serial commands
|
// If the command buffer is empty for too long,
|
||||||
|
// send "wait" to indicate Marlin is still waiting.
|
||||||
#if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
|
#if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
|
||||||
static millis_t last_command_time = 0;
|
static millis_t last_command_time = 0;
|
||||||
millis_t ms = millis();
|
millis_t ms = millis();
|
||||||
|
if (commands_in_queue == 0 && !MYSERIAL.available() && ms > last_command_time + NO_TIMEOUTS) {
|
||||||
if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > NO_TIMEOUTS) {
|
|
||||||
SERIAL_ECHOLNPGM(MSG_WAIT);
|
SERIAL_ECHOLNPGM(MSG_WAIT);
|
||||||
last_command_time = ms;
|
last_command_time = ms;
|
||||||
}
|
}
|
||||||
@ -988,9 +981,11 @@ void get_command() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // queue has space, serial has data
|
} // queue has space, serial has data
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
|
|
||||||
|
inline void get_sdcard_commands() {
|
||||||
static bool stop_buffering = false,
|
static bool stop_buffering = false,
|
||||||
sd_comment_mode = false;
|
sd_comment_mode = false;
|
||||||
|
|
||||||
@ -1050,8 +1045,26 @@ void get_command() {
|
|||||||
if (!sd_comment_mode) command_queue[cmd_queue_index_w][sd_count++] = sd_char;
|
if (!sd_comment_mode) command_queue[cmd_queue_index_w][sd_count++] = sd_char;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SDSUPPORT
|
#endif // SDSUPPORT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add to the circular command queue the next command from:
|
||||||
|
* - The command-injection queue (queued_commands_P)
|
||||||
|
* - The active serial input (usually USB)
|
||||||
|
* - The SD card file being actively printed
|
||||||
|
*/
|
||||||
|
void get_available_commands() {
|
||||||
|
|
||||||
|
// if any immediate commands remain, don't get other commands yet
|
||||||
|
if (drain_queued_commands_P()) return;
|
||||||
|
|
||||||
|
get_serial_commands();
|
||||||
|
|
||||||
|
#if ENABLED(SDSUPPORT)
|
||||||
|
get_sdcard_commands();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool code_has_value() {
|
bool code_has_value() {
|
||||||
@ -7362,7 +7375,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
|
|||||||
filrunout();
|
filrunout();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (commands_in_queue < BUFSIZE) get_command();
|
if (commands_in_queue < BUFSIZE) get_available_commands();
|
||||||
|
|
||||||
millis_t ms = millis();
|
millis_t ms = millis();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user