Go Down

Topic: SD error (hijack) (Read 806 times) previous topic - next topic

SixtoD

when i used
Code: [Select]

#include <SPI.h>
//#include <SD.h>
#include <SdFat.h>
extern SdFat SD;

i get error msg
Error compiling for board Arduino/Genuino Uno.

AWOL

when i used
Code: [Select]

#include <SPI.h>
//#include <SD.h>
#include <SdFat.h>
extern SdFat SD;

i get error msg
Error compiling for board Arduino/Genuino Uno.
But you couldn't be bothered to post the code or the error message?

Is that approach working for you?
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

SixtoD

Code: [Select]
#include <SPI.h>
//#include <SD.h>
#include <SdFat.h>
extern SdFat SD;



File myFile;
File tempFile;
char cr;
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");
  // re-open the file for reading:
  myFile = SD.open("test.txt");
  tempFile = SD.open("temp.txt", O_WRITE | O_CREAT | O_TRUNC);

// skipped/blocked the first Line OPEN
      bool firstLine = true;
while (myFile.available()) {
  int c = myFile.read();
  if (firstLine) {
    if (c == '\n') {
      firstLine = false;
    }
  } else {
 
  Serial.write(c);
  tempFile.write(c);
  }

}
myFile.close();
tempFile.close();
 

   
// skipped/blocked the first Line CLOSED

loop();



  } //if(myFile) closing
  else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
// nothing happens after setup
}


just wanted to save all output to temp.txt, then i will delete the test.txt and rename the temp.txt to test..txt


Lucario448

just wanted to save all output to temp.txt, then i will delete the test.txt and rename the temp.txt to test..txt
I don't see like you were doing such thing.

SixtoD

I don't see like you were doing such thing.
just want to know how to use hehe
Code: [Select]
#include <SdFat.h>
extern SdFat SD;

I want to rename the temp.txt,
Ive search in this forum, they all say that the SdFat is the only solution to rename a file
but im getting an error msg "Error compiling for board Arduino/Genuino Uno."

PaulS

Quote
but im getting an error msg "Error compiling for board Arduino/Genuino Uno."
That message is the LAST message. We need to see your complete code AND ALL of the error messages.

You also need to explain why you have added the extern statement to the code.
The art of getting good answers lies in asking good questions.

SixtoD

Code: [Select]
#include <SPI.h>
//#include <SD.h>
#include <SdFat.h>
extern SdFat SD;



File myFile;
File tempFile;
char cr;
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");
  // re-open the file for reading:
  myFile = SD.open("test.txt");
  tempFile = SD.open("temp.txt", O_WRITE | O_CREAT | O_TRUNC);

// skipped/blocked the first Line OPEN
      bool firstLine = true;
while (myFile.available()) {
  int c = myFile.read();
  if (firstLine) {
    if (c == '\n') {
      firstLine = false;
    }
  } else {
 
  Serial.write(c);
  tempFile.write(c);
  }

}
myFile.close();
tempFile.close();
 

   
// skipped/blocked the first Line CLOSED

loop();



  } //if(myFile) closing
  else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
// nothing happens after setup
}


just wanted to save all output to temp.txt, then i will delete the test.txt and rename the temp.txt to test..txt


this is my whole code

and im getting this error msg when I used the extern SdFat
Code: [Select]
Error compiling for board Arduino/Genuino Uno."

PaulS

Quote
and im getting this error msg when I used the extern SdFat
That is not the only message, though.
The art of getting good answers lies in asking good questions.

SixtoD

#8
Sep 17, 2018, 06:31 pm Last Edit: Sep 17, 2018, 07:13 pm by SixtoD
sorry, i thought thats the only error message.
Code: [Select]

Desktop\blahblah\skip_first_line_and_write_to_temp_file__experiment\skip_first_line_and_write_to_temp_file__experiment.ino:3:19: fatal error: SdFat.h: No such file or directory

 #include <SdFat.h>

                   ^

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.



Lucario448

The library's folder isn't placed in the correct location. This locaton is: "Documents" folder>Arduino>libraries

Go Up