Revert "Moved comment and block delete handling to be done in protocol.c rather than gcode.c. Prevents these from being held in memory. Also, fixes bug when comments and block delete character are mixed with g-code."
This reverts commit ea5b8942db
.
This commit is contained in:
parent
8b0556bcfd
commit
a2837943c0
25
protocol.c
25
protocol.c
@ -72,34 +72,14 @@ uint8_t protocol_execute_line(char *line) {
|
|||||||
void protocol_process()
|
void protocol_process()
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
uint8_t iscomment = false;
|
|
||||||
while((c = serial_read()) != SERIAL_NO_DATA)
|
while((c = serial_read()) != SERIAL_NO_DATA)
|
||||||
{
|
{
|
||||||
if (iscomment) {
|
if((char_counter > 0) && ((c == '\n') || (c == '\r'))) { // Line is complete. Then execute!
|
||||||
// While in comment, skip all characters until ')', '\n', or '\r'
|
line[char_counter] = 0; // treminate string
|
||||||
if ((c == ')') || (c == '\n') || (c == '\r')) {
|
|
||||||
iscomment = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!iscomment) { // Seperate if-statement to process '\n' or '\r' at end of comment
|
|
||||||
if ((c == '\n') || (c == '\r')) { // End of block reached
|
|
||||||
if (char_counter > 0) {// Line is complete. Then execute!
|
|
||||||
line[char_counter] = 0; // terminate string
|
|
||||||
status_message(protocol_execute_line(line));
|
status_message(protocol_execute_line(line));
|
||||||
char_counter = 0; // reset line buffer index
|
char_counter = 0; // reset line buffer index
|
||||||
} else {
|
|
||||||
// Empty or comment line. Skip block.
|
|
||||||
status_message(STATUS_OK); // Send status message for syncing purposes.
|
|
||||||
}
|
|
||||||
} else if (c <= ' ') {
|
} else if (c <= ' ') {
|
||||||
// Throw away whitepace and control characters
|
// Throw away whitepace and control characters
|
||||||
} else if (c == '/') {
|
|
||||||
// Disable block delete and throw away character
|
|
||||||
// To enable block delete, uncomment following line
|
|
||||||
// iscomment = true;
|
|
||||||
} else if (c == '(') {
|
|
||||||
// Enable comments and ignore all characters until ')' or '\n'
|
|
||||||
iscomment = true;
|
|
||||||
} else if (char_counter >= LINE_BUFFER_SIZE-1) {
|
} else if (char_counter >= LINE_BUFFER_SIZE-1) {
|
||||||
// Throw away any characters beyond the end of the line buffer
|
// Throw away any characters beyond the end of the line buffer
|
||||||
} else if (c >= 'a' && c <= 'z') { // Upcase lowercase
|
} else if (c >= 'a' && c <= 'z') { // Upcase lowercase
|
||||||
@ -108,5 +88,4 @@ void protocol_process()
|
|||||||
line[char_counter++] = c;
|
line[char_counter++] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user