writing to SD card using smartGPU library

Hello
I am trying to write text into text file stored on my SD card using arduino uno
the SD card is placed inside the smartGPU screen and I am using their library to write.
the smartGPU screen is on top of my arduino.

this is my code

  char buffer[100] = {0}; 
  unsigned int bytesRead=0; 
  lcd.SDFopenFile("config.txt",READWRITE,WORKSPACE0);
  lcd.SDFreadFile(buffer,20, &bytesRead, WORKSPACE0);
  strcat(buffer, "ApplicationName:Living Room;");
  lcd.SDFwriteFile(buffer,100, &bytesRead, WORKSPACE0);
  lcd.SDFsaveFile(WORKSPACE0);
  lcd.SDFcloseFile(WORKSPACE0);

the code write succefuly with no errors, but when I open the file in PC this is the content
??????????????

the library write the english text into chinese !!!
is there an example to write using the smartGPU library? and why did this happen?

regards

I am trying to write text into text file stored on my SD card using arduino uno

  lcd.SDFwriteFile(buffer,100, &bytesRead, WORKSPACE0);

Since you didn't post a link to the library you are using, we can only guess at what the arguments mean. The second one appears to tell the function to write 100 bytes to the file, regardless of how many are actually in the array in the first argument. Why would you do that? Why does the function (appear to) get told to store the number of bytes written into a variable called bytesRead?

No clue what WORKSPACE0 means.

the library write the english text into chinese !!!

Perhaps because the library was written by the Chinese? Post a link to it.

PS. Why are there no Serial.print() statements in that snippet? Perhaps there would be a clue.

sorry for the missing info in my post
here is the link if the screen i use

and in the attachments is the library I use

and here is the method I am trying to use

FILERESULT SMARTGPU2::SDFwriteFile(char buffer[], NUMBEROFBYTES BTW, NUMBEROFBYTES *SWB,  WORKSPACEBLOCK objectWorkspaceNo){ //Bytes to Write, Succesfully Written Bytes, file object # to write bytes
  FILERESULT res;
  unsigned int x=0, sw=0;
 
  putcharTX('F');           //File function - memory card file management
  putcharTX('W');           //Write file
  putcharTX(objectWorkspaceNo); //object workspace number to write bytes 0-4    
  putcharTX(BTW>>8);
  putcharTX(BTW);    
  for(x=0;x<BTW;x++){
	putcharTX(buffer[x]);
  }

  ((unsigned char*)&sw)[1]=getcharRX();
  ((unsigned char*)&sw)[0]=getcharRX();

  *SWB = sw;                   //store succesfully written bytes   
  res = (FILERESULT)getcharRX(); //Get SD file execution status
  getcharRX();                   //Discard 'O' or 'F'
  return res;                      //Return SD file execution status
}

and the library is not written by Chinese , i guess there is a encoding issue here.
any suggestions?

SMARTGPU2.cpp (49.6 KB)