Error in opening file non-standard file in PSoC 62 emFile system example

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
jayesh_joshi
Level 4
Level 4
50 replies posted 10 questions asked 25 sign-ins

Hi,

I am successfully able to run the example emFile_Filesystem  by importing it to ModusToolbox. 

I have tried the .txt and .log files and FS_FOpen does not return NULL. I assume open operation is successful. Now if I try to open .ico or .h264 file FS_FOpen  returns with NULL. Please find below the API for reference.  

Update : I have tried with flag "rb" but no success. 

inputFil = FS_FOpen(INPUT_FILE, "r");
if (inputFil == NULL)
{
       printf("Error opening input file");
}

Are there some flags that need to be given in Open API for opening files that are not text files? 

0 Likes
7 Replies
YuZh
Moderator
Moderator
Moderator
100 replies posted 10 likes received 50 sign-ins

Hi

You can use the error function to check what kind of problem type you encounter:

/*******************************************************************************
* Function Name: check_error
****************************************************************************//**
* Summary:
*  Prints the message and halts the execution by running an infinite loop, when
*  the error value is negative.
*
* Parameters: 
*  message - message to print if error value is negative.
*  error - error value for evaluation.
*
*******************************************************************************/
static void check_error(char *message, int error)
{
    if (error < 0)
    {
        printf("\n================================================================================\n");
        printf("\nFAIL: %s\n", message);
        printf("Error Value: %d\n", error);
        printf("emFile-defined Error Message: %s", FS_ErrorNo2Text(error));
        printf("\n================================================================================\n");
        
        while(true);
    }
}

If you use  MTB to generate example code, this function will include in main.c file.

 

Good Luck

zhichao

0 Likes
lock attach
Attachments are accessible only for community members.
jayesh_joshi
Level 4
Level 4
50 replies posted 10 questions asked 25 sign-ins

@YuZh 

Thanks for replying.

 

Getting an error code definitely would help but FS_FOpen does not return an error code.

I have again tried with clean code but with no success. I am attaching a sample code and file which I am trying to open for reference. Code has very minimal changes from MTB-generated code. Also, find setup detail.

Kit: PSoC Wifi BT Prototyping Kit 

Memory card: 8 GB sandisk 

Can you please run this at your end to help see if it is reproducible at your end as well?

 

 

 

0 Likes
YuZh
Moderator
Moderator
Moderator
100 replies posted 10 likes received 50 sign-ins

Hi:

Wait for moment, I will try to reproduce this phenomenon.

0 Likes
YuZh
Moderator
Moderator
Moderator
100 replies posted 10 likes received 50 sign-ins

Hi:

Could you tell me the size of h264? Maybe the h264 is too large to open it. You can minimize this file and try it again.

0 Likes
jayesh_joshi
Level 4
Level 4
50 replies posted 10 questions asked 25 sign-ins

@YuZh 

I have attached .h264 in form of .zip (simpltest.zip).  I have tried a similar size .txt file but then FS_FOpen does not return a null pointer. 

0 Likes
jayesh_joshi
Level 4
Level 4
50 replies posted 10 questions asked 25 sign-ins

@YuZh 

 

Have you got a chance to reproduce this issue? 

FYI, I have tried other file format that works for opening a file e.g. .hex, .jpeg. Even if I rename this file to .hex then also I don't get the NULL pointer so that should give some clue. 

Let me know if you need more information.  

0 Likes
YuZh
Moderator
Moderator
Moderator
100 replies posted 10 likes received 50 sign-ins

Hi:

I have reproduce this issue. I have the same outcome. Because lack of SD Card,  I used the NOR flash to try it. But I think this has nothing to do with which physical storage medium is used. We could not review the source code, so the following is my guess:

1. emFile doesn't support .h264 file list.  I guess that every time you call OPEN function, the code will iterate the file support list. Maybe the list never include the string: h264.

2. You can try to modify the file format to the text or others. May be you can open it and can read content successfully.  

3. This is not open source code,  and also I don't find any other information about support list of file.  So we just guess something and try it and verify it.

4. And also you can try some other open source file system, may be it will develop smoothly.

 

Good luck

 

zhichao

0 Likes