Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Data logging to internal memory (http://www.chiefdelphi.com/forums/showthread.php?t=74076)

JBotAlan 10-02-2009 15:07

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

Redneck 10-02-2009 16:35

Re: Data logging to internal memory
 
You should be able to just write a file to the cRIO using a regular fstream and retrieve it later via FTP.

slavik262 10-02-2009 18:51

Re: Data logging to internal memory
 
I created a class that provides as a wrapper to the standard C file i/o functions. I'll post it later tonight.

JBotAlan 10-02-2009 19:06

Re: Data logging to internal memory
 
Quote:

Originally Posted by Redneck (Post 818046)
You should be able to just write a file to the cRIO using a regular fstream and retrieve it later via FTP.

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...

Quote:

Originally Posted by slavik262 (Post 818117)
I created a class that provides as a wrapper to the standard C file i/o functions. I'll post it later tonight.

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

Thanks all,
Jacob

slavik262 10-02-2009 23:02

Re: Data logging to internal memory
 
2 Attachment(s)
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).

Chief Pride 12-02-2009 07:41

Re: Data logging to internal memory
 
Would it be possible to write to a USB stick in the drivers station with something like this?

JBotAlan 12-02-2009 09:16

Re: Data logging to internal memory
 
Quote:

Originally Posted by Chief Pride (Post 819165)
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

wt200999 12-02-2009 09:30

Re: Data logging to internal memory
 
Quote:

Originally Posted by JBotAlan (Post 819198)
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.

Quote:

Originally Posted by slavik262 (Post 818322)
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).

Can't you just use ofstream?

EricVanWyk 12-02-2009 09:37

Re: Data logging to internal memory
 
Quote:

Originally Posted by Chief Pride (Post 819165)
Would it be possible to write to a USB stick in the drivers station with something like this?

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

Chief Pride 12-02-2009 13:23

Re: Data logging to internal memory
 
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.

slavik262 12-02-2009 18:34

Re: Data logging to internal memory
 
Quote:

Originally Posted by wt200999 (Post 819206)
Can't you just use ofstream?

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

wt200999 12-02-2009 23:00

Re: Data logging to internal memory
 
Quote:

Originally Posted by Chief Pride (Post 819338)
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.

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

xtreampb 12-02-2009 23:28

Re: Data logging to internal memory
 
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 :/

wt200999 13-02-2009 00:04

Re: Data logging to internal memory
 
Quote:

Originally Posted by xtreampb (Post 819713)
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 :/

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


All times are GMT -5. The time now is 02:50.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi