View Single Post
  #5   Spotlight this post!  
Unread 11-02-2013, 06:44
kenfox kenfox is offline
Registered User
FRC #3322 (Eagle Imperium)
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Ann Arbor, MI
Posts: 52
kenfox is a glorious beacon of lightkenfox is a glorious beacon of lightkenfox is a glorious beacon of lightkenfox is a glorious beacon of lightkenfox is a glorious beacon of light
Re: Printing to a text file

Quote:
Originally Posted by mrklempae View Post
So we can write to a text file
Yes.

Don't ignore smart dashboard though. I really think it will be better for you to try that first. Smart dashboard is useful for debugging, but can also be used during a competition match to show information on your driver station.

Quote:
we can't read it unless we FTP the file
Yes.

Quote:
we need to use the Preferences class to create and access it
No. You can use standard file I/O routines to open and write to files. We use C stdio which looks like this:

Code:
#include <stdio.h>
...
FILE *output = fopen("/3322-output.txt", "w");
if (output) {
  fprintf(output, "hello world\n");
  fclose(output);
}
The file written above can be viewed with a web browser by visiting "ftp://10.te.am.2/3322-output.txt".

C++ stream I/O routines should also work, but I haven't tried. Can you post some working code if you get C++ streams working?

Quote:
can we still do complex tasks with the data such as reading comma separated values into an array?
Yes.

The cRIO is an independent computer with its own files. The driver station is another independent computer. The cRIO and driver station use a limited network connection to communicate. If you want to share files between them you must copy them by FTP.

The only problem we've found using the cRIO file system with C is it will occasionally pause for up to 100ms to write data to permanent storage (flash storage). The C stdio routines I showed above buffer writes in memory. When the buffer fills up, it has to be written to permanent storage and that takes a long time.
Reply With Quote