Page 1 of 1

File system

Posted: Tue Dec 20, 2016 8:25 am
by SeeCwriter
I have run example program EFF-FPT on a MOD5441X, and it runs fine. But I'm trying to understand why/how the following snippet of code works.
In UserMain(), part of the initialization is this:

Code: Select all

   f_enterFS();

   // We now must also enter the file system for the FTP task
   OSChangePrio( FTP_PRIO );
   f_enterFS();
   OSChangePrio( MAIN_PRIO );
I understand that each task must call f_enterFS() in order to access the file system. What I don't understand is
why calling OSChangePrio() causes the following call to f_enterFS() to be part of the FTP Task, especially since the FTP
Task hasn't even been started yet. That doesn't happen until later on in the initialization process.

Also, does changing the priority for UserMain have to follow the FTP priority change? Could main's priority have been changed before changing FTP's?

In addition, as I'm going through the code for the example program, in function FTPD_SendFileToClient() (ftp_f.cpp) there are a
series of conditional compiles based on the type of device being accessed. All the conditional compile sections
have this same construct:

Code: Select all

#ifdef USE_MMC
   if ( strcmp( file_name, "_mmc" ) == 0 )
   {
      //iprintf( "Change to MMC.\r\n" );
      f_chdrive( MMC_DRV_NUM );
      return( FTPD_FAIL );
   }
#endif /* USE_MMC */
Every code section returns a fail code without testing the return of the change directory call. Is this correct?

Re: File system

Posted: Wed Dec 21, 2016 4:46 pm
by rnixon
My understanding is each task (and therefore each task priority) needs to have it's own path information for the file system. Otherwise task A could change the path for task B. I don't think the order matters for changing priorities, except for the fact if you switched the order of OSChangePrio() and called ftp last in usermain, usermain would be at the ftp priority (since usermain is actually a task). Seems like it would be better form to call the fs enter stuff for the ftp task after it was created though.

In regards to the send file function, those look like commands to me to make the file system change modes. In that case a file would not be sent, so maybe the fail return value is correct since a file was not sent? Not 100% sure though.

Always good to check return values. Examples tend to miss that sometimes. Does the example work?