Minor bug fixes and updates. Line number tracking.

- Line number tracking was getting truncated at 255, since it was using
wrong variable type. Fixed it with a trunc().

- Increased the max number line allowed by Grbl to 9999999 from the
g-code standard 99999. The latter seems to be an arbitrary number, so
we are allowing larger ones for at least one known use case scenario.

- Created a new test directory to contain some testing g-code to proof
the firmware. Only got started with one test case so far. More will be
inserted as needed.

- Some other commenting updates to clarify certain aspects of the code.
This commit is contained in:
Sonny Jeon
2014-07-02 08:39:19 -06:00
parent 79e0e45826
commit 1ef5a45479
4 changed files with 56 additions and 15 deletions

View File

@ -61,7 +61,7 @@ static void protocol_execute_line(char *line)
/*
GRBL MAIN LOOP:
GRBL PRIMARY LOOP:
*/
void protocol_main_loop()
{
@ -81,9 +81,9 @@ void protocol_main_loop()
system_execute_startup(line); // Execute startup script.
}
// ------------------------------------------------------------------------------
// Main loop! Upon a system abort, this exits back to main() to reset the system.
// ------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------
// Primary loop! Upon a system abort, this exits back to main() to reset the system.
// ---------------------------------------------------------------------------------
uint8_t iscomment = false;
uint8_t char_counter = 0;
@ -92,6 +92,14 @@ void protocol_main_loop()
// Process one line of incoming serial data, as the data becomes available. Performs an
// initial filtering by removing spaces and comments and capitalizing all letters.
// NOTE: While comment, spaces, and block delete(if supported) handling should technically
// be done in the g-code parser, doing it here helps compress the incoming data into Grbl's
// line buffer, which is limited in size. The g-code standard actually states a line can't
// exceed 256 characters, but the Arduino Uno does not have the memory space for this.
// With a better processor, it would be very easy to pull this initial parsing out as a
// seperate task to be shared by the g-code parser and Grbl's system commands.
while((c = serial_read()) != SERIAL_NO_DATA) {
if ((c == '\n') || (c == '\r')) { // End of line reached
line[char_counter] = 0; // Set string termination character.