Rx buffer overflow behavior improved
This commit is contained in:
parent
04f8e6d61e
commit
ed5842d1d1
@ -722,8 +722,4 @@ enum CalibrationStatus
|
||||
|
||||
#include "Configuration_adv.h"
|
||||
#include "thermistortables.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //__CONFIGURATION_H
|
||||
|
@ -429,7 +429,7 @@ static bool cmdbuffer_front_already_processed = false;
|
||||
// Debugging information will be sent to serial line.
|
||||
// #define CMDBUFFER_DEBUG
|
||||
|
||||
static int serial_count = 0;
|
||||
static int serial_count = 0; //index of character read from serial line
|
||||
static boolean comment_mode = false;
|
||||
static char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc
|
||||
|
||||
@ -1323,10 +1323,16 @@ void loop()
|
||||
void get_command()
|
||||
{
|
||||
// Test and reserve space for the new command string.
|
||||
if (! cmdqueue_could_enqueue_back(MAX_CMD_SIZE-1))
|
||||
if (!cmdqueue_could_enqueue_back(MAX_CMD_SIZE - 1))
|
||||
return;
|
||||
|
||||
bool rx_buffer_full = false; //flag that serial rx buffer is 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();
|
||||
TimeSent = millis();
|
||||
TimeNow = millis();
|
||||
@ -1476,6 +1482,13 @@ void get_command()
|
||||
}
|
||||
}
|
||||
|
||||
//add comment
|
||||
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){
|
||||
// If there is a half filled buffer from serial line, wait until return before
|
||||
@ -3878,7 +3891,6 @@ Sigma_Exit:
|
||||
SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
|
||||
}
|
||||
#endif
|
||||
|
||||
SERIAL_PROTOCOLLN("");
|
||||
return;
|
||||
break;
|
||||
|
@ -4637,7 +4637,7 @@ void lcd_buttons_update()
|
||||
button_pressed = true;
|
||||
}
|
||||
else {
|
||||
if (millis() - long_press_timer > 500) { //long press activated
|
||||
if (millis() - long_press_timer > 1000) { //long press activated
|
||||
long_press_active = true;
|
||||
move_menu_scale = 1.0;
|
||||
savedMenu = currentMenu;
|
||||
@ -4651,7 +4651,7 @@ void lcd_buttons_update()
|
||||
if (currentMenu == lcd_move_z) {
|
||||
//return to previously active menu
|
||||
//lcd_goto_menu(savedMenu);
|
||||
lcd_goto_menu(lcd_main_menu);
|
||||
//lcd_goto_menu(lcd_main_menu);
|
||||
lcd_return_to_status();
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user