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