Shop OBEX P1 Docs P2 Docs Learn Events
Using SparkFun OpenLog with Javelin Stamp to access an SD card — Parallax Forums

Using SparkFun OpenLog with Javelin Stamp to access an SD card

Paul RingPaul Ring Posts: 16
edited 2010-06-04 06:17 in General Discussion
Some times ago I posted a note regarding how to use Javelin Stamp with 4D Labs micro-DRIVE microSD OEM module. I remember when I started using the micro-DRIVE I found it quite difficult to use. That was because of the communication protocol which I later encapsulated in a driver which made the life much more easier. For you rather preferring an OpenSource alternative to micro-DRIVE module there is a much more cooler product out there from SparkFun called OpenLog. The source code is available http://github.com/nseidle/OpenLog. Since OpenLog is an OpenSource project you have the possibility to contribute to the development and if you have have ideas for improvement you can modify the code yourself, recompile and flash the firmware. The same approach with the micro-DRIVE module is not possible as the firmware is proprietary to 4D Labs.

Attached to this post there is a zip-file, Drivers.zip that contains the driver source code and a test program.
Please start by reading the README file.
In order to use the driver you will have to download the OpenLog source code version available at this location http://github.com/ringp/OpenLog using git.

* If you are running Windows you can install git from http://code.google.com/p/msysgit and then download the source code using git pull git://github.com/ringp/OpenLog.git.
* In Linux (Ubuntu) you can type: git pull git://github.com/ringp/OpenLog.git at the terminal. If you don't have git install it; sudo apt-get install git
* You can also download the source code as a zip file. Goto this page http://github.com/ringp/OpenLog and choose the option Download Source.

Instructions on how to flash the OpenLog module can be found http://wiki.github.com/nseidle/OpenLog/.

NOTE: The Javelin driver version attached to this post (in Driver.zip) will not be maintained. To ensure you have the latest version please download it from http://github.com/ringp/OpenLog.

Some examples on how to use OpenLog from Javelin

Listing files in current directory
FileInfo fileInfo;
if(openLog.[b]listDirectoryStart()[/b]) {
  int count = openLog.[b]listDirectoryCount()[/b];
  while ((fileInfo = openLog.[b]listDirectoryNextEntry()[/b]) != null) {
    <do something with fileInfo>
   }
}
openLog.[b]listDirectoryEnd()[/b];




Reading from file
if (openLog.[b]openFile([i]<file name>[/i])[/b]) {
  openLog.[b]setFilePosition([i]<file position>[/i])[/b];
  while (openLog.[b]readFile([i]<buffer>[/i], [i]<size>[/i])[/b]{
    <do something with the file data>
  }
  openLog.[b]closeFile()[/b];
}




Creating a directory
if (openLog.[b]createDir([i]<folder name>[/i])[/b]) {
  if (openLog.[b]changeDir()[/b]) {
    <do something here>
  }
}




Writing to file
openLog.[b]writeFile([i]<file name>[/i], [i]<file data>[/i], [i]<append>[/i])[/b]



More examples can be found in OpenLog.java file found in the Driver.zip file.

Post Edited (Paul Ring) : 6/6/2010 6:43:17 PM GMT
Sign In or Register to comment.