소스 검색

Flush RX buffer on G-code line errors to prevent hang (#13018)

jeffstaley 6 년 전
부모
커밋
2f176d6fb8
1개의 변경된 파일12개의 추가작업 그리고 11개의 파일을 삭제
  1. 12
    11
      Marlin/src/gcode/queue.cpp

+ 12
- 11
Marlin/src/gcode/queue.cpp 파일 보기

251
   ok_to_send();
251
   ok_to_send();
252
 }
252
 }
253
 
253
 
254
-void gcode_line_error(PGM_P err, uint8_t port) {
255
-  SERIAL_ERROR_START_P(port);
256
-  serialprintPGM_P(port, err);
257
-  SERIAL_ECHOLN_P(port, gcode_LastN);
258
-  flush_and_request_resend();
259
-  serial_count[port] = 0;
260
-}
261
-
262
-static bool serial_data_available() {
254
+inline bool serial_data_available() {
263
   return false
255
   return false
264
     || MYSERIAL0.available()
256
     || MYSERIAL0.available()
265
     #if NUM_SERIAL > 1
257
     #if NUM_SERIAL > 1
268
   ;
260
   ;
269
 }
261
 }
270
 
262
 
271
-static int read_serial(const uint8_t index) {
263
+inline int read_serial(const uint8_t index) {
272
   switch (index) {
264
   switch (index) {
273
     case 0: return MYSERIAL0.read();
265
     case 0: return MYSERIAL0.read();
274
     #if NUM_SERIAL > 1
266
     #if NUM_SERIAL > 1
278
   }
270
   }
279
 }
271
 }
280
 
272
 
273
+void gcode_line_error(PGM_P err, uint8_t port) {
274
+  SERIAL_ERROR_START_P(port);
275
+  serialprintPGM_P(port, err);
276
+  SERIAL_ECHOLN_P(port, gcode_LastN);
277
+  while (read_serial(port) != -1);           // clear out the RX buffer
278
+  flush_and_request_resend();
279
+  serial_count[port] = 0;
280
+}
281
+
281
 #if ENABLED(FAST_FILE_TRANSFER)
282
 #if ENABLED(FAST_FILE_TRANSFER)
282
 
283
 
283
   #if ENABLED(SDSUPPORT)
284
   #if ENABLED(SDSUPPORT)
286
     #define CARD_ECHOLN_P(V) SERIAL_ECHOLN_P(card.transfer_port, V)
287
     #define CARD_ECHOLN_P(V) SERIAL_ECHOLN_P(card.transfer_port, V)
287
   #endif
288
   #endif
288
 
289
 
289
-  static bool serial_data_available(const uint8_t index) {
290
+  inline bool serial_data_available(const uint8_t index) {
290
     switch (index) {
291
     switch (index) {
291
       case 0: return MYSERIAL0.available();
292
       case 0: return MYSERIAL0.available();
292
       #if NUM_SERIAL > 1
293
       #if NUM_SERIAL > 1

Loading…
취소
저장