FTP server file date

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FTP server file date

Jump to solution
623 Views
adyr
Contributor V

Hi,

I'm using MQX with KSDK 1.3 and I have created an FTP server that is saving files to an SD card with MFS. It is working except the date / time of files written to the SD card via FTP are always 1/1/1970 (viewed in the FTP client). I have the RTC running with the correct time so is there a way to integrate it with the MFS / FTP server so the corrected date is written to the file?

Thanks,

Adrian.

0 Kudos
1 Solution
414 Views
adyr
Contributor V

Thanks for the information Daniel.

While looking through the FTP / MFS code to see where I could place this I noticed that MFS already tries to write the date based on _time_get. Then it dawned on me that if I synchronised the systems tick with the real time it should all work. So I have now added the following to my start-up code:

//Synchronise systems clock to real time clock
rtc_datetime_t datetime;
RTC_DRV_GetDatetime( FSL_RTCTIMER1, &datetime );
DATE_STRUCT date;
TIME_STRUCT time;

date.YEAR = datetime.year;
date.MONTH = datetime.month;
date.DAY = datetime.day;
date.HOUR = datetime.hour;
date.SECOND = datetime.second;
date.MILLISEC = 0;
_time_from_date(&date, &time);
_time_set(&time);

I'm not sure if that is the most efficient way but it works and now the date/time of any files I create use the current real time.

Adrian.

View solution in original post

0 Kudos
2 Replies
414 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Adrian:

I think you can try the IO_IOCTL_SET_DATE_TIME command, this command sets the time and date of an open file.

Please refer to the section 3.8.1.25 of MFS user guide for more details

pastedImage_1.png

Regards

Daniel

0 Kudos
415 Views
adyr
Contributor V

Thanks for the information Daniel.

While looking through the FTP / MFS code to see where I could place this I noticed that MFS already tries to write the date based on _time_get. Then it dawned on me that if I synchronised the systems tick with the real time it should all work. So I have now added the following to my start-up code:

//Synchronise systems clock to real time clock
rtc_datetime_t datetime;
RTC_DRV_GetDatetime( FSL_RTCTIMER1, &datetime );
DATE_STRUCT date;
TIME_STRUCT time;

date.YEAR = datetime.year;
date.MONTH = datetime.month;
date.DAY = datetime.day;
date.HOUR = datetime.hour;
date.SECOND = datetime.second;
date.MILLISEC = 0;
_time_from_date(&date, &time);
_time_set(&time);

I'm not sure if that is the most efficient way but it works and now the date/time of any files I create use the current real time.

Adrian.

0 Kudos