Bladeren bron

Fix for a wrong checksum truncation for certain commands

Positioning of string terminator to truncate checksum from the commands
M23, M28, M30, M32, M928 and M117 was off by one, causing the last
letter of the actual command to be truncated instead of just the
checksum.

In case of the SD commands this caused checksummed commands targeting
existing files to fail since the last letter of the filename was
truncated.

In case of M117 this caused the last given letter not to be displayed.

This patch fixes the off-by-one error and sets the null terminator
on the exact position of the * starting the checksum instead of the
character before that.
Gina Häußge 11 jaren geleden
bovenliggende
commit
2d22902d08
1 gewijzigde bestanden met toevoegingen van 6 en 6 verwijderingen
  1. 6
    6
      Marlin/Marlin_main.cpp

+ 6
- 6
Marlin/Marlin_main.cpp Bestand weergeven

@@ -1693,7 +1693,7 @@ void process_commands()
1693 1693
     case 23: //M23 - Select file
1694 1694
       starpos = (strchr(strchr_pointer + 4,'*'));
1695 1695
       if(starpos!=NULL)
1696
-        *(starpos-1)='\0';
1696
+        *(starpos)='\0';
1697 1697
       card.openFile(strchr_pointer + 4,true);
1698 1698
       break;
1699 1699
     case 24: //M24 - Start SD print
@@ -1716,7 +1716,7 @@ void process_commands()
1716 1716
       if(starpos != NULL){
1717 1717
         char* npos = strchr(cmdbuffer[bufindr], 'N');
1718 1718
         strchr_pointer = strchr(npos,' ') + 1;
1719
-        *(starpos-1) = '\0';
1719
+        *(starpos) = '\0';
1720 1720
       }
1721 1721
       card.openFile(strchr_pointer+4,false);
1722 1722
       break;
@@ -1731,7 +1731,7 @@ void process_commands()
1731 1731
         if(starpos != NULL){
1732 1732
           char* npos = strchr(cmdbuffer[bufindr], 'N');
1733 1733
           strchr_pointer = strchr(npos,' ') + 1;
1734
-          *(starpos-1) = '\0';
1734
+          *(starpos) = '\0';
1735 1735
         }
1736 1736
         card.removeFile(strchr_pointer + 4);
1737 1737
       }
@@ -1753,7 +1753,7 @@ void process_commands()
1753 1753
         namestartpos++; //to skip the '!'
1754 1754
 
1755 1755
       if(starpos!=NULL)
1756
-        *(starpos-1)='\0';
1756
+        *(starpos)='\0';
1757 1757
 
1758 1758
       bool call_procedure=(code_seen('P'));
1759 1759
 
@@ -1776,7 +1776,7 @@ void process_commands()
1776 1776
       if(starpos != NULL){
1777 1777
         char* npos = strchr(cmdbuffer[bufindr], 'N');
1778 1778
         strchr_pointer = strchr(npos,' ') + 1;
1779
-        *(starpos-1) = '\0';
1779
+        *(starpos) = '\0';
1780 1780
       }
1781 1781
       card.openLogFile(strchr_pointer+5);
1782 1782
       break;
@@ -2193,7 +2193,7 @@ void process_commands()
2193 2193
     case 117: // M117 display message
2194 2194
       starpos = (strchr(strchr_pointer + 5,'*'));
2195 2195
       if(starpos!=NULL)
2196
-        *(starpos-1)='\0';
2196
+        *(starpos)='\0';
2197 2197
       lcd_setstatus(strchr_pointer + 5);
2198 2198
       break;
2199 2199
     case 114: // M114

Laden…
Annuleren
Opslaan