parent
3a81646c9a
commit
0108d5181f
|
@ -230,18 +230,17 @@ inline void get_serial_commands() {
|
||||||
*/
|
*/
|
||||||
if (serial_char == '\n' || serial_char == '\r') {
|
if (serial_char == '\n' || serial_char == '\r') {
|
||||||
|
|
||||||
serial_comment_mode = false; // end of line == end of comment
|
serial_comment_mode = false; // end of line == end of comment
|
||||||
|
|
||||||
if (!serial_count) continue; // skip empty lines
|
if (!serial_count) continue; // Skip empty lines
|
||||||
|
|
||||||
serial_line_buffer[serial_count] = 0; // terminate string
|
serial_line_buffer[serial_count] = 0; // Terminate string
|
||||||
serial_count = 0; //reset buffer
|
serial_count = 0; // Reset buffer
|
||||||
|
|
||||||
char* command = serial_line_buffer;
|
char* command = serial_line_buffer;
|
||||||
|
|
||||||
while (*command == ' ') command++; // skip any leading spaces
|
while (*command == ' ') command++; // Skip leading spaces
|
||||||
char *npos = (*command == 'N') ? command : NULL, // Require the N parameter to start the line
|
char *npos = (*command == 'N') ? command : NULL; // Require the N parameter to start the line
|
||||||
*apos = strchr(command, '*');
|
|
||||||
|
|
||||||
if (npos) {
|
if (npos) {
|
||||||
|
|
||||||
|
@ -259,15 +258,14 @@ inline void get_serial_commands() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *apos = strrchr(command, '*');
|
||||||
if (apos) {
|
if (apos) {
|
||||||
byte checksum = 0, count = 0;
|
uint8_t checksum = 0, count = uint8_t(apos - command);
|
||||||
while (command[count] != '*') checksum ^= command[count++];
|
while (count) checksum ^= command[--count];
|
||||||
|
|
||||||
if (strtol(apos + 1, NULL, 10) != checksum) {
|
if (strtol(apos + 1, NULL, 10) != checksum) {
|
||||||
gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH));
|
gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if no errors, continue parsing
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM));
|
gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM));
|
||||||
|
@ -275,11 +273,6 @@ inline void get_serial_commands() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gcode_LastN = gcode_N;
|
gcode_LastN = gcode_N;
|
||||||
// if no errors, continue parsing
|
|
||||||
}
|
|
||||||
else if (apos) { // No '*' without 'N'
|
|
||||||
gcode_line_error(PSTR(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM), false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Movement commands alert when stopped
|
// Movement commands alert when stopped
|
||||||
|
|
Loading…
Reference in a new issue