AnsweredAssumed Answered

Open / Close the Simple Memory Driver does not work

Question asked by nico engel on May 8, 2012
Latest reply on May 8, 2012 by nico engel

Hello,

 

I run the following code in an infinity loop. So I install the driver for memory only the first time. Then I open the file, read the io_controll and close the file.

This works well until the first loops (maybe this are 900 or 1000 calls of the loop).

 

But then I will get a NULL-pointer from function _io_fopen(). Does anyone know what is going wrong here?

 

By the way:  When I have a look to the source code of MQX-function _io_mem_close, I can see this function will do nothing than return MQX_OK. But I think this should not be the problem.

 

#define SIZE_OF_MEM        2000#define NAME_OF_DRIVE      "my:"uint32_t my_mem_init(void){    MQX_FILE_PTR    drive_p  = NULL;    static uint32_t mem_init_done   = 0;    uint32_t        size            = 0;    uint32_t        start_addr      = 0;    if ( mem_init_done == 0 )  {  if (_io_mem_install(NAME_OF_DRIVE, NULL, SIZE_OF_MEM) == MQX_OUT_OF_MEMORY)  {   printf("could not install drive\n");   return 1;  }  mem_init_done = 1;    }    //! Open the drive    drive_p = _io_fopen( NAME_OF_DRIVE, "r");    if ( drive_p == NULL )    {        printf("unable to open %s\n", NAME_OF_DRIVE);        return 1;    }    //!___check_________________________________________________________________    _io_ioctl(drive_p, IO_MEM_IOCTL_GET_TOTAL_SIZE,   &size);    _io_ioctl(drive_p, IO_MEM_IOCTL_GET_BASE_ADDRESS, &start_addr);    printf("drive installed: %u bytes @ addr. %x\n", size, start_addr);    //!___close_________________________________________________________________    _io_mem_close(drive_p);    return 0;}

 Thanks for help.

 

 

Outcomes