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.
master
Gina Häußge 10 years ago
parent ea9bffdc48
commit 2d22902d08

@ -1693,7 +1693,7 @@ void process_commands()
case 23: //M23 - Select file case 23: //M23 - Select file
starpos = (strchr(strchr_pointer + 4,'*')); starpos = (strchr(strchr_pointer + 4,'*'));
if(starpos!=NULL) if(starpos!=NULL)
*(starpos-1)='\0'; *(starpos)='\0';
card.openFile(strchr_pointer + 4,true); card.openFile(strchr_pointer + 4,true);
break; break;
case 24: //M24 - Start SD print case 24: //M24 - Start SD print
@ -1716,7 +1716,7 @@ void process_commands()
if(starpos != NULL){ if(starpos != NULL){
char* npos = strchr(cmdbuffer[bufindr], 'N'); char* npos = strchr(cmdbuffer[bufindr], 'N');
strchr_pointer = strchr(npos,' ') + 1; strchr_pointer = strchr(npos,' ') + 1;
*(starpos-1) = '\0'; *(starpos) = '\0';
} }
card.openFile(strchr_pointer+4,false); card.openFile(strchr_pointer+4,false);
break; break;
@ -1731,7 +1731,7 @@ void process_commands()
if(starpos != NULL){ if(starpos != NULL){
char* npos = strchr(cmdbuffer[bufindr], 'N'); char* npos = strchr(cmdbuffer[bufindr], 'N');
strchr_pointer = strchr(npos,' ') + 1; strchr_pointer = strchr(npos,' ') + 1;
*(starpos-1) = '\0'; *(starpos) = '\0';
} }
card.removeFile(strchr_pointer + 4); card.removeFile(strchr_pointer + 4);
} }
@ -1753,7 +1753,7 @@ void process_commands()
namestartpos++; //to skip the '!' namestartpos++; //to skip the '!'
if(starpos!=NULL) if(starpos!=NULL)
*(starpos-1)='\0'; *(starpos)='\0';
bool call_procedure=(code_seen('P')); bool call_procedure=(code_seen('P'));
@ -1776,7 +1776,7 @@ void process_commands()
if(starpos != NULL){ if(starpos != NULL){
char* npos = strchr(cmdbuffer[bufindr], 'N'); char* npos = strchr(cmdbuffer[bufindr], 'N');
strchr_pointer = strchr(npos,' ') + 1; strchr_pointer = strchr(npos,' ') + 1;
*(starpos-1) = '\0'; *(starpos) = '\0';
} }
card.openLogFile(strchr_pointer+5); card.openLogFile(strchr_pointer+5);
break; break;
@ -2193,7 +2193,7 @@ void process_commands()
case 117: // M117 display message case 117: // M117 display message
starpos = (strchr(strchr_pointer + 5,'*')); starpos = (strchr(strchr_pointer + 5,'*'));
if(starpos!=NULL) if(starpos!=NULL)
*(starpos-1)='\0'; *(starpos)='\0';
lcd_setstatus(strchr_pointer + 5); lcd_setstatus(strchr_pointer + 5);
break; break;
case 114: // M114 case 114: // M114

Loading…
Cancel
Save