|
Team 3132 - Sample code for writing to a file on the cRIO
There's been a couple of threads about trying to write to a file on the cRIO (including one of my own), and even a request to see how we get it to work.
The code isn't heavily commented, but hopefully you can see what it's doing, as there's not much there.
So, here is code for writing to a log file on the cRIO, courtesy of Team 3132 - The Thunder Down under.
If you add the attached files to your code, you can then call it as follows:
* Get the logger instance through a call such as this..
Logger* logger = Logger::GetInstance();
* Add logging statements to your code as follows:
if (logger->IsLogging())
{
logger->Log(Logger::kINFO, "Bruce has initialised");
}
* The call to IsLogging() is optional, but is a hangover from my day job programming Java, where string creation is (used to be) expensive. Either way, if you have a large amount of code in your debugging, in order to calculate valued to log, but only at certain times, then best to surround it in a similar check so it's not calculated, but then never used.
When your code has finished, you can FTP to your cRIO (10.xx.yy.2) as anonymous (empty username and password) and download the file to your computer to read and analyse.
Standard disclaimers: I wrote it from scratch so I can distribute it, it's provided as is, I can't support you all, try it out if you like, don't blame me if it doesn't work for you, results may vary, handwash only, shrinkage may occur.
Hope this helps some of you.
__________________
FRC Team 111 - WildStang (Mentor, Drive Coach)
FTC Team 7458 - Full Force! (Mentor, Coach)
FRC Team 3132 - Australia's FIRST FRC Team! (Holy crazy first year, Batman!)
|