|
Re: help with file I/O on Crio ... unable to read file when fopen fails
Hi ... Thanks for the replies.
Here is our routine but it sounds like the "rt" - read text should not be a problem but we'll try the "r+" - read write and see if it helps.
The 'C' functions were quick and easy way to implement reading and parsing values from a file. Preference I guess, but we'll also try the C++ stream routines as well.
I thought maybe the way we referred to the file system using Windows "c:\" or Unix "/" would be a problem.
/* Reads values for potentiometer offset, etc.
* note: home_path is a char* path to the file in the cRIO root directory
* where the values should be stored. ("C:\some_file.txt")
*/
void read_vals(void)
{
pInFile = fopen(home_path, "rt");
if(pInFile == NULL)
{
printToDisplay("FILEPATH INCORRECT", 1, 1, LCD);
load_defaults();
return;
}
fscanf(pInFile, "potentiometer=%f\n", &test_var);
fclose(pInFile);
}
|