MQX 4.2 Problem with finding a file on SDCard

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MQX 4.2 Problem with finding a file on SDCard

跳至解决方案
1,587 次查看
t_k
Contributor II

I was previously using MQX4.0 and my SDCard functions were all working fine.

We are trying to move to 4.2 and are finding a few issues we need to solve.

I need to be able to find a file on a SDCard, and the code used to work perfectly, but now it fails to find the file.

I'm able to create and write a separate file just fine after discovering not to flush the filesystem after writing.

Has the find file routine changed as well?

   MQX_FILE_PTR fs_ptr = NULL;

   char filepath[] = "b:\\file*.s19";

   MFS_SEARCH_DATA search_data;

   MFS_SEARCH_PARAM search;

   fs_ptr = _io_get_fs_by_name("b:");

   search.ATTRIBUTE = MFS_SEARCH_EXCLUSIVE;

   search.WILDCARD =  (char_ptr)&filepath;

   search.SEARCH_DATA_PTR = &search_data;

  

   if( ioctl( fs_ptr, IO_IOCTL_FIND_FIRST_FILE, (uint32_t *) & search ) == MFS_NO_ERROR )

   {

      DBG_INFO( "Upgrade files found, waiting 30s for upgrade request" );

   }

   else

   {

      DBG_INFO( "No upgrade files found" );

   }

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,291 次查看
RadekS
NXP Employee
NXP Employee

Hi Travis,

MFS in MQX4.2 was widely reworked in compare MFS in MQX 4.1.1

I tested your code at MQX 4.2 for file search at USB flash disk and it works correctly on my side.

Just be careful: You selected MFS_SEARCH_EXCLUSIVE, therefore result file has to be without any attributes.

When I created file in shell by command “write test1 500”, result file was with attribute ARCHIVE.

If you don’t care about attributes, please use MFS_SEARCH_ANY as parameter for search.ATTRIBUTE.

Archive.png

Could you please specify closer your doubts about file search function?

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,291 次查看
t_k
Contributor II

you're right.  Changing from MFS_SEARCH_EXCLUSIVE to MFS_SEARCH_ANY fixed the problem.  Since it had worked in 4.0 and 4.1, I never expected it to need to be changed for 4.2.

thanks,

Travis

0 项奖励
回复
1,291 次查看
RadekS
NXP Employee
NXP Employee

Hi Travis,

i am glad that it works now correctly.

Yes, it is possible that MFS in old version of MQX contained such bug and it was (unintentionally) fixed in reworked MFS code for MQX 4.2.

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
1,292 次查看
RadekS
NXP Employee
NXP Employee

Hi Travis,

MFS in MQX4.2 was widely reworked in compare MFS in MQX 4.1.1

I tested your code at MQX 4.2 for file search at USB flash disk and it works correctly on my side.

Just be careful: You selected MFS_SEARCH_EXCLUSIVE, therefore result file has to be without any attributes.

When I created file in shell by command “write test1 500”, result file was with attribute ARCHIVE.

If you don’t care about attributes, please use MFS_SEARCH_ANY as parameter for search.ATTRIBUTE.

Archive.png

Could you please specify closer your doubts about file search function?

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复