FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Read/Write text file to cRIO for FRC

Hi

We need to store data on the cRIO non-volatile memory (flash ... I think) for later retrieval.  We are using the WPIlib in C++.

We have a test program that worked in windows and then ported it to a working cRIO robot program but the fopen is failing.  We've already copied a test.txt to the file system using FTP and it worked.

I think it may be because we are not using the correct root for the file system.  I assumed maybe incorrectly that it is not Windows "c:\" so we tried the unix " /test.txt" or the "file://" and "text.txt" but none have worked. We found something about a SetFileWriteAllowed but not sure if that is required. I've searched the other forums with some success but haven't found anyone indicating what the file path should be or if there are some permission requirements.

//sample ...

FILE  *pFile = fopen("text.txt", "rt");

if(pFile == NULL )

{printf("failed to open"); }

fscanf(pFile,"Offset=%f",&floatTest);

//and later we have something similar in order to write using fprintf

:

fprintf(pOutFile,"\nLabel_1=%d",floatTest);

Any ideas would be appreciated.

Thanks,

Carm

0 Kudos
Message 1 of 4
(6,346 Views)

When I use files on LabVIEW, I use windows style paths (c:\filename.txt).

0 Kudos
Message 2 of 4
(2,387 Views)

carm wrote:

I think it may be because we are not using the correct root for the file system.  I assummed maybe incorrectly that it is not Windows "c:\" so we tried the unix " /test.txt" or the "file://" and "text.txt" but none have worked. We found something about a SetFileWriteAllowed but not sure if that is required. I've searched the other forums with some success but haven't found anyone indicating what the file path should be or if there are some permission requirements.

Did you happen to try the Windows-style path?  I don't know about C++, but at least in LabVIEW you use Windows-style paths on RT systems such as the cRIO.  In LabVIEW, opening C:\test.txt works on the cRIO.

0 Kudos
Message 3 of 4
(2,387 Views)

Hi, Thanks for the replies.

Yes, we tried the "c:\\" today and the fopen still failed.  We also tried a single slash in case escaping the backslash wasn't required but still no luck. 

Good to have confirmaqtion that the "c:\" worked in labview indicating the cRIO flash works using that syntax and something else may be awry.  Still researching.  Thanks again.

0 Kudos
Message 4 of 4
(2,387 Views)