G-code line number for each serial port (for TFTs) (#18165)
This commit is contained in:
parent
53cb2963dc
commit
7119596170
|
@ -27,5 +27,8 @@
|
|||
* M110: Set Current Line Number
|
||||
*/
|
||||
void GcodeSuite::M110() {
|
||||
if (parser.seenval('N')) queue.last_N = parser.value_long();
|
||||
|
||||
if (parser.seenval('N'))
|
||||
queue.last_N[queue.command_port()] = parser.value_long();
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ GCodeQueue queue;
|
|||
* sending commands to Marlin, and lines will be checked for sequentiality.
|
||||
* M110 N<int> sets the current line number.
|
||||
*/
|
||||
long gcode_N, GCodeQueue::last_N;
|
||||
long GCodeQueue::last_N[NUM_SERIAL];
|
||||
|
||||
/**
|
||||
* GCode Command Queue
|
||||
|
@ -277,7 +277,7 @@ void GCodeQueue::enqueue_now_P(PGM_P const pgcode) {
|
|||
*/
|
||||
void GCodeQueue::ok_to_send() {
|
||||
#if NUM_SERIAL > 1
|
||||
const int16_t pn = port[index_r];
|
||||
const int16_t pn = command_port();
|
||||
if (pn < 0) return;
|
||||
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
||||
#endif
|
||||
|
@ -302,14 +302,15 @@ void GCodeQueue::ok_to_send() {
|
|||
* indicate that a command needs to be re-sent.
|
||||
*/
|
||||
void GCodeQueue::flush_and_request_resend() {
|
||||
const int16_t pn = command_port();
|
||||
#if NUM_SERIAL > 1
|
||||
const int16_t pn = port[index_r];
|
||||
if (pn < 0) return;
|
||||
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
||||
#endif
|
||||
SERIAL_FLUSH();
|
||||
SERIAL_ECHOPGM(STR_RESEND);
|
||||
SERIAL_ECHOLN(last_N + 1);
|
||||
|
||||
SERIAL_ECHOLN(last_N[pn] + 1);
|
||||
ok_to_send();
|
||||
}
|
||||
|
||||
|
@ -336,7 +337,7 @@ void GCodeQueue::gcode_line_error(PGM_P const err, const int8_t pn) {
|
|||
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
||||
SERIAL_ERROR_START();
|
||||
serialprintPGM(err);
|
||||
SERIAL_ECHOLN(last_N);
|
||||
SERIAL_ECHOLN(last_N[pn]);
|
||||
while (read_serial(pn) != -1); // Clear out the RX buffer
|
||||
flush_and_request_resend();
|
||||
serial_count[pn] = 0;
|
||||
|
@ -475,9 +476,9 @@ void GCodeQueue::get_serial_commands() {
|
|||
if (n2pos) npos = n2pos;
|
||||
}
|
||||
|
||||
gcode_N = strtol(npos + 1, nullptr, 10);
|
||||
const long gcode_N = strtol(npos + 1, nullptr, 10);
|
||||
|
||||
if (gcode_N != last_N + 1 && !M110)
|
||||
if (gcode_N != last_N[i] + 1 && !M110)
|
||||
return gcode_line_error(PSTR(STR_ERR_LINE_NO), i);
|
||||
|
||||
char *apos = strrchr(command, '*');
|
||||
|
@ -490,7 +491,7 @@ void GCodeQueue::get_serial_commands() {
|
|||
else
|
||||
return gcode_line_error(PSTR(STR_ERR_NO_CHECKSUM), i);
|
||||
|
||||
last_N = gcode_N;
|
||||
last_N[i] = gcode_N;
|
||||
}
|
||||
#if ENABLED(SDSUPPORT)
|
||||
// Pronterface "M29" and "M29 " has no line number
|
||||
|
|
|
@ -35,7 +35,8 @@ public:
|
|||
* commands to Marlin, and lines will be checked for sequentiality.
|
||||
* M110 N<int> sets the current line number.
|
||||
*/
|
||||
static long last_N;
|
||||
|
||||
static long last_N[NUM_SERIAL];
|
||||
|
||||
/**
|
||||
* GCode Command Queue
|
||||
|
@ -51,13 +52,21 @@ public:
|
|||
|
||||
static char command_buffer[BUFSIZE][MAX_CMD_SIZE];
|
||||
|
||||
/*
|
||||
/**
|
||||
* The port that the command was received on
|
||||
*/
|
||||
#if NUM_SERIAL > 1
|
||||
static int16_t port[BUFSIZE];
|
||||
#endif
|
||||
|
||||
static int16_t command_port() {
|
||||
return (0
|
||||
#if NUM_SERIAL > 1
|
||||
+ port[index_r]
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
GCodeQueue();
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue