diff options
author | XPila <robert.pelnar@seznam.cz> | 2018-01-15 17:28:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-15 17:28:19 +0300 |
commit | 9d52d017dfe854a32eb223a870402b238630ed2e (patch) | |
tree | a0f7e7af9ad4c03a7d9e97a1c27a4bb41d2fb42e | |
parent | 87ffb0b193766a66c930dbc39bce0516d4b0b1f8 (diff) | |
parent | 1d3f6e8be56ec8f3a8b32f11b3188a11bc30cc19 (diff) |
Merge pull request #401 from PavelSindler/rx_buffer
get command update
-rw-r--r-- | Firmware/MarlinSerial.cpp | 4 | ||||
-rw-r--r-- | Firmware/cmdqueue.cpp | 16 |
2 files changed, 10 insertions, 10 deletions
diff --git a/Firmware/MarlinSerial.cpp b/Firmware/MarlinSerial.cpp index 359aaa595..357de7c60 100644 --- a/Firmware/MarlinSerial.cpp +++ b/Firmware/MarlinSerial.cpp @@ -200,10 +200,6 @@ void MarlinSerial::flush() // occurs after reading the value of rx_buffer_head but before writing // the value to rx_buffer_tail; the previous value of rx_buffer_head // may be written to rx_buffer_tail, making it appear as if the buffer - // don't reverse this or there may be problems if the RX interrupt - // occurs after reading the value of rx_buffer_head but before writing - // the value to rx_buffer_tail; the previous value of rx_buffer_head - // may be written to rx_buffer_tail, making it appear as if the buffer // were full, not empty. rx_buffer.head = rx_buffer.tail; } diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 2bb389848..771daafec 100644 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -368,11 +368,15 @@ void get_command() bool rx_buffer_full = false; //flag that serial rx buffer is full + if (MYSERIAL.available() == RX_BUFFER_SIZE - 1) { //compare number of chars buffered in rx buffer with rx buffer size + MYSERIAL.flush(); + SERIAL_ECHOLNPGM("Full RX Buffer"); //if buffer was full, there is danger that reading of last gcode will not be completed + + rx_buffer_full = true; //sets flag that buffer was full + } + while (MYSERIAL.available() > 0) { - if (MYSERIAL.available() == RX_BUFFER_SIZE - 1) { //compare number of chars buffered in rx buffer with rx buffer size - SERIAL_ECHOLNPGM("Full RX Buffer"); //if buffer was full, there is danger that reading of last gcode will not be completed - rx_buffer_full = true; //sets flag that buffer was full - } + char serial_char = MYSERIAL.read(); /* if (selectedSerialPort == 1) { @@ -529,11 +533,11 @@ void get_command() } //add comment - if (rx_buffer_full == true && serial_count > 0) { //if rx buffer was full and string was not properly terminated + /*if (rx_buffer_full == true && serial_count > 0) { //if rx buffer was full and string was not properly terminated rx_buffer_full = false; bufindw = bufindw - serial_count; //adjust tail of the buffer to prepare buffer for writing new command serial_count = 0; - } + }*/ #ifdef SDSUPPORT if(!card.sdprinting || serial_count!=0){ |