sdFat library error code need help

Can someone help me interpret the second error code? I think the first means

uint8_t const SD_CARD_ERROR_WRITE = 0X13

card returned an error token as a response to a write operation

Type any character to start
error: opening test.txt for write failed
SD errorCode: 0X13,0X8B

This card reads fine with the sdfat quickstart sketch but can't be written to with sdfat or SD wrapper library. It is an eye-fi wifi card:

http://www.eye.fi/products/prox2

Reading and writing are both fine on a PC.

The error 0X13 is (from Sd2Card.h):

/** card returned an error token as a response to a write operation */ uint8_t const SD_CARD_ERROR_WRITE = 0X13;

The error data, 0X8B is the returned token. From the SD specification

7.3.3.1 Data Response Token Every data block written to the card will be acknowledged by a data response token. It is one byte long and has the following format: 7 6 5 4 3 2 1 0 x x x 0 Status 1 The meaning of the status bits is defined as follows: '010' - Data accepted. '101' - Data rejected due to a CRC error. '110' - Data Rejected due to a Write Error

0X8B is a CRC error.

Most SD cards ignore CRC on data write in SPI mode but eye.fi cards can not be made to ignore CRC.

The Arduino has no hardware for CRC but SdFat can do software CRC. You can enable CRC by editing SdFatConfig.h . Change this define:

//------------------------------------------------------------------------------
/**
 * To enable SD card CRC checking set USE_SD_CRC nonzero.
 *
 * Set USE_SD_CRC to 1 to use a smaller slower CRC-CCITT function.
 *
 * Set USE_SD_CRC to 2 to used a larger faster table driven CRC-CCITT function.
 */
#define USE_SD_CRC 0

fat16lib,

Thank you! You saved my project! Does USE_SD_CRC 2 mean a larger table in SRAM for fast speed? I am using MEGA 2560 and should have plenty of memory for buffers.

BTW, the SD library that comes with arduino IDE doesn't have this capability, right?

The table is in flash so it won't use RAM.

SD.h does not support CRC.

fat16lib: The table is in flash so it won't use RAM.

SD.h does not support CRC.

Thank you again! Karma!

I've thought about switching from SD library to sdFat for quite some time. Time is now!

OK I am switching to SdFat library. It reminds me of the old DOS days. I used to know FAT12 and 16 and the 33MB partitions of DOS 3.3.

So to test if a file exists, can I do the following?

if (!imgFile.open(_f_name,O_READ))

Basically I'm trying to open a file name (with path) to read and expect it to bounce back with false if the file doesn't exist.

Basically I'm trying to open a file name (with path) to read and expect it to bounce back with false if the file doesn't exist.

Failure to open a file for read does not mean that the file doesn't exist. There is an exists() method that determines existence (which is separate from access permissions).

PaulS:

Basically I’m trying to open a file name (with path) to read and expect it to bounce back with false if the file doesn’t exist.

Failure to open a file for read does not mean that the file doesn’t exist. There is an exists() method that determines existence (which is separate from access permissions).

Thanks. That’s a very good point. I found that method and will see if it takes a file name with path.

Hi there, i'm kind of facing a problem using the sdFat library where im trying to implement it with a mp3 library. I'm a using the following libraries but i'm keep getting this error: " \arduino-1.0.5\libraries\SdFat/SdSpi.h:65: error: redefinition of 'const uint8_t SD_CHIP_SELECT_PIN' Arduino\libraries\SdFat/Sd2Card.h:139: error: 'const uint8_t SD_CHIP_SELECT_PIN' previously defined here

Can u please heeelpp meee :(

these r the libraries i;m using"

#include <SdFat.h>
#include <SD.h>
#include <Sd2Card.h>
#include <SdFatUtil.h>
#include <SdFile.h>
#include <SdInfo.h>
#include <SdSpi.h>
#include <SPI.h>
#include <SFEMP3Shield.h>
//SdFat sd;
SFEMP3Shield MP3player;
/** **/
// SDcard stuff
//MP3 stuff
// Below is not needed if interrupt driven. Safe to remove if not using.
#if defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_Timer1
#include <TimerOne.h>
#elif defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_SimpleTimer
#include <SimpleTimer.h>
#endif

You have two or more copies of SdFat.

This one appears to be in the correct place, the libraries folder in your sketch book.

Arduino\libraries\SdFat

This appears to be an older version in the wrong place.

\arduino-1.0.5\libraries\SdFat/

thanks for ur reply, i actually had 2 different folders of libraries but now when i settled the libraries thing, got these new errors :frowning: :frowning:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:1061: multiple definition of Sd2Card::setSckRate(unsigned char)' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:555: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::waitNotBusy(unsigned int)’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:1071: multiple definition of Sd2Card::waitNotBusy(unsigned int)' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:591: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::chipSelectLow()’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:764: multiple definition of Sd2Card::chipSelectLow()' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:220: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::cardCommand(unsigned char, unsigned long)’:
duino-1.0.5\libraries\SdFat/Sd2Card.cpp:695: multiple definition of Sd2Card::cardCommand(unsigned char, unsigned long)' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:162: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::chipSelectHigh()’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:758: multiple definition of Sd2Card::chipSelectHigh()' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:216: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::writeStop()’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:1198: multiple definition of Sd2Card::writeStop()' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:772: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::writeStart(unsigned long, unsigned long)’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:1172: multiple definition of Sd2Card::writeStart(unsigned long, unsigned long)' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:741: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::writeData(unsigned char, unsigned char const*)’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:1137: multiple definition of Sd2Card::writeData(unsigned char, unsigned char const*)' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:675: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::writeData(unsigned char const*)’:
Desktop\arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:1122: multiple definition of Sd2Card::writeData(unsigned char const*)' SD\utility\Sd2Card.cpp.o:C:\Users\100020246\Desktop\arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:664: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::writeBlock(unsigned long, unsigned char const*)’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:1090: multiple definition of Sd2Card::writeBlock(unsigned long, unsigned char const*)' SD\utility\Sd2Card.cpp.o arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:628: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::readRegister(unsigned char, void*)’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:989: multiple definition of Sd2Card::readRegister(unsigned char, void*)' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:524: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::eraseSingleBlockEnable()’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:822: multiple definition of Sd2Card::eraseSingleBlockEnable()' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:268: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::cardSize()’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:738: multiple definition of Sd2Card::cardSize()' SD\utility\Sd2Card.cpp.o arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:195: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::readBlock(unsigned long, unsigned char*)’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:925: multiple definition of Sd2Card::readBlock(unsigned long, unsigned char*)' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:422: first defined here SdFat\Sd2Card.cpp.o: In function Sd2Card::erase(unsigned long, unsigned long)’:
arduino-1.0.5\libraries\SdFat/Sd2Card.cpp:782: multiple definition of Sd2Card::erase(unsigned long, unsigned long)' SD\utility\Sd2Card.cpp.o:arduino-1.0.5\libraries\SD\utility/Sd2Card.cpp:236: first defined here SdFat\SdFile.cpp.o: In function SdFile::write_P(char const*)’:
arduino-1.0.5\libraries\SdFat/SdFile.cpp:72: multiple definition of SdFile::write_P(char const*)' SD\utility\SdFile.cpp.o:arduino-1.0.5\libraries\SD\utility/SdFile.cpp:1250: first defined here SdFat\SdFile.cpp.o: In function SdFile::writeln_P(char const*)’:
arduino-1.0.5\libraries\SdFat/SdFile.cpp:80: multiple definition of SdFile::writeln_P(char const*)' SD\utility\SdFile.cpp.o arduino-1.0.5\libraries\SD\utility/SdFile.cpp:1259: first defined here SdFat\SdFile.cpp.o: In function SdFile::write(char const*)’:
arduino-1.0.5\libraries\SdFat/SdFile.cpp:65: multiple definition of SdFile::write(char const*)' SD\utility\SdFile.cpp.o:arduino-1.0.5\libraries\SD\utility/SdFile.cpp:1240: first defined here SdFat\SdFile.cpp.o: In function SdFile::write(unsigned char)’:
arduino-1.0.5\libraries\SdFat/SdFile.cpp:55: multiple definition of SdFile::write(unsigned char)' SD\utility\SdFile.cpp.o:arduino-1.0.5\libraries\SD\utility/SdFile.cpp:1231: first defined here SdFat\SdFile.cpp.o: In function SdFile::write(void const*, unsigned int)’:
Desktop\arduino-1.0.5\libraries\SdFat/SdFile.cpp:47: multiple definition of SdFile::write(void const*, unsigned int)' SD\utility\SdFile.cpp.o:arduino-1.0.5\libraries\SD\utility/SdFile.cpp:1132: first defined here SdFat\SdVolume.cpp.o:arduino-1.0.5\libraries\SdFat/SdVolume.cpp:271: multiple definition of SdVolume::cacheBlockNumber_’
SD\utility\SdVolume.cpp.o:(.data.ZN8SdVolume17cacheBlockNumber_E+0x0): first defined here
SdFat\SdVolume.cpp.o:arduino-1.0.5\libraries\SdFat/SdVolume.cpp:271: multiple definition of SdVolume::sdCard_' SD\utility\SdVolume.cpp.o:arduino-1.0.5\libraries\SD\utility/SdVolume.cpp:100: first defined here SdFat\SdVolume.cpp.o:arduino-1.0.5\libraries\SdFat/SdVolume.cpp:271: multiple definition of SdVolume::cacheBuffer

SD\utility\SdVolume.cpp.o:arduino-1.0.5\libraries\SD\utility/SdVolume.cpp:100: first defined here
SdFat\SdVolume.cpp.o: In function SdVolume::init(Sd2Card*, unsigned char)': arduino-1.0.5\libraries\SdFat/SdVolume.cpp:496: multiple definition of SdVolume::init(Sd2Card*, unsigned char)’
SD\utility\SdVolume.cpp.o:arduino-1.0.5\libraries\SD\utility/SdVolume.cpp:227: first defined here
SdFat\SdVolume.cpp.o: In function SdVolume::fatPut(unsigned long, unsigned long)': arduino-1.0.5\libraries\SdFat/SdVolume.cpp:338: multiple definition of SdVolume::fatPut(unsigned long, unsigned long)’
SD\utility\SdVolume.cpp.o:arduino-1.0.5\libraries\SD\utility/SdVolume.cpp:167: first defined here
SdFat\SdVolume.cpp.o: In function SdVolume::freeChain(unsigned long)': arduino-1.0.5\libraries\SdFat/SdVolume.cpp:405: multiple definition of SdVolume::freeChain(unsigned long)’
SD\utility\SdVolume.cpp.o:
arduino-1.0.5\libraries\SD\utility/SdVolume.cpp:195: first defined here
SdFat\SdVolume.cpp.o: In function SdVolume::allocContiguous(unsigned long, unsigned long*)': arduino-1.0.5\libraries\SdFat/SdVolume.cpp:40: multiple definition of SdVolume::allocContiguous(unsigned long, unsigned long*)’
SD\utility\SdVolume.cpp.o:
\arduino-1.0.5\libraries\SD\utility/SdVolume.cpp:31: first defined here

You are including both the SD.h library which is a wrapper for an old version of SdFat and a new version of SdFat.

Remove this to use the new version of SdFat.

#include <SD.h>

Limit the number of include files. Most SdFat sketches only need this include.

#include <SdFat.h>

You may need this if you call FreeRam()

#include <SdFatUtil.h>

These are not needed.

#include <Sd2Card.h>
#include <SdFile.h>
#include <SdInfo.h>

This is only needed if you access SPI for a device other than the SD.

#include <SdSpi.h>

ok i did that but now i got this:

all3:24: error: 'File' does not name a type all3.ino: In function 'void SDcardSetup()': all3:63: error: 'SD' was not declared in this scope all3:69: error: 'DB' was not declared in this scope all3:69: error: 'SD' was not declared in this scope all3.ino: In function 'void PressButtonToPlay()': all3:179: error: 'SD' was not declared in this scope

Thanks btw for ur fast replies :D

You are using symbols from the SD.h library. Maybe you don’t want SdFat features.

Try using SD.h instead of SdFat.h

Where did you get the code you are using? If you have more problems contact the author of the code.

Just on a side not, that SD card you are using, does the Wifi capability work in the arduino shield, seems like a really neat idea.

pYro_65: Just on a side not, that SD card you are using, does the Wifi capability work in the arduino shield, seems like a really neat idea.

Yes it does. I am using the adafruit sd shield. The antenna must be in the end of the sd card that sticks outside the metal holder. It only transfers image files so there's no way to make it transfer text files for data logging. Also it has some minimal image size thing that it will not transfer images less than a certain size.

Can you just save the data to an image file extension ( .jpg, .png )? <<EDIT: just saw post above.
To beat the size, can you place a chuck of empty data in it, or does it go on dimensions?

If its dimensions, you could place a bitmap header reserving a block of data represented by the width and height, then fill in the blank pixel data with your logging.

Kind of similar to packing the data into a ‘packet’ for network transmission.

Possible. I didn't try though.

You were right, the Sdfat library already has SD included in it and I was using different definitions from both libraries and this was causing a problem :slight_smile: but now i variable problems which is as follows:
all3.ino:69:29: error: invalid suffix “_READ” on integer constant
all3.ino: In function ‘void SDcardSetup()’:
all3:70: error: could not convert ‘DB’ to ‘bool’
all3.ino: In function ‘void PressButtonToPlay()’:
all3:179: error: expected primary-expression before ‘.’ token

This is part of the code

//** /
bool debug = true;
char
words[100];
char
tracks[100];
int count = 0; // number of elements
// SDcard variables
SdFile DB; // file in sdCard (the database)
int CS = 9; // cable select for SD card
char DB_fileName = “try.txt”;
SdFat sd;

DB = DB.open(DB_fileName, 0_READ);
if (DB) {
// filling arrays (words, tracks)
while (DB.available()) { // for each 2 lines (2 words)
String myWord = “”; // we will fill this word char by char in the next loop
int temp = 0; // one charachter
while(DB.available()){
temp = DB.read();