This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

file write and read in C6670

Hi,

I have an application runs on C6670 in which at the end of application i want to write my statistics to the file.

I am able to view the file related APIs but when i use the fopen it return NULL.

How to locate the file for file open?

Where file will be located and how can i view the file?

Thanks in Advance.

Regards,

K. Lakshmanan

  • Hi Lakshmanan,

    Can you paste here the code snippet of the file operation which you are doing?

    I guess its not able to open because its not able to locate where the file is exactly.

    Where exactly are you placing the file in your workspace ? If your file is placed in the workspace and not in any other folder inside the workspace, then try using this:

    if((fp = fopen("../filename","r"))!=NULL)

    If inside a folder name, then use:
    if((fp = fopen("../<folder_name/path>/filename","r"))!=NULL) 

    If its in some other place in the PC hard disk, then try giving the absolute path of that file.

    Its important to specify the exact path of the file for it to open.

    Hope this helps!

    Regards

    Sud

  • Hi Lakshmanan,

    Please follow the following code snippet for file open.

    File Read:

    	FILE * fpr = 0;
    	fpr = fopen("file.txt", "rb");
    
    

    File Write:

    	FILE * fpw = 0;
    	fpw = fopen("file.txt", "wb");

    Please refer Image Processing example source available in MCSDK.(mcip_master_main.c). I hope this helps.

    If the full path is not specified, the file will be created under project debug directory.

    Please download the latest MCSDK 02_01_02_06 from below link.

    http://software-dl.ti.com/sdoemb/sdoemb_public_sw/bios_mcsdk/latest/index_FDS.html

  • Lakshmanan,

    Would like to add one point. Depending on the location of the file.txt (whether inside the workspace or outside), we must provide the correct path for the file operations to work! ☺

    Regards

    Sud

     

  • Dear Sudharsan & Rajasekaran,

    I have created a folder for workspace and kept the file.txt(parallel to metadata and dvt). and gave the absolute path also  like "E:\file.txt "

    fp = fopen("E:\file.txt", "r");

    Still i am not able to open the file. fopen returns null pointer.

    Note: I am using C6670 EVM to execute this scenario.

     

    Thanks & Regards,

    K .Lakshmanan

  • Hi,

    Please check with the attached project files.

    7103.TestProgram.zip

    I have tested on C6678 EVM. Please change the target configuration file (ccxml) to connect with your target.

    Thanks.

  • Dear Rajasekaran,

    Thanks for your information. Its working. 

    I missed to place the text file inside debug folder.

     

    Thanks & Regards,

    K. Lakshmanan