Using NXTDataLogger to write to a file on the NXT

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: roger, 99jonathan, imaqine

Using NXTDataLogger to write to a file on the NXT

Postby BlueHaze » Mon Feb 04, 2013 11:45 am

Hi all,

I would like to use the Logger class to write everyting to a CSV or TXT file on the NXT. I would like to log 7 integers per line. The caching mode seems perfect. If I understand correctly it will keep as much as possible in memory and clear the oldest when running out of space. Perfect ! When finnished I still need to write the cache to a file, so I think I need to stopLogging first and then use sendCache, but it seems that sendCache has 2 paremeters. A DataOutputStream and a DataInputStream. Why an inputstream ???

Does someone have an example that does something like this ? I browsed the internet and found examples to send the data via BT to the PC, but not one where it writes the cache to a logfile.

Here is a code snippet of what I was thinking :
Code: Select all
Logger xxLog = new NXTDataLogger ()  ;
xxLog.startCachingLog () ;
xxLog.setColumns (new LogColumn[] {
          new LogColumn ("C1", LogColumn.DT_INTEGER, false) ;
          new LogColumn ("C2", LogColumn.DT_INTEGER, false) ;
          new LogColumn ("C3", LogColumn.DT_INTEGER, false) ;
          ...
          new LogColumn ("C7", LogColumn.DT_INTEGER, false) ;
        });
     
// Start reading, displaying and logging data
while (! Button.ESCAPE.isDown ()) {
          [ some code .....]
         
          // write to Logger
          xxLog.writeLog (i1) ; xxLog.writeLog (i2) ; ... ; xxLog.writeLog (i7) ;
          xxLog.finishLine() ;
                   
          Delay.msDelay(250) ;
}
xxLog.stopLogging() ;
xxLog.sendCache ( NOT SURE WHAT GOES HERE ) ;


Your help is appreciated !

Kind regards,
BlueHaze
BlueHaze
New User
 
Posts: 2
Joined: Thu Dec 24, 2009 3:11 pm

Re: Using NXTDataLogger to write to a file on the NXT

Postby kirkpthompson » Tue Feb 05, 2013 2:06 pm

Hi.
I would like to use the Logger class to write everyting to a CSV or TXT file on the NXT.

I'm afraid that is not possible.

The NXTDataLogger class is used in conjunction with the NXT Charting Logger (NCL) desktop application (<Lejos home>/bin/nxjchartinglogger) to display and log data on your PC. The caching mode you are using will cache the logged data which is then sent (after logging what you want) to the NCL via the sendCache() method. You can also log data in "real-time" using the startRealtimeLog() method. The IO streams are both required for the NCL protocol.

There is the TestLogger sample in the samples area that is installed with LeJOS that shows how to use the NXTDataLogger class.

Aswin's blog has some good examples of the NCL output http://nxttime.wordpress.com/2011/08/25/the-imu-sensor-filter-part-ii/.

Best,
-K
Leg Godt!
User avatar
kirkpthompson
leJOS Team Member
 
Posts: 282
Joined: Wed Dec 05, 2007 1:27 am
Location: New Mexico, USA

Re: Using NXTDataLogger to write to a file on the NXT

Postby Aswin » Tue Feb 05, 2013 4:36 pm

Please note that the NCL does write the data to a file and it does allow you to copy the data to the paste buffer.
So if you need additional processing of your data this is easy.

Aswin
My NXT blog: http://nxttime.wordpress.com/
Aswin
Active User
 
Posts: 122
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

more stuff