|
@ -385,6 +385,8 @@ static int serial_count = 0; |
|
|
static boolean comment_mode = false; |
|
|
static boolean comment_mode = false; |
|
|
static char *strchr_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.)
|
|
|
static char *strchr_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.)
|
|
|
|
|
|
|
|
|
|
|
|
const char* queued_commands_P= NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */ |
|
|
|
|
|
|
|
|
const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
|
|
|
const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
|
|
|
|
|
|
|
|
|
// Inactivity shutdown
|
|
|
// Inactivity shutdown
|
|
@ -448,39 +450,64 @@ void serial_echopair_P(const char *s_P, unsigned long v) |
|
|
} |
|
|
} |
|
|
#endif //!SDSUPPORT
|
|
|
#endif //!SDSUPPORT
|
|
|
|
|
|
|
|
|
//adds an command to the main command buffer
|
|
|
//Injects the next command from the pending sequence of commands, when possible
|
|
|
//thats really done in a non-safe way.
|
|
|
//Return false if and only if no command was pending
|
|
|
//needs overworking someday
|
|
|
static bool drain_queued_commands_P() |
|
|
void enquecommand(const char *cmd) |
|
|
|
|
|
{ |
|
|
{ |
|
|
if(buflen < BUFSIZE) |
|
|
char cmd[30]; |
|
|
{ |
|
|
if(!queued_commands_P) |
|
|
//this is dangerous if a mixing of serial and this happens
|
|
|
return false; |
|
|
strcpy(&(cmdbuffer[bufindw][0]),cmd); |
|
|
// Get the next 30 chars from the sequence of gcodes to run
|
|
|
SERIAL_ECHO_START; |
|
|
strncpy_P(cmd, queued_commands_P, sizeof(cmd)-1); |
|
|
SERIAL_ECHOPGM(MSG_Enqueing); |
|
|
cmd[sizeof(cmd)-1]= 0; |
|
|
SERIAL_ECHO(cmdbuffer[bufindw]); |
|
|
// Look for the end of line, or the end of sequence
|
|
|
SERIAL_ECHOLNPGM("\""); |
|
|
size_t i= 0; |
|
|
bufindw= (bufindw + 1)%BUFSIZE; |
|
|
char c; |
|
|
buflen += 1; |
|
|
while( (c= cmd[i]) && c!='\n' ) |
|
|
|
|
|
++i; // look for the end of this gcode command
|
|
|
|
|
|
cmd[i]= 0; |
|
|
|
|
|
if(enquecommand(cmd)) // buffer was not full (else we will retry later)
|
|
|
|
|
|
{ |
|
|
|
|
|
if(c) |
|
|
|
|
|
queued_commands_P+= i+1; // move to next command
|
|
|
|
|
|
else |
|
|
|
|
|
queued_commands_P= NULL; // will have no more commands in the sequence
|
|
|
} |
|
|
} |
|
|
|
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void enquecommand_P(const char *cmd) |
|
|
//Record one or many commands to run from program memory.
|
|
|
|
|
|
//Aborts the current queue, if any.
|
|
|
|
|
|
//Note: drain_queued_commands_P() must be called repeatedly to drain the commands afterwards
|
|
|
|
|
|
void enquecommands_P(const char* pgcode) |
|
|
{ |
|
|
{ |
|
|
if(buflen < BUFSIZE) |
|
|
queued_commands_P= pgcode; |
|
|
{ |
|
|
drain_queued_commands_P(); // first command exectuted asap (when possible)
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//adds a single command to the main command buffer, from RAM
|
|
|
|
|
|
//that is really done in a non-safe way.
|
|
|
|
|
|
//needs overworking someday
|
|
|
|
|
|
//Returns false if it failed to do so
|
|
|
|
|
|
bool enquecommand(const char *cmd) |
|
|
|
|
|
{ |
|
|
|
|
|
if(*cmd==';') |
|
|
|
|
|
return false; |
|
|
|
|
|
if(buflen >= BUFSIZE) |
|
|
|
|
|
return false; |
|
|
//this is dangerous if a mixing of serial and this happens
|
|
|
//this is dangerous if a mixing of serial and this happens
|
|
|
strcpy_P(&(cmdbuffer[bufindw][0]),cmd); |
|
|
strcpy(&(cmdbuffer[bufindw][0]),cmd); |
|
|
SERIAL_ECHO_START; |
|
|
SERIAL_ECHO_START; |
|
|
SERIAL_ECHOPGM(MSG_Enqueing); |
|
|
SERIAL_ECHOPGM(MSG_Enqueing); |
|
|
SERIAL_ECHO(cmdbuffer[bufindw]); |
|
|
SERIAL_ECHO(cmdbuffer[bufindw]); |
|
|
SERIAL_ECHOLNPGM("\""); |
|
|
SERIAL_ECHOLNPGM("\""); |
|
|
bufindw= (bufindw + 1)%BUFSIZE; |
|
|
bufindw= (bufindw + 1)%BUFSIZE; |
|
|
buflen += 1; |
|
|
buflen += 1; |
|
|
} |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup_killpin() |
|
|
void setup_killpin() |
|
|
{ |
|
|
{ |
|
|
#if defined(KILL_PIN) && KILL_PIN > -1 |
|
|
#if defined(KILL_PIN) && KILL_PIN > -1 |
|
@ -684,6 +711,9 @@ void loop() |
|
|
|
|
|
|
|
|
void get_command() |
|
|
void get_command() |
|
|
{ |
|
|
{ |
|
|
|
|
|
if(drain_queued_commands_P()) // priority is given to non-serial commands
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
while( MYSERIAL.available() > 0 && buflen < BUFSIZE) { |
|
|
while( MYSERIAL.available() > 0 && buflen < BUFSIZE) { |
|
|
serial_char = MYSERIAL.read(); |
|
|
serial_char = MYSERIAL.read(); |
|
|
if(serial_char == '\n' || |
|
|
if(serial_char == '\n' || |
|
@ -4459,7 +4489,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s |
|
|
{ |
|
|
{ |
|
|
if (homeDebounceCount == 0) |
|
|
if (homeDebounceCount == 0) |
|
|
{ |
|
|
{ |
|
|
enquecommand_P((PSTR("G28"))); |
|
|
enquecommands_P((PSTR("G28"))); |
|
|
homeDebounceCount++; |
|
|
homeDebounceCount++; |
|
|
LCD_ALERTMESSAGEPGM(MSG_AUTO_HOME); |
|
|
LCD_ALERTMESSAGEPGM(MSG_AUTO_HOME); |
|
|
} |
|
|
} |
|
|