Data logging to internal memory

This is probably going to be a stupid simple answer, but I am away from the cRIO at the moment and won’t be back to it until tomorrow; bear with me.

How would I go about writing a small text file for logging purposes on the cRIO inside WindRiver? Can I just use fstream to write a file? Is there any provision inside WPILib that I should be using instead?

Jacob

You should be able to just write a file to the cRIO using a regular fstream and retrieve it later via FTP.

I created a class that provides as a wrapper to the standard C file i/o functions. I’ll post it later tonight.

Whoa! I didn’t know the cRIO has an FTP server! :cool: I assume it is on port 21 like a normal FTP server? I guess I’m not reading the right documents…

I would definitely be interested in having a peek; this could save me some time coding a similar structure for myself.

Thanks all,
Jacob

I’ve attached my class. I need to get some sleep right now, so I apologize for not providing full documentation, but the header file is commented well enough that you should get an idea of how it works fairly easily. The only note I’d like to make is that the read and write functions take pointers to the variables you are reading/writing to. Also, you can use the generic read/write functions to write c-style strings (char arrays). For the pointer to the data, provide the name of the array, dataItemSize should be sizeof(char), and itemCount should be however many characters you want to write. I apologize for lacking full string implementation. I plan on creating a WriteString function that takes a pointer to a null-terminated string later.

I hope this helps you out.

EDIT: I just noticed I left some typedefs and a definition in the header file that I needed when I tested this in Visual C++. Feel free to remove lines 6, 11, and 12 (the _CRT_SECURE_NO_WARNINGS #define and the typedefs).

FileStream.cpp (3.14 KB)
FileStream.h (2.38 KB)


FileStream.cpp (3.14 KB)
FileStream.h (2.38 KB)

Would it be possible to write to a USB stick in the drivers station with something like this?

I am 99.9% sure that the DS ports only will handle HID devices–joysticks and the like. It may be possible to do something like this with a custom circuit, but really I don’t think it’s worth it. I will just FTP into the cRIO to get the log file.

Though that idea is very cool…

Jacob

Well you do use a thumb drive to update the driver station, so the possibility of somthing like that getting implemented may not be far off.

Can’t you just use ofstream?

That sounds like a cool feature to add to the 2010 wishlist.

Well, I was thinking because the cRio already saves the images from the camera when processing, it would be cool to save them to the thumbdrive, then write a simple program to arrange the images in order and play them as a video after your match.

Yes, I could. I just prefer the C libraries to the C++ std namespace for certain things.

If I am not mistaken I did see some functions to save as AVI in the nivision.h…

well how much memory does the cRIO have??? My team would be sending snapshots to our laptop so the driver could tell where he is going but we have to limit our packet size so :confused:

the docs say 128MB of non-volatile memory and 64MB system memory.