_io_fopen behaviour w.r.t extra information for device not as described by I/O user guide

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

_io_fopen behaviour w.r.t extra information for device not as described by I/O user guide

653 Views
dry
Senior Contributor I

MQX's I/O Drivers User Guide  (rev 24, 04/2015) p 39,  says that characters following the ":" are considered extra information for the device and passed to the device driver by fopen (which is = _io_fopen()).

But this is not how io_fopen does it, it just passes the entire string from open_type_ptr argument to the driver's IO_OPEN, so instead of passing it just "bob.txt" the whole string "mfs1:bob.txt." is passed.

0 Kudos
3 Replies

377 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi D.RY

The low level driver will parse these characters.

Let me take the flashx demo for example:  (Freescale_MQX_4_2\mqx\examples\flashx\build\iar\flashx_frdmk64f)

#define         FLASH_NAME "flashx:bank0"

    /* Open the flash device */
    flash_file = fopen(FLASH_NAME, NULL);   It will call_io_fopen, yes, the entire string "flashx:bank0" is passed to flashx driver,   _io_flashx_open.    In this function, the characters following ":" are parsed with below lines.

...

    while (*file_name_ptr++ != 0)
        open_name_ptr++; /* move to the file name */
    file_name_ptr = open_name_ptr; /* throw out value of file_name_ptr and assign the correct file name */

...

After this line, file_name_ptr will pointer to "bank0"

Next low level driver will handle this

Regards

Daniel

0 Kudos

377 Views
dry
Senior Contributor I

I must be misreading that user guide section then. My understanding of it was that, for _any_ device, not just flashx,  fopen (_io_fopen()) will strip out the device string name from the argument, and pass _only_ the rest of that string to the device's open().   So in "mfs1:bob.txt" , only "bob.txt" will get passed down ( the string before that is redundant, the driver knows what it is).

But that's not the case, as _io_fopen has this:

MQX_FILE_PTR _io_fopen
   (
      const char  *open_type_ptr,
      const char  *open_mode_ptr
   )
{

 .. // open_type_ptr is not modified before this call , so it's passed as is from _io_fopen

 result = (*dev_ptr->IO_OPEN)(file_ptr, (char *)open_type_ptr, (char *)open_mode_ptr);

...

}

I guess you saying this is correct behavior?  Apologies if I misread this.

0 Kudos

377 Views
danielchen
NXP TechSupport
NXP TechSupport

Yes,  you are right. open_type_ptr is paased as is from _io_fopen.  

Regards

Daniel

0 Kudos