Browse Source

Fix multi-serial CRC error crash (#21249)

Victor Oliveira 4 years ago
parent
commit
101f09aabd
No account linked to committer's email address
3 changed files with 4 additions and 5 deletions
  1. 1
    1
      Marlin/src/gcode/control/M999.cpp
  2. 2
    3
      Marlin/src/gcode/queue.cpp
  3. 1
    1
      Marlin/src/gcode/queue.h

+ 1
- 1
Marlin/src/gcode/control/M999.cpp View File

41
 
41
 
42
   if (parser.boolval('S')) return;
42
   if (parser.boolval('S')) return;
43
 
43
 
44
-  queue.flush_and_request_resend();
44
+  queue.flush_and_request_resend(queue.ring_buffer.command_port());
45
 }
45
 }

+ 2
- 3
Marlin/src/gcode/queue.cpp View File

262
  * Send a "Resend: nnn" message to the host to
262
  * Send a "Resend: nnn" message to the host to
263
  * indicate that a command needs to be re-sent.
263
  * indicate that a command needs to be re-sent.
264
  */
264
  */
265
-void GCodeQueue::flush_and_request_resend() {
266
-  const serial_index_t serial_ind = ring_buffer.command_port();
265
+void GCodeQueue::flush_and_request_resend(const serial_index_t serial_ind) {
267
   #if HAS_MULTI_SERIAL
266
   #if HAS_MULTI_SERIAL
268
     if (serial_ind < 0) return;                   // Never mind. Command came from SD or Flash Drive
267
     if (serial_ind < 0) return;                   // Never mind. Command came from SD or Flash Drive
269
     PORT_REDIRECT(SERIAL_PORTMASK(serial_ind));   // Reply to the serial port that sent the command
268
     PORT_REDIRECT(SERIAL_PORTMASK(serial_ind));   // Reply to the serial port that sent the command
306
   SERIAL_ERROR_START();
305
   SERIAL_ERROR_START();
307
   SERIAL_ECHOLNPAIR_P(err, serial_state[serial_ind].last_N);
306
   SERIAL_ECHOLNPAIR_P(err, serial_state[serial_ind].last_N);
308
   while (read_serial(serial_ind) != -1) { /* nada */ } // Clear out the RX buffer. Why don't use flush here ?
307
   while (read_serial(serial_ind) != -1) { /* nada */ } // Clear out the RX buffer. Why don't use flush here ?
309
-  flush_and_request_resend();
308
+  flush_and_request_resend(serial_ind);
310
   serial_state[serial_ind].count = 0;
309
   serial_state[serial_ind].count = 0;
311
 }
310
 }
312
 
311
 

+ 1
- 1
Marlin/src/gcode/queue.h View File

185
    * Clear the serial line and request a resend of
185
    * Clear the serial line and request a resend of
186
    * the next expected line number.
186
    * the next expected line number.
187
    */
187
    */
188
-  static void flush_and_request_resend();
188
+  static void flush_and_request_resend(const serial_index_t serial_ind);
189
 
189
 
190
   /**
190
   /**
191
    * (Re)Set the current line number for the last received command
191
    * (Re)Set the current line number for the last received command

Loading…
Cancel
Save