浏览代码

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 年前
父节点
当前提交
2d22902d08
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 6
    6
      Marlin/Marlin_main.cpp

+ 6
- 6
Marlin/Marlin_main.cpp 查看文件

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

正在加载...
取消
保存