|
@ -72,7 +72,7 @@ char GCodeQueue::command_buffer[BUFSIZE][MAX_CMD_SIZE]; |
|
|
/*
|
|
|
/*
|
|
|
* The port that the command was received on |
|
|
* The port that the command was received on |
|
|
*/ |
|
|
*/ |
|
|
#if NUM_SERIAL > 1 |
|
|
#if HAS_MULTI_SERIAL |
|
|
int16_t GCodeQueue::port[BUFSIZE]; |
|
|
int16_t GCodeQueue::port[BUFSIZE]; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -119,14 +119,12 @@ void GCodeQueue::clear() { |
|
|
* Once a new command is in the ring buffer, call this to commit it |
|
|
* Once a new command is in the ring buffer, call this to commit it |
|
|
*/ |
|
|
*/ |
|
|
void GCodeQueue::_commit_command(bool say_ok |
|
|
void GCodeQueue::_commit_command(bool say_ok |
|
|
#if NUM_SERIAL > 1 |
|
|
#if HAS_MULTI_SERIAL |
|
|
, int16_t p/*=-1*/ |
|
|
, int16_t p/*=-1*/ |
|
|
#endif |
|
|
#endif |
|
|
) { |
|
|
) { |
|
|
send_ok[index_w] = say_ok; |
|
|
send_ok[index_w] = say_ok; |
|
|
#if NUM_SERIAL > 1 |
|
|
TERN_(HAS_MULTI_SERIAL, port[index_w] = p); |
|
|
port[index_w] = p; |
|
|
|
|
|
#endif |
|
|
|
|
|
TERN_(POWER_LOSS_RECOVERY, recovery.commit_sdpos(index_w)); |
|
|
TERN_(POWER_LOSS_RECOVERY, recovery.commit_sdpos(index_w)); |
|
|
if (++index_w >= BUFSIZE) index_w = 0; |
|
|
if (++index_w >= BUFSIZE) index_w = 0; |
|
|
length++; |
|
|
length++; |
|
@ -138,14 +136,14 @@ void GCodeQueue::_commit_command(bool say_ok |
|
|
* Return false for a full buffer, or if the 'command' is a comment. |
|
|
* Return false for a full buffer, or if the 'command' is a comment. |
|
|
*/ |
|
|
*/ |
|
|
bool GCodeQueue::_enqueue(const char* cmd, bool say_ok/*=false*/ |
|
|
bool GCodeQueue::_enqueue(const char* cmd, bool say_ok/*=false*/ |
|
|
#if NUM_SERIAL > 1 |
|
|
#if HAS_MULTI_SERIAL |
|
|
, int16_t pn/*=-1*/ |
|
|
, int16_t pn/*=-1*/ |
|
|
#endif |
|
|
#endif |
|
|
) { |
|
|
) { |
|
|
if (*cmd == ';' || length >= BUFSIZE) return false; |
|
|
if (*cmd == ';' || length >= BUFSIZE) return false; |
|
|
strcpy(command_buffer[index_w], cmd); |
|
|
strcpy(command_buffer[index_w], cmd); |
|
|
_commit_command(say_ok |
|
|
_commit_command(say_ok |
|
|
#if NUM_SERIAL > 1 |
|
|
#if HAS_MULTI_SERIAL |
|
|
, pn |
|
|
, pn |
|
|
#endif |
|
|
#endif |
|
|
); |
|
|
); |
|
@ -276,7 +274,7 @@ void GCodeQueue::enqueue_now_P(PGM_P const pgcode) { |
|
|
* B<int> Block queue space remaining |
|
|
* B<int> Block queue space remaining |
|
|
*/ |
|
|
*/ |
|
|
void GCodeQueue::ok_to_send() { |
|
|
void GCodeQueue::ok_to_send() { |
|
|
#if NUM_SERIAL > 1 |
|
|
#if HAS_MULTI_SERIAL |
|
|
const int16_t pn = command_port(); |
|
|
const int16_t pn = command_port(); |
|
|
if (pn < 0) return; |
|
|
if (pn < 0) return; |
|
|
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
|
|
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
|
@ -303,30 +301,24 @@ void GCodeQueue::ok_to_send() { |
|
|
*/ |
|
|
*/ |
|
|
void GCodeQueue::flush_and_request_resend() { |
|
|
void GCodeQueue::flush_and_request_resend() { |
|
|
const int16_t pn = command_port(); |
|
|
const int16_t pn = command_port(); |
|
|
#if NUM_SERIAL > 1 |
|
|
#if HAS_MULTI_SERIAL |
|
|
if (pn < 0) return; |
|
|
if (pn < 0) return; |
|
|
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
|
|
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
|
|
#endif |
|
|
#endif |
|
|
SERIAL_FLUSH(); |
|
|
SERIAL_FLUSH(); |
|
|
SERIAL_ECHOPGM(STR_RESEND); |
|
|
SERIAL_ECHOPGM(STR_RESEND); |
|
|
|
|
|
SERIAL_ECHOLN(last_N[pn] + 1); |
|
|
SERIAL_ECHOLN(last_N[pn] + 1); |
|
|
|
|
|
ok_to_send(); |
|
|
ok_to_send(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
inline bool serial_data_available() { |
|
|
inline bool serial_data_available() { |
|
|
return false |
|
|
return MYSERIAL0.available() || TERN0(HAS_MULTI_SERIAL, MYSERIAL1.available()); |
|
|
|| MYSERIAL0.available() |
|
|
|
|
|
#if NUM_SERIAL > 1 |
|
|
|
|
|
|| MYSERIAL1.available() |
|
|
|
|
|
#endif |
|
|
|
|
|
; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
inline int read_serial(const uint8_t index) { |
|
|
inline int read_serial(const uint8_t index) { |
|
|
switch (index) { |
|
|
switch (index) { |
|
|
case 0: return MYSERIAL0.read(); |
|
|
case 0: return MYSERIAL0.read(); |
|
|
#if NUM_SERIAL > 1 |
|
|
#if HAS_MULTI_SERIAL |
|
|
case 1: return MYSERIAL1.read(); |
|
|
case 1: return MYSERIAL1.read(); |
|
|
#endif |
|
|
#endif |
|
|
default: return -1; |
|
|
default: return -1; |
|
@ -538,7 +530,7 @@ void GCodeQueue::get_serial_commands() { |
|
|
|
|
|
|
|
|
// Add the command to the queue
|
|
|
// Add the command to the queue
|
|
|
_enqueue(serial_line_buffer[i], true |
|
|
_enqueue(serial_line_buffer[i], true |
|
|
#if NUM_SERIAL > 1 |
|
|
#if HAS_MULTI_SERIAL |
|
|
, i |
|
|
, i |
|
|
#endif |
|
|
#endif |
|
|
); |
|
|
); |
|
|