Increased g-code parser line buffer. Added line overflow feedback.
- Increased g-code parser line buffer from 50 to 70 characters. Should fix most all issues with long arc statements, provided that they are 8 digits(float) long only. - Added a line buffer overflow feedback error to let the user know when it encounters this problem. Resets the line whenever this occurs. (Thanks @BHSPitMonkey!)
This commit is contained in:
parent
33c6659523
commit
ca563cf423
4
config.h
4
config.h
@ -185,11 +185,11 @@
|
||||
// each of the startup blocks, as they are each stored as a string of this size. Make sure
|
||||
// to account for the available EEPROM at the defined memory address in settings.h and for
|
||||
// the number of desired startup blocks.
|
||||
// NOTE: 50 characters is not a problem except for extreme cases, but the line buffer size
|
||||
// NOTE: 70 characters is not a problem except for extreme cases, but the line buffer size
|
||||
// can be too small and g-code blocks can get truncated. Officially, the g-code standards
|
||||
// support up to 256 characters. In future versions, this default will be increased, when
|
||||
// we know how much extra memory space we can re-invest into this.
|
||||
// #define LINE_BUFFER_SIZE 50 // Uncomment to override default in protocol.h
|
||||
// #define LINE_BUFFER_SIZE 70 // Uncomment to override default in protocol.h
|
||||
|
||||
// Serial send and receive buffer size. The receive buffer is often used as another streaming
|
||||
// buffer to store incoming blocks to be processed by Grbl when its ready. Most streaming
|
||||
|
15
protocol.c
15
protocol.c
@ -37,10 +37,16 @@ static uint8_t char_counter; // Last character counter in line variable.
|
||||
static uint8_t iscomment; // Comment/block delete flag for processor to ignore comment characters.
|
||||
|
||||
|
||||
void protocol_init()
|
||||
static void protocol_reset_line_buffer()
|
||||
{
|
||||
char_counter = 0; // Reset line input
|
||||
iscomment = false;
|
||||
}
|
||||
|
||||
|
||||
void protocol_init()
|
||||
{
|
||||
protocol_reset_line_buffer();
|
||||
report_init_message(); // Welcome message
|
||||
|
||||
PINOUT_DDR &= ~(PINOUT_MASK); // Set as input pins
|
||||
@ -303,8 +309,7 @@ void protocol_process()
|
||||
// Empty or comment line. Skip block.
|
||||
report_status_message(STATUS_OK); // Send status message for syncing purposes.
|
||||
}
|
||||
char_counter = 0; // Reset line buffer index
|
||||
iscomment = false; // Reset comment flag
|
||||
protocol_reset_line_buffer();
|
||||
|
||||
} else {
|
||||
if (iscomment) {
|
||||
@ -322,7 +327,9 @@ void protocol_process()
|
||||
// Enable comments flag and ignore all characters until ')' or EOL.
|
||||
iscomment = true;
|
||||
} else if (char_counter >= LINE_BUFFER_SIZE-1) {
|
||||
// Throw away any characters beyond the end of the line buffer
|
||||
// Report line buffer overflow and reset
|
||||
report_status_message(STATUS_OVERFLOW);
|
||||
protocol_reset_line_buffer();
|
||||
} else if (c >= 'a' && c <= 'z') { // Upcase lowercase
|
||||
line[char_counter++] = c-'a'+'A';
|
||||
} else {
|
||||
|
@ -30,7 +30,7 @@
|
||||
// memory space we can invest into here or we re-write the g-code parser not to have his
|
||||
// buffer.
|
||||
#ifndef LINE_BUFFER_SIZE
|
||||
#define LINE_BUFFER_SIZE 50
|
||||
#define LINE_BUFFER_SIZE 70
|
||||
#endif
|
||||
|
||||
// Initialize the serial protocol
|
||||
|
2
report.c
2
report.c
@ -74,6 +74,8 @@ void report_status_message(uint8_t status_code)
|
||||
printPgmString(PSTR("Busy or queued")); break;
|
||||
case STATUS_ALARM_LOCK:
|
||||
printPgmString(PSTR("Alarm lock")); break;
|
||||
case STATUS_OVERFLOW:
|
||||
printPgmString(PSTR("Line overflow")); break;
|
||||
}
|
||||
printPgmString(PSTR("\r\n"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user