Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit 4f11bf5

Browse files
committed
Fix for #33
1 parent 34e5020 commit 4f11bf5

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Makelangelo-firmware.ino

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -621,24 +621,28 @@ char checkCRCisOK() {
621621
*/
622622
void parseMessage() {
623623
#ifdef HAS_LCD
624-
int i;
625-
// "M117 " is 5 characters long
626-
for(i=0;i<5;++i) {
627-
if(serialBuffer[i]==0) {
628-
// no message
629-
lcd_message[0]=0;
630-
return;
624+
int i,j=0;
625+
for(i=0;i<strlen(serialBuffer);++i) {
626+
if(serialBuffer[i]==' ') {
627+
++j;
628+
if(j==2) break;
631629
}
632630
}
633631

632+
if(i==strlen(serialBuffer)) {
633+
// no message
634+
lcd_message[0]=0;
635+
lcd_message[LCD_WIDTH + 1]=0;
636+
return;
637+
}
638+
634639
// preserve message for display
635640
int top = min(LCD_MESSAGE_LENGTH,MAX_BUF);
636641
//Serial.print("top "); Serial.println(top);
637642
//Serial.print(">>");
638643

639-
i=0;
640-
int j=0;
641-
char *buf = serialBuffer+5;
644+
char *buf = serialBuffer[i];
645+
i=j=0;
642646
while(isPrintable(*buf) && *buf!='\r' && *buf!='\n' && i<LCD_MESSAGE_LENGTH-1) {
643647
lcd_message[i]=*buf;
644648
//Serial.print(i); Serial.print(j); Serial.print('\t'); Serial.println(*buf);

0 commit comments

Comments
 (0)