|
@@ -723,6 +723,15 @@ void loop() {
|
723
|
723
|
lcd_update();
|
724
|
724
|
}
|
725
|
725
|
|
|
726
|
+void gcode_line_error(const char *err, bool doFlush=true) {
|
|
727
|
+ SERIAL_ERROR_START;
|
|
728
|
+ serialprintPGM(err);
|
|
729
|
+ SERIAL_ERRORLN(gcode_LastN);
|
|
730
|
+ //Serial.println(gcode_N);
|
|
731
|
+ if (doFlush) FlushSerialRequestResend();
|
|
732
|
+ serial_count = 0;
|
|
733
|
+}
|
|
734
|
+
|
726
|
735
|
/**
|
727
|
736
|
* Add to the circular command queue the next command from:
|
728
|
737
|
* - The command-injection queue (queued_commands_P)
|
|
@@ -768,12 +777,7 @@ void get_command() {
|
768
|
777
|
strchr_pointer = strchr(command, 'N');
|
769
|
778
|
gcode_N = (strtol(strchr_pointer + 1, NULL, 10));
|
770
|
779
|
if (gcode_N != gcode_LastN + 1 && strstr_P(command, PSTR("M110")) == NULL) {
|
771
|
|
- SERIAL_ERROR_START;
|
772
|
|
- SERIAL_ERRORPGM(MSG_ERR_LINE_NO);
|
773
|
|
- SERIAL_ERRORLN(gcode_LastN);
|
774
|
|
- //Serial.println(gcode_N);
|
775
|
|
- FlushSerialRequestResend();
|
776
|
|
- serial_count = 0;
|
|
780
|
+ gcode_line_error(PSTR(MSG_ERR_LINE_NO));
|
777
|
781
|
return;
|
778
|
782
|
}
|
779
|
783
|
|
|
@@ -784,33 +788,22 @@ void get_command() {
|
784
|
788
|
strchr_pointer = strchr(command, '*');
|
785
|
789
|
|
786
|
790
|
if (strtol(strchr_pointer + 1, NULL, 10) != checksum) {
|
787
|
|
- SERIAL_ERROR_START;
|
788
|
|
- SERIAL_ERRORPGM(MSG_ERR_CHECKSUM_MISMATCH);
|
789
|
|
- SERIAL_ERRORLN(gcode_LastN);
|
790
|
|
- FlushSerialRequestResend();
|
791
|
|
- serial_count = 0;
|
|
791
|
+ gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH));
|
792
|
792
|
return;
|
793
|
793
|
}
|
794
|
|
- //if no errors, continue parsing
|
|
794
|
+ // if no errors, continue parsing
|
795
|
795
|
}
|
796
|
796
|
else {
|
797
|
|
- SERIAL_ERROR_START;
|
798
|
|
- SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM);
|
799
|
|
- SERIAL_ERRORLN(gcode_LastN);
|
800
|
|
- FlushSerialRequestResend();
|
801
|
|
- serial_count = 0;
|
|
797
|
+ gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM));
|
802
|
798
|
return;
|
803
|
799
|
}
|
804
|
800
|
|
805
|
801
|
gcode_LastN = gcode_N;
|
806
|
|
- //if no errors, continue parsing
|
|
802
|
+ // if no errors, continue parsing
|
807
|
803
|
}
|
808
|
804
|
else { // if we don't receive 'N' but still see '*'
|
809
|
805
|
if ((strchr(command, '*') != NULL)) {
|
810
|
|
- SERIAL_ERROR_START;
|
811
|
|
- SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM);
|
812
|
|
- SERIAL_ERRORLN(gcode_LastN);
|
813
|
|
- serial_count = 0;
|
|
806
|
+ gcode_line_error(PSTR(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM), false);
|
814
|
807
|
return;
|
815
|
808
|
}
|
816
|
809
|
}
|