Permalink
Browse files

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!)
  • Loading branch information...
1 parent 33c6659 commit ca563cf42366a861f94aa6df45b31e939d1513ed @chamnit chamnit committed Apr 5, 2013
Showing with 18 additions and 8 deletions.
  1. +2 −2 config.h
  2. +12 −5 protocol.c
  3. +1 −1 protocol.h
  4. +2 −0 report.c
  5. +1 −0 report.h
View
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
View
17 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,9 +309,8 @@ 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) {
// Throw away all comment characters
@@ -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 {
View
2 protocol.h
@@ -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
View
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"));
}
View
1 report.h
@@ -35,6 +35,7 @@
#define STATUS_SETTING_READ_FAIL 10
#define STATUS_IDLE_ERROR 11
#define STATUS_ALARM_LOCK 12
+#define STATUS_OVERFLOW 13
// Define Grbl alarm codes. Less than zero to distinguish alarm error from status error.
#define ALARM_HARD_LIMIT -1

0 comments on commit ca563cf

Please sign in to comment.