|
@@ -52,7 +52,7 @@ GCodeQueue queue;
|
52
|
52
|
* sending commands to Marlin, and lines will be checked for sequentiality.
|
53
|
53
|
* M110 N<int> sets the current line number.
|
54
|
54
|
*/
|
55
|
|
-long gcode_N, GCodeQueue::last_N;
|
|
55
|
+long GCodeQueue::last_N[NUM_SERIAL];
|
56
|
56
|
|
57
|
57
|
/**
|
58
|
58
|
* GCode Command Queue
|
|
@@ -277,7 +277,7 @@ void GCodeQueue::enqueue_now_P(PGM_P const pgcode) {
|
277
|
277
|
*/
|
278
|
278
|
void GCodeQueue::ok_to_send() {
|
279
|
279
|
#if NUM_SERIAL > 1
|
280
|
|
- const int16_t pn = port[index_r];
|
|
280
|
+ const int16_t pn = command_port();
|
281
|
281
|
if (pn < 0) return;
|
282
|
282
|
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
283
|
283
|
#endif
|
|
@@ -302,14 +302,15 @@ void GCodeQueue::ok_to_send() {
|
302
|
302
|
* indicate that a command needs to be re-sent.
|
303
|
303
|
*/
|
304
|
304
|
void GCodeQueue::flush_and_request_resend() {
|
|
305
|
+ const int16_t pn = command_port();
|
305
|
306
|
#if NUM_SERIAL > 1
|
306
|
|
- const int16_t pn = port[index_r];
|
307
|
307
|
if (pn < 0) return;
|
308
|
308
|
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
309
|
309
|
#endif
|
310
|
310
|
SERIAL_FLUSH();
|
311
|
311
|
SERIAL_ECHOPGM(STR_RESEND);
|
312
|
|
- SERIAL_ECHOLN(last_N + 1);
|
|
312
|
+
|
|
313
|
+ SERIAL_ECHOLN(last_N[pn] + 1);
|
313
|
314
|
ok_to_send();
|
314
|
315
|
}
|
315
|
316
|
|
|
@@ -336,7 +337,7 @@ void GCodeQueue::gcode_line_error(PGM_P const err, const int8_t pn) {
|
336
|
337
|
PORT_REDIRECT(pn); // Reply to the serial port that sent the command
|
337
|
338
|
SERIAL_ERROR_START();
|
338
|
339
|
serialprintPGM(err);
|
339
|
|
- SERIAL_ECHOLN(last_N);
|
|
340
|
+ SERIAL_ECHOLN(last_N[pn]);
|
340
|
341
|
while (read_serial(pn) != -1); // Clear out the RX buffer
|
341
|
342
|
flush_and_request_resend();
|
342
|
343
|
serial_count[pn] = 0;
|
|
@@ -475,9 +476,9 @@ void GCodeQueue::get_serial_commands() {
|
475
|
476
|
if (n2pos) npos = n2pos;
|
476
|
477
|
}
|
477
|
478
|
|
478
|
|
- gcode_N = strtol(npos + 1, nullptr, 10);
|
|
479
|
+ const long gcode_N = strtol(npos + 1, nullptr, 10);
|
479
|
480
|
|
480
|
|
- if (gcode_N != last_N + 1 && !M110)
|
|
481
|
+ if (gcode_N != last_N[i] + 1 && !M110)
|
481
|
482
|
return gcode_line_error(PSTR(STR_ERR_LINE_NO), i);
|
482
|
483
|
|
483
|
484
|
char *apos = strrchr(command, '*');
|
|
@@ -490,7 +491,7 @@ void GCodeQueue::get_serial_commands() {
|
490
|
491
|
else
|
491
|
492
|
return gcode_line_error(PSTR(STR_ERR_NO_CHECKSUM), i);
|
492
|
493
|
|
493
|
|
- last_N = gcode_N;
|
|
494
|
+ last_N[i] = gcode_N;
|
494
|
495
|
}
|
495
|
496
|
#if ENABLED(SDSUPPORT)
|
496
|
497
|
// Pronterface "M29" and "M29 " has no line number
|