|
@@ -1138,18 +1138,17 @@ inline void get_serial_commands() {
|
1138
|
1138
|
*/
|
1139
|
1139
|
if (serial_char == '\n' || serial_char == '\r') {
|
1140
|
1140
|
|
1141
|
|
- serial_comment_mode = false; // end of line == end of comment
|
|
1141
|
+ serial_comment_mode = false; // end of line == end of comment
|
1142
|
1142
|
|
1143
|
|
- if (!serial_count) continue; // skip empty lines
|
|
1143
|
+ if (!serial_count) continue; // Skip empty lines
|
1144
|
1144
|
|
1145
|
|
- serial_line_buffer[serial_count] = 0; // terminate string
|
1146
|
|
- serial_count = 0; //reset buffer
|
|
1145
|
+ serial_line_buffer[serial_count] = 0; // Terminate string
|
|
1146
|
+ serial_count = 0; // Reset buffer
|
1147
|
1147
|
|
1148
|
1148
|
char* command = serial_line_buffer;
|
1149
|
1149
|
|
1150
|
|
- while (*command == ' ') command++; // skip any leading spaces
|
1151
|
|
- char *npos = (*command == 'N') ? command : NULL, // Require the N parameter to start the line
|
1152
|
|
- *apos = strchr(command, '*');
|
|
1150
|
+ while (*command == ' ') command++; // Skip leading spaces
|
|
1151
|
+ char *npos = (*command == 'N') ? command : NULL; // Require the N parameter to start the line
|
1153
|
1152
|
|
1154
|
1153
|
if (npos) {
|
1155
|
1154
|
|
|
@@ -1167,15 +1166,14 @@ inline void get_serial_commands() {
|
1167
|
1166
|
return;
|
1168
|
1167
|
}
|
1169
|
1168
|
|
|
1169
|
+ char *apos = strrchr(command, '*');
|
1170
|
1170
|
if (apos) {
|
1171
|
|
- byte checksum = 0, count = 0;
|
1172
|
|
- while (command[count] != '*') checksum ^= command[count++];
|
1173
|
|
-
|
|
1171
|
+ uint8_t checksum = 0, count = uint8_t(apos - command);
|
|
1172
|
+ while (count) checksum ^= command[--count];
|
1174
|
1173
|
if (strtol(apos + 1, NULL, 10) != checksum) {
|
1175
|
1174
|
gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH));
|
1176
|
1175
|
return;
|
1177
|
1176
|
}
|
1178
|
|
- // if no errors, continue parsing
|
1179
|
1177
|
}
|
1180
|
1178
|
else {
|
1181
|
1179
|
gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM));
|
|
@@ -1183,11 +1181,6 @@ inline void get_serial_commands() {
|
1183
|
1181
|
}
|
1184
|
1182
|
|
1185
|
1183
|
gcode_LastN = gcode_N;
|
1186
|
|
- // if no errors, continue parsing
|
1187
|
|
- }
|
1188
|
|
- else if (apos) { // No '*' without 'N'
|
1189
|
|
- gcode_line_error(PSTR(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM), false);
|
1190
|
|
- return;
|
1191
|
1184
|
}
|
1192
|
1185
|
|
1193
|
1186
|
// Movement commands alert when stopped
|