djuseeq / Ch376msc

Arduino library for CH376 mass storage contoller
MIT License
71 stars 17 forks source link

File Creation date wrong #30

Closed gcharles81 closed 4 years ago

gcharles81 commented 4 years ago

Hello Thanks for this library I am using it in my Aquarium controller project but I have an issue on teh creation date of the files created on the USB somehow the date shows always 31.12.2003 time 23.00 is there a reason for that ?

Thanks Charles CH736Scapture

djuseeq commented 4 years ago

Hi Charles. I'm glad you can use it, thanks for the star. The default date/time it should be 2004-jan-1, 0h.0m.0s . What is the process during creating the RTCLOG.TXT file? First create and save the file,after set the file name again and open it, using the setYear, setMonth ... functions set the actual date/time, after call saveFileAttrb function and finally close the file. Actually with these functions you change the file "last modified time and date" attributes. Maybe i will add a possibility to choose between create and modified date attributes to change.

gcharles81 commented 4 years ago

Hello Thanks for the Answer , so the solution to that is to use the below functions at startup and always update those with Today`s date ? I have RTC so I can keep thoose updated or I have to update before editing any file ?

      flashDrive.setYear(2019);
      flashDrive.setMonth(12);
      flashDrive.setDay(19);
      flashDrive.setHour(03);
      flashDrive.setMinute(38);
      flashDrive.setSecond(42);
djuseeq commented 4 years ago

If the file doesn't exist on the drive then first you create it, if there is some data then write it, close the file with this you will create the file on the drive setFileName(FILENAME); openFile(); writeFile(data, length); closeFile(); this will create the file with the default date 2004-jan-1, 0h.0m.0s and then open again the file and modify the date setFileName(FILENAME); openFile(); get the date/time from RTC and use the set functions ; saveFileAttrb(); after these you can close the file or continue to add a next line of data and close it afterwards moveCursor(CURSOREND); writeFile(data, length); closeFile();