FTP server file date

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,178件の閲覧回数
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.

ラベル(2)
0 件の賞賛
返信
1 解決策
969件の閲覧回数
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 件の賞賛
返信
2 返答(返信)
969件の閲覧回数
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 件の賞賛
返信
970件の閲覧回数
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 件の賞賛
返信