MQX 4.2 Problem with finding a file on SDCard

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

MQX 4.2 Problem with finding a file on SDCard

Jump to solution
801 Views
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" );

   }

Labels (1)
Tags (1)
0 Kudos
1 Solution
505 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
3 Replies
505 Views
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 Kudos
505 Views
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 Kudos
506 Views
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 Kudos