Poll
Question: Help... Data Files ...
data files - 1 (100%)
create new - 0 (0%)
Total Voters: 0

Pages: 1 [2] 3 4 ... 6   Go Down
Author Topic: FileLogger  (Read 9270 times)
0 Members and 1 Guest are viewing this topic.
Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Marcoberri,

first, "buffer" is a pointer to a new assigned array of bytes. If you do this assignment:
Quote
buffer=msg;
you are trying to point "buffer" to the incoming "msg" array, so you would lose any reference to your array. Instead, you should copy any single char in the "msg" array to the "buffer" array:
Quote
for(int i=0; i<length;i++) {
   buffer = msg;
}

By the way, you better declare your "buffer" array as a char array, instead of byte array:
Quote
char buffer[length];

Hope this help,

Eduardo
Logged

Santhià - Vercelli - Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

it's ok! Thank You Very Much!!!

the final code:

Code:
void write_log(char msg[]){
 unsigned int length = (strlen(msg)+1);
  byte buffer[length];
  Serial.print(length);
  for(int i=0; i<length;i++)
    buffer[i] = msg[i];
  FileLogger::append(FILE_LOG, buffer, length);
  }
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm hoping to use FileLogger to store data from a weather station I'm building but I'm having some problems with it. I did have it working but now it's stopped and I can't figure out why. I could do with some help/suggestions please!

I'm using the FileLoggerDemo code:
Code:
// Title        : FileLogger library for Arduino, example code
// Author       : Eduardo García (egarcia@stream18.com)
// Date         : April 2009
// Id                  : $Id: FileLoggerDemo.pde 24 2009-04-23 22:45:13Z stream18 $
//
// DISCLAIMER:
// The author is in no way responsible for any problems or damage caused by
// using this code. Use at your own risk.
//
// LICENSE:
// This code is distributed under the GNU Public License
// which can be found at ...
//


#include "FileLogger.h"

// define the pin that powers up the SD card
#define MEM_PW 8

// variable used when reading from serial
byte inSerByte = 0;

#define MESSAGE "Hello, this is my message. Just testing the FileLogger library.\r\n"
unsigned long length = sizeof(MESSAGE)-1;
byte buffer[] = MESSAGE;

void setup(void) {
  pinMode(MEM_PW, OUTPUT);
  digitalWrite(MEM_PW, HIGH);
  Serial.begin(9600);
}

void loop(void) {
  char command = '0';
  unsigned long t1, t2;

  // Arduino expects one of a series of one-byte commands
  if (Serial.available() > 0) {
    int result;
    inSerByte = Serial.read();
    switch (inSerByte) {
      case 'W':
        result = FileLogger::append("data.log", buffer, length);
        Serial.print(" Result: ");
        if( result == 0) {
          Serial.println("OK");
        } else if( result == 1) {
          Serial.println("Fail initializing");
        } else if( result == 2) {
          Serial.println("Fail appending");
        }
      break;
    case 'T':
        for(int i=0; i<10; i++) {
            result = FileLogger::append("data.log", buffer, length);
              Serial.print(" Result: ");
              if( result == 0) {
                Serial.println("OK");
              } else if( result == 1) {
                Serial.println("Fail initializing");
              } else if( result == 2) {
                Serial.println("Fail appending");
              }
        }
          Serial.print("Done");
      break;
    }
  }
}

When I try to write to a file on an SD card by typing 'W' into the serial monitor I get ' Result: Fail initializing'. There is one file on the card, called data.log, and it has one character in it to initialise it.

The fact that I had it working before and haven't changed anything makes me think it might be a hardware problem. Is there any way of testing this?

I'm using an Arduino Duemilanove, a microSD board from Libelium and the latest version of the IDE.

Apologies if I've done something stupid but I'm completely new to all this!
Logged

Oviedo, Asturias
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Linstead,

just one suggestion: try to format your SD card again, then create the one-byte-file "data.log". Maybe there is nothing wrong with the hardware, but maybe there is a problem with the card.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi edugarcia,

Thanks for the suggestion. I've tried refomatting and making sure that the file is 1 byte, and I've tried other cards, but I still get the same problem.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I try to log some data of a GPS to a SD card. I am using the GPS code from the playground and some example code of FileLogger in this thread. Both GPS example and FileLogger example work, but my combined version does not.

Code:
#include <FileLogger.h>
 //#include <string.h>
 //#include <ctype.h>

 //int ledPin = 13;                  // LED test pin
 #define MEM_PW 8
 int rxPin = 0;                    // RX PIN
 int txPin = 1;                    // TX TX
 int byteGPS=-1;
 char linea[70] = "";
 char comandoGPR[7] = "$GPRMC";
 int bien=0;
 int conta=0;

 void setup() {
   //pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   //pinMode(MEM_PW, OUTPUT);
   //digitalWrite(MEM_PW, HIGH);
   pinMode(txPin, OUTPUT);
   Serial.begin(4800);
   for (int i=0;i<70;i++){       // Initialize a buffer for received data
     linea[i]=' ';
   }  
   Serial.println("Booting.... v2.0");
   write_log("Fail...");
   //delay(100);
   write_log("\n\nGPS RESET\n");
   //delay(100);
 }

 void loop() {
   byteGPS=Serial.read();         // Read a byte of the serial port
   if (byteGPS != -1) {
     Serial.print(byteGPS,BYTE);
     if(conta == 70){
       conta = 0;
     }
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     conta++;                      
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
       bien=0;
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
           bien++;
         }
       }
       if(bien==6){               // If yes, continue and process the data
         Serial.println("RMC DATA RECEIVED");      // ... and write to the serial port
         write_log(linea);
       }
       conta=0;                    // Reset the buffer
       for (int i=0;i<70;i++){    //  
         linea[i]=' ';            
       }                
     }
   }
 }



 void write_log(char msg[]){
  unsigned int length = (strlen(msg)+1);
  Serial.println(length);
  byte buffer[length];
  for(int i=0; i<length;i++)
    buffer[i] = msg[i];
  int result = FileLogger::append("data.log", buffer, length);
  if( result == 0) {
   Serial.println("OK");
  } else if( result == 1) {
   Serial.println("Fail initializing");
  } else if( result == 2) {
   Serial.println("Fail appending");
  } else {
   Serial.println("Unknown error");
  }
}

Result:
Quote
Booting....
8                  <-- (write_log("Fail...");)
Fail initializing
13                  <-- (write_log("\n\nGPS RESET\n");)
OK                  (sometimes Fail initializing)
----lots of GPS data----

The file on the card does contain some Testing2... but nothing more.

It only breaks when FileLogger::append("data.log", buffer, length); for writing the GPS string is called. The arduino reboots, repeats that a few times and stops completely.
Can somebody help me?
« Last Edit: June 08, 2009, 08:06:16 am by Jack75 » Logged

Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Jack75: did u manage to work it out?



I've managed to write data on my microSD using the Filelogger lib.
I'm working on a similar project like Jack75, i haven't tested yet FileLogger with the lib. i use to receive my GPS data..

Anyway, my question is: how can i read the Data saved on the microSD directly on Arduino in a variable?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am working on a diploma thesis with sensors (temperature and humidity) and data logging. I am working with the microSd card module from libelium. Do u know if there is a possibility to connect the module to the ICSP instead of pins 8-13??

Thanks and Congratz !! U have done great job here.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi developers,

i tried the example included in the arduino-filelogger lib and got this
error "Fail initializing." as I typed "W", which should add a few lines to data.log on the sd-card.

I am using Arduino16 and microSD over SPI. The card is connected with the standard spi pins on the arduino mini pro.


Thanks for help.

agitar


« Last Edit: July 15, 2009, 06:01:04 pm by agitar » Logged

Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Spiderman: It is possible, but you have to modify your module yourself i think.
My module is a little different than the one here: http://www.sensor-networks.org/index.php?page=0827727742

I'll take a pic in a couple of hours and post it here. According to the site, you can connect it to the ICSP but i havent tried it yet.


Agitar: I changed the code from the FileLogger lib scetch and i'm saving a string from a buffer array, in the microSD. heres my code:

Code:
#include "FileLogger.h"

// define the pin that powers up the SD card
#define MEM_PW 8

#define MESSAGE "Hello, this is my message. Just testing the FileLogger library.\r\n"
unsigned long length = sizeof(MESSAGE)-1;
byte buffer[] = MESSAGE;

void setup(void) {
  pinMode(MEM_PW, OUTPUT);
  digitalWrite(MEM_PW, HIGH);
  Serial.begin(115200);
}

void loop(void) {
    int result;
        result = FileLogger::append("hola.txt", buffer, length);
        Serial.print(" Result: ");
        if( result == 0)
        {
          Serial.println("OK");
        }
        else if( result == 1)
        {
          Serial.println("Fail initializing");
        }
        else if( result == 2)
        {
          Serial.println("Fail appending");
        }
    delay(2000);
}



I'll write later a small program to log my GPS data, on the microSD and i'll tell you how it went.
« Last Edit: July 16, 2009, 03:58:38 am by blank » Logged

Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh by the way, my libelium microSD module is connected to digital pins of my ArduinoBT, not to ICSP so  I dont know if this is any helpful.
« Last Edit: July 16, 2009, 03:58:06 am by blank » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello again,

it seems that this library works fine through ICSP connection, but it totally spoils my sensor code. In fact, it shows different temperature and humidity.
Could someone help please? Thank you!
Logged

Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think anyone can help you, if you don't provide more info..
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@blank: I tried your code:
Quote
Result: Fail initializing
 Result: Fail initializing
 Result: Fail initializing
 Result: Fail initializing
 Result: Fail initializing
 Result: Fail initializing

How can I test, whether the hardware configuration is ok?
The card is powered by 3.3 Volt. I measured it.

Or do you think this is a software problem?
Logged

Greece
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you try connecting it on the Digital pins?
Also check if any of your other libraries, those you have under arduino/hardware/libraries  contain the mmc or any of the other .h or .cpp that FileLogger uses and remove it from the libraries folder. There might be a conflict.
« Last Edit: July 16, 2009, 09:16:38 am by blank » Logged

Pages: 1 [2] 3 4 ... 6   Go Up
Jump to: