Code Monkey home page Code Monkey logo

sdfat's Introduction

File copy constructors and file assignment operators have been made private by default in 2.2.3 to prevent call by value and multiple copies of file instances.

SdFatConfig.h has options to make file constructors and assignment operators public.

UTF-8 encoded filenames are supported in v2.1.0 or later.

Try the UnicodeFilenames example. Here is output from ls:

Type any character to begin
ls:
         0 😀/
          20 россиянин
          17 très élégant
           9 狗.txt

SdFat Version 2 supports FAT16/FAT32 and exFAT SD cards. It is mostly backward compatible with SdFat Version 1 for FAT16/FAT32 cards.

exFAT supports files larger than 4GB so files sizes and positions are type uint64_t for classes that support exFAT.

exFAT has many features not available in FAT16/FAT32. exFAT has excellent support for contiguous files on flash devices and supports preallocation.

If the SD card is the only SPI device, use dedicated SPI mode. This can greatly improve performance. See the bench example.

Here is write performance for an old, 2011, card on a Due board.

Shared SPI:
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
294.45,24944,1398,1737

Dedicated SPI:
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
3965.11,16733,110,127

The default version of SdFatConfig.h enables support for dedicated SPI and optimized access to contiguous files. This makes SdFat Version 2 slightly larger than Version 1. If these features are disabled, Version 2 is smaller than Version 1.

The types for the classes SdFat and File are defined in SdFatConfig.h. The default version of SdFatConfig.h defines SdFat to only support FAT16/FAT32. SdFat and File are defined in terms of more basic classes by typedefs. You can use these basic classes in applications.

Support for exFAT requires a substantial amount of flash. Here are sizes on an UNO for a simple program that opens a file, prints one line, and closes the file.

FAT16/FAT32 only: 9780 bytes flash, 875 bytes SRAM.

exFAT only: 13830 bytes flash, 938 bytes SRAM.

FAT16/FAT32/exFAT: 19326 bytes flash, 928 bytes SRAM.

The section below of SdFatConfig.h has been edited to uses FAT16/FAT32 for small AVR boards and FAT16/FAT32/exFAT for all other boards.

/**
 * File types for SdFat, File, SdFile, SdBaseFile, fstream,
 * ifstream, and ofstream.
 *
 * Set SDFAT_FILE_TYPE to:
 *
 * 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
 */
#if defined(__AVR__) && FLASHEND < 0X8000
// FAT16/FAT32 for 32K AVR boards.
#define SDFAT_FILE_TYPE 1
#else  // defined(__AVR__) && FLASHEND < 0X8000
// FAT16/FAT32 and exFAT for all other boards.
#define SDFAT_FILE_TYPE 3
#endif  // defined(__AVR__) && FLASHEND < 0X8000

The SdBaseFile class has no Arduino Stream or Print support.

The File class is derived from Stream and SdBaseFile.

The SdFile class is derived from SdBaseFile and Print.

Please try the examples. Start with SdInfo, bench, and ExFatLogger.

To use SdFat Version 2, unzip the download file, rename the library folder SdFat and place the SdFat folder into the libraries sub-folder in your main sketch folder.

For more information see the Manual installation section of this guide:

http://arduino.cc/en/Guide/Libraries

A number of configuration options can be set by editing SdFatConfig.h define macros. See the html documentation File tab for details.

Please read the html documentation for this library in SdFat/doc/SdFat.html. Start with the Main Page. Next go to the Classes tab and read the documentation for the classes SdFat32, SdExFat, SdFs, File32, ExFile, FsFile.

The SdFat and File classes are defined in terms of the above classes by typedefs. Edit SdFatConfig.h to select class options.

Please continue by reading the html documentation in the SdFat/doc folder.

sdfat's People

Contributors

greiman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdfat's Issues

ADC drop outs with AnalogBinLogger

Hi,

first of all I have to admit that I did not grasp from the code how you got the adc values at all. I tried to use your library as a fast and cheap alternative for those very expensive digital data logger devices. What I've done is using your example out of the box with an UNO (and a Mega 2560) together with an Adafruit Logging Shield to log a (working) serial connection. Logging 5000 Samples per second worked well at first glance. However I could not completely reconstruct the data sent using the log file. Sometimes a high signal was simply missing. Curiously there were longer series of zero values recorded from time to time, while the program stated no error. Occasionally such an event happened when there was data to transmit.

It seems to me that the data aquisition is broken. Reproduction should be easy as this happened with a standard setup. Enclosed some data samples that illustrate the frequency of such events. The red lines are adc readings that are exactly zero for more than one bit (1200 baud at 5000 samples).

Hopefully you can fix this, because it breaks the purpose of the logger.

Best regards,
cmteuffel

pin0
pin0err
pin0detail1
pin0detail2

ESP8266 issue

Hi I use latest git version of SdFat with my ESP8266 and got error when trying to download "big" files.
File 451B is ok but with 174KB and up I got this :

Panic C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266\core_esp8266_main.cpp:98 __yield

ctx: sys 
sp: 3ffffbc0 end: 3fffffb0 offset: 01b0

>>>stack>>>
3ffffd70:  00000003 0140b7be 00000000 00000000  
3ffffd80:  3ffed7ee 1c01a8c0 00000003 4021b0bd  
3ffffd90:  3fff0b80 3fff09c0 3fff09e4 40217735  
3ffffda0:  3fff0b80 3fff09bf 3fff09e4 00000000  
3ffffdb0:  00000000 00000011 3fff09e4 402178b1  
3ffffdc0:  00007653 00000001 3fff09e4 402176d3  
3ffffdd0:  00000000 3fff07c0 3fff09e4 40217aad  
3ffffde0:  4023ab43 00007653 3fff07b4 40208043  
3ffffdf0:  00000000 00007653 3fff07b4 40217210  
3ffffe00:  3fff2000 00000001 00000001 402162d8  
3ffffe10:  00000001 3ffffe40 00000013 3fff27c0  
3ffffe20:  3fff27c4 3fff52cc 3fff27bc 000005b4  
3ffffe30:  3fff5fe4 3fff1ff0 3fff1ff0 40208b54  
3ffffe40:  0000002e 3ffeacb9 00000001 4010068c  
3ffffe50:  3fff2e7c 00000000 3fff1ff0 40219fa7  
3ffffe60:  3fff109c 000004f0 000003c8 40219feb  
3ffffe70:  3fff514c 3fff27c8 3fff514c 3fff27bc  
3ffffe80:  3fff52cc 000005b4 3fff53ac 40211c37  
3ffffe90:  3fff514c 000005b4 3fff523c 40211de7  
3ffffea0:  40230000 3fff52d0 3fff52cc 3fff27bc  
3ffffeb0:  3fff52cc 3fff27c4 3fff523c 40211f14  
3ffffec0:  3ffeb698 c162de08 3fff27c0 40211f34  
3ffffed0:  3fff52cc 3fff27c4 3fff27c0 4023b059  
3ffffee0:  00000000 1c01a8c0 00000010 00000000  
3ffffef0:  00000000 00000010 00000102 401075f8  
3fffff00:  40240000 00000000 0000007d 3fff2864  
3fffff10:  3ffed7da 3fff286c 3fff5414 40239479  
3fffff20:  3fff26b8 3fff2e7c 3fff2e7c 3ffefb30  
3fffff30:  00000000 3fff5414 0000001c 3fff2e7c  
3fffff40:  3ffed7cc 00000000 3fff5414 40238875  
3fffff50:  8701a8c0 3ffeadb4 00dcec39 00000000  
3fffff60:  40104b62 00dcec39 3fff0180 60000600  
3fffff70:  40241b9c 3fff0158 3fff0180 10e0b48f  
3fffff80:  40241bc2 3fffdab0 00000000 3fff2edc  
3fffff90:  3fffdc80 00000000 3fff5414 402417bf  
3fffffa0:  40000f49 3fffdab0 3fffdab0 40000f49  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,7)


 ets Jan  8 2013,rst cause:4, boot mode:(1,7)

wdt reset

Using https://github.com/tannewt/SdFat fork, which is pre-SDFat-Beta and has some patch for ESP8266, this issue does not happen, I can even download 10M files, but tannewt one crash when using clustercount functions:

uint32_t volTotal = SD.vol()->clusterCount();
uint32_t volFree = SD.vol()->freeClusterCount();

when yours do not, even answer is slow there is no watchdog issue.

I have applied same patch @tannewt did on his fork to your git version but this did not help.

Anything I can do to help to debug this issue ?

Thanks
I add decoded
image

Sdfat csv write string

Is it actually possible to input a variable string to write in the csv? can't find a way to replace
sdout << F(
"line 1,1,2.3,4.5\n"
"line 2,6,7.8,9.0\n"
"line 3,9,8.7,6.5\n"
"line 4,-4,-3.2,-1\n") << flush;

with an actual String test= "line 1,1,2.3,4.5\n";

SoftwareSPI Write keeps overwriting

Hi,
I tried to use Software SPI to log data from other Hardware SPI devices.
One thing keeps annoying me is that the write/print function will keep overwriting. Therefore, only thing I've got was the last data.
Do you know how to solve it?
I tried to use another file as temp but not working.

Looking forwards to your reply.

Slow reading of free space

I'm checking free space of SD card (Sandisk, 64G, formatted by official SD formatter):

 uint32_t freeSpace = SD.vol()->freeClusterCount() * SD.vol()->blocksPerCluster();

This line takes 54s to finish. Is this normal? I'm using RFduino with SDfat (SPI of RFduino has been rewritten to work with SdFat).

For the modification of SPI class of RFduino, I simply added a class for SPISettings (note that it is not actually used, just a placeholder):

class SPISettings {
	// placeholder so that SdFat could be used
  public:
	SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {
	};
	SPISettings() {
	};
};

Then added beginTransaction and endTransaction that actually called the default begin and end of RFduino:

	inline void beginTransaction(SPISettings settings) {
		begin();
	};
	inline void endTransaction(void) {
		end();
	};

And after this, SdFat works on RFduino, and I was able to write to SD card!

My concrete question is that: is the slow speed due to incomplete porting of SPI.h, or due to parameters: Rfduino SPI default frequency is set to 4MHz (but is 4000 in the code)?

Port for esp8266

what would it take to port this to esp8266 ?

https://github.com/esp8266/arduino

just wondering if it's not to work you could do it or I could do it.
but no ideas where to start to port it.

currently compiling bench.ino gives a lot of undefined reference's.

Case sensible file name

Hello,
Why file names (now long one) are not case sensible.
Are there any possibility: a boolean or function, to have a case sensible library.
Very useful when you upload file on the SD card from WiFi (ESP8266).
Thanks a lot

Library documentation ( html pages )

Hi ! thanks for your job,
I just want to bring my idea to improve a little thing that is not very important.

This is not really an issue, but it could be interesting to have a new branch, using github fonctionnalities, such as gh-page that allow you to put web content available on greiman.github.io/SdFat/ for example.

Why it could be interesting ? The documentation is currently in an "html" folder and can be moved or duplicated to a gh-pages branch. By doing this the documentation can be pushed online and always be up to date.

Having this pages online is a lot more practical than having them somewhere in the developper hard disk.

Thank in advance.
Ps : Sorry for my very bad english, this is not my native language, I am french....

Clearing the library's cache

Hello!

I've integrated the SdFormatter example into my program. It does the following:

  1. Print the root directory files, where there are 3-4 files.
  2. Format the SD.
  3. Print the root directory files again. At this moment no files should be shown, since the SD has been formatted, but instead the same list as in the first step is shown, I think because a cache issue.
  4. Repeat step 3. At this moment the cache has been flushed internally and the listing prints no files (correct).

So my question is - is there a way to force clear the SD library internal cache?

Thanks for your great job!

'ostream& endl(ostream&)' redeclared as different kind of symbol

Another Eclipse user here with SAM3X8E (DUE).
An issue I struck when including an often used library, streaming.h, which defines endl, as does iostream as part of SDFat.

Streaming library: http://arduiniana.org/libraries/streaming

Previous declaration of '_EndLineCode endl' error occurs at line Streaming.h line: 100
enum _EndLineCode { endl };

and iostream at line: 40
inline ostream& endl(ostream& os) {

To get error, simply include streaming.h with SdFat.h.

Any thoughts, I guess there would be a few users of Streaming.h by Mikal Hart.

Licenses missing in SdFat/examples

Hello, I noticed that all the arduino sketches in SdFat/examples and SdFatTestSuite/examples have no license at all. Please license these under the GNU GPLv3 like the SdFat library.
Thanks.

can't remove an empty file in some case

Hi, surprising is not possible to remove an empty file, for example created as follows:

$ touch /pathToSD/Q0000000.QLS
$ umount /pathToSD

and then:

void setup() {
  while(!Serial.available());
  while(Serial.available()) Serial.read();

  SdFat sd = SdFat();
  sd.begin(SD_CS, SPI_FULL_SPEED);

  if (sd.remove("Q0000000.QLS")) {
    Serial.println("remove ok"); // is always true!!!
  } else {
    Serial.println("remove fail");
  }
}
void loop() {}

is amazing!, but if this method is unprivatized, make possible this:

void setup() {
  while(!Serial.available());
  while(Serial.available()) Serial.read();

  SdFat sd = SdFat();
  sd.begin(SD_CS, SPI_FULL_SPEED);

  if (sd.remove("Q0000000.QLS")) {
    Serial.println("remove ok"); // is always true!!!
  } else {
    Serial.println("remove fail");
  }

  {// some like flush SdFat
    sd.card()->chipSelectLow();
    sd.card()->waitNotBusy(SD_WRITE_TIMEOUT);
    sd.card()->chipSelectHigh();
  }
}
void loop() {}

this code remove the file, can some like flush() or end() be necessary to SdFat?

PD: if the file name is lower case or more length it work flawlessly...

Wierd Issue observed when reading files with filenames of 13 with same name as a subfolder in the volume working directory.

Hi Bill,

I've been using your excellent sdFat Library (beta version for sdioEx downloaded from your github last week) to access the builtin memory card on a Teensy 3.6 and it works very well indeed. I'm working with this for integration with a TFT display so I've to read bmp's from time to time and I use the function attached to read the bmp's. I've made a slight alteration to the function from original source just to omit colors below certain threshold, i.e. similar to allowing for a transparent background which I find useful.

sampe_code.txt

Now to the issue I'm experiencing with the sdFat library. The attached bmpDraw function appears to work excellently with your library. It is capable of opening and reading all information required from 24bit bmp's with either short or long filenames and I've verified both. However, I've come across a strange exception whereby the file isn't reading correctly and I really hope you can help me out which. It occurs under fairly specific conditions as follows.

  1. Only occurs when working with a file with a long filename, i.e. abcdefghijkl.bmp
    works fine but abcdefghijklm.bmp doesn't read correctly.
  2. Only occurs when a sub-folder of the same name as the the bitmap I'm trying to access exist together within the same working directory.

The failure is occurring when trying to read the first few bytes in the file just after opening it with the statement:
if (read16(bmpFile) == 0x4D42) // BMP signature
This condition isn't satisfied and so the bmpDraw function is bypassed. Again I note is was perfectly satisfied with the exact same file when no folder of the same name exists in the working directory, or if the filename length is reduced by one character and a folder with the same name exists.

This is all a bit weird for me and I'm banging my head off a brick wall at this stage but can't seem to find any possible causes, any idea's, possible causes, suggestions would be much appreciated.

Regards,
Pat

openNext is always false help

So im trying to list all the files on the SD card to a LCD screen, and the function openNext always returns false. Im unable to figure it out, so here are pieces of the relevant code.

include <SdFat.h>

SdFat sd;
SdFile sdFile;
SdVolume sdVol;
Sd2Card MyCard;

char cname[9];
String fileName;

int counter = 16;
while(sdFile.openNext(sd.vwd(),O_READ))
{
sdFile.getFilename(cname);
sdFile.close();
fileName = String(cname);
lcd.print(fileName,LEFT,counter);
counter += 16;

}

read file after restart esp8266

this issue appearing only when esp8266 device restarted without card power off and disappear when card reinserted before device restarting
i suppose it can depend of USE_MULTI_BLOCK_IO option enabled
project compiled with https://github.com/esp8266/Arduino 2.3.0 (with embeded library it works properly)
and used https://github.com/esp8266/Arduino/blob/2.3.0/libraries/ESP8266WiFi/src/WiFiClient.h#L76
write function which request from sd card blocks with size:
#define WIFICLIENT_MAX_PACKET_SIZE 1460
i will try to disable this option USE_MULTI_BLOCK_IO manually and test project again

attached file has first 512 bytes correct - then trash (it changes every time when i reload page) - then everything repeated
image

SOLVED : SD fat on Software SPI not compiling on MightyCore 1284p

At the outset thank you for providing SDFat. I am currently using a MightyCore for 1284P and have successfully tested a SD card using your library on the 1284P running at 3.3V on a external 8MHz crystal on a breadboard using hardware SPI.
However when I used the code provided by you for SoftwareSPI (provided actually for 2560) my code first does not compile at all. and gives an error as below :

In file included from F:\arduino-1.8.2\portable\sketchbook\libraries\SdFat\src/SdSpiCard/DigitalPin.h:45:0,
from F:\arduino-1.8.2\portable\sketchbook\libraries\SdFat\src/SdSpiCard/SoftSPI.h:31,

             from F:\arduino-1.8.2\portable\sketchbook\libraries\SdFat\src/SdSpiCard/SdSpi.h:235,

             from F:\arduino-1.8.2\portable\sketchbook\libraries\SdFat\src/SdSpiCard/SdSpiCard.h:29,

             from F:\arduino-1.8.2\portable\sketchbook\libraries\SdFat\src/SdFat.h:27,

             from F:\arduino-1.8.2\portable\sketchbook\Series2_Tx\DumpInfo\DumpInfo\SDSPI1284\SDSPI1284.ino:7:

F:\arduino-1.8.2\portable\sketchbook\libraries\SdFat\src/SdSpiCard/boards/GpioPinMap.h:40:2: error: #error Undefined variant 1284, 644, 324
#error Undefined variant 1284, 644, 324

I have not got this error when using other libraries on 1284P.

Finally I got the code to compile without errors by commenting out everything in GpioPinMap.h and adding the line #include "BobuinoGpioPinMap.h" as I am using the Bobuino pinout. After uploading, I realized my card is not recognized.

I need to use SoftwareSPI as my RC522 with the SD card if both are attached to the same SPI bus.

Kindly provide me with help as to why it does not compile in the first place without modifying Gpio header file and also why it doesnt recognize my card

I am using a SD fat library which says #define SD_FAT_VERSION 20160719
The Mighty Core is also recent I believe as I am using the IDE version 1.8.2 and downloaded it using Boards Manager. I am using Mighty Core MCUdude version 1.0.8

Please help. My code is the same as on this site with pins modified as below :

// An example of the SdFatSoftSpi template class.
// This example is for an Adafruit Data Logging Shield on a Mega.
// Software SPI is required on Mega since this shield connects to pins 10-13.
// This example will also run on an Uno and other boards using software SPI.
//

#include "SdFat.h"
#include <SPI.h>

#if SD_SPI_CONFIGURATION >= 3 // Must be set in SdFat/SdFatConfig.h
//
// Pin numbers in templates must be constants.
const uint8_t SOFT_MISO_PIN = 6;
const uint8_t SOFT_MOSI_PIN = 5;
const uint8_t SOFT_SCK_PIN = 7;
//
// Chip select may be constant or RAM variable.
const uint8_t SD_CHIP_SELECT_PIN = 10;

// SdFat software SPI template
SdFatSoftSpi<SOFT_MISO_PIN, SOFT_MOSI_PIN, SOFT_SCK_PIN> sd;

// Test file.
SdFile file;

void setup() {
Serial.begin(9600);
// Wait for USB Serial
while (!Serial) {
SysCall::yield();
}
Serial.println("Type any character to start");
while (!Serial.available()) {
SysCall::yield();
}

if (!sd.begin(SD_CHIP_SELECT_PIN)) {
sd.initErrorHalt();
}

if (!file.open("SoftSPI.txt", O_CREAT | O_RDWR)) {
sd.errorHalt(F("open failed"));
}
file.println(F("This line was printed using software SPI."));

file.rewind();

while (file.available()) {
Serial.write(file.read());
}

file.close();

Serial.println(F("Done."));
}
//------------------------------------------------------------------------------
void loop() {}
#else // SD_SPI_CONFIGURATION >= 3
#error SD_SPI_CONFIGURATION must be set to 3 in SdFat/SdFatConfig.h
#endif //SD_SPI_CONFIGURATION >= 3

The error I get is :

Type any character to start
Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X1,0X0

ESP8266 WIMOS pins

Dear developper,
I try to use the SdFat with a ESP8266 Wimos D1 and the SD Card at the same format.
The connexion pins used for this card is the following:

D5 = GPIO14 = SCK // SD reader
D6 = GPIO12 = MISO // SD reader
D7 = GPIO13 = MOSI // SD reader
D8 = GPIO15, 10k Pull-down = SS // SD reader
I don't see any mean to define this pins to be used for the SdFat lib.

Any possible solution ?

Thanks
Laurent

License of SDFat?

Hi,

I might be blind, and while I can see that SDFat is GPL as per the comments in the code, which version of GPL is it under? According to the Arduino folks, all of the core libraries are LGPL, and SD (based on this I believe) is part of the core library. Does that mean that SDFat is LGPL?

Thanks,
Jeremy

spi on other pin, Soft spi on Arduino ZERO

Hi I am try to compile your great library on my custom AtSamd21E18 zero compatible board
I have onboard SD card reader connected to MISO a19(d12),SCK a17(d13), MOSI a16(d11),SS a18(10)
I have try Soft spi because I do not know how to configure samd sercoms.
I get this erros:

In file included from D:_sukromne_Arduino\arduino-1.6.5\portable....\Arduino\libraries\SdFat/utility/SoftSPI.h:31:0,
from D:_sukromne_Arduino\arduino-1.6.5\portable....\Arduino\libraries\SdFat/SdSpi.h:211,
from D:_sukromne_Arduino\arduino-1.6.5\portable....\Arduino\libraries\SdFat/SdSpiCard.h:29,
from D:_sukromne_Arduino\arduino-1.6.5\portable....\Arduino\libraries\SdFat/SdFat.h:26,
from SoftwareSpi.ino:7:
D:_sukromne_Arduino\arduino-1.6.5\portable....\Arduino\libraries\SdFat/utility/DigitalPin.h: In function 'bool fastDigitalRead(uint8_t)':
D:_sukromne_Arduino\arduino-1.6.5\portable....\Arduino\libraries\SdFat/utility/DigitalPin.h:63:33: error: 'const PinDescription' has no member named 'pPort'
return g_APinDescription[pin].pPort->PIO_PDSR & g_APinDescription[pin].ulPin;
^
D:_sukromne_Arduino\arduino-1.6.5\portable....\Arduino\libraries\SdFat/utility/DigitalPin.h: In function 'void fastDigitalWrite(uint8_t, bool)':
D:_sukromne_Arduino\arduino-1.6.5\portable....\Arduino\libraries\SdFat/utility/DigitalPin.h:73:28: error: 'const PinDescription' has no member named 'pPort'
g_APinDescription[pin].pPort->PIO_SODR = g_APinDescription[pin].ulPin;
^
D:_sukromne_Arduino\arduino-1.6.5\portable....\Arduino\libraries\SdFat/utility/DigitalPin.h:75:28: error: 'const PinDescription' has no member named 'pPort'
g_APinDescription[pin].pPort->PIO_CODR = g_APinDescription[pin].ulPin;
^
Error compiling.

Particle Photon Support?

A year ago I floated the idea of porting SdFat to the Spark Core on their official forum. Unfortunately nothing came of it. They recently released a lower cost (and more powerful) version of that board called the Photon.

https://store.particle.io/

I would be happy to sponsor the purchase of one of these boards if it meant support for SdFat.

begin class latency

I would like to use the sd.begin() class to test if the card is connected to the board.
I check the connection using this piece of code:

/* check if the SD card is connected */
boolean SDconnected(void)
{
  boolean flagSD = false;
  /* Initializes the SD library and card. This begins use of the SPI bus and chip select pin */
  flagSD = sd.begin(CHIP_SELECT);
  return flagSD;
}

I have observed a latency of about 1 sec when I call SDconnected() function.
Is there any chance to remove the latency ?

analogRead A7 inside LowLatencyLogger with Feather M0

Not sure if this is an issue or something I'm doing wrong:
I am using the Adalogger FeatherWing on top of a M0 BasicProto to log some sensor data into an SD card at 100hz. For this I have modified the LowLatencyLogger example and so far it works great. Now I need to implement some form of battery voltage reading so the program can stop recording and close the file before the battery runs out. For this I need to do an analogRead on pin A7(aka digital pin 9) which is connected to the battery via a voltage divider, I have added this code inside the logData() function:

vBat = readBat();
if (vBat <= 3.35) {
  Serial.println("Battery low, closing file");
  closeFile = true;
}

where readBat() is:

float readBat() {
  float voltage = analogRead(VBATPIN);
  voltage *= 2;
  voltage *= 3.3;
  voltage /= 1024;
  return voltage;
}

Which prints the following:

error: createContiguous failed
SD errorCode: 0X4,0X4

My guess was that there might be some pin conflicts but according to my research that is not the case here. Do you know why this happens/how could I implement it correctly?

PS: I understand I should probably filter the values returned by the readBat() function in order for this to work properly.

Missing SdVolume on SparkPlug MP3 2011 Code

Hi I've searched on forums in Arduino and other web links online, but I'm am trying to test out the SparkPlug 2011 Code on my Arduino Nano, I've set the pins and included the correct libraries, but I'm missing SdVolume. I've looked at the text files of the changes and realized that it is deprecated, but then is there another function or even a library that I need to include for a function similar to SdVolume?

SdFat SD;
//Create the variables to be used by SdFat Library
//Sd2Card card;
// SdVolume volume;
SdFile root;
SdFile track;

UPDATE: Nevermind I saw that it is supposed to be included with the sdfat object, but for the SParkPlug Project would I replace every function that has SdVolume's object name and Sd2Card's object name with the name of my SdFat object? If you'd like I'm posting the example code for Arduino below.

Here's the link to the example code
http://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/MP3_Player_Example_Control.pde

I appreciate any help
Thanks Bill!

Hot plug/remove sample ?

Hi, very very nice library thanks for your great work. 😄
I am trying using it with my ESP8266 and have couple of question.

Is there an example of which functions need to be done when SD card is removed then plugged or even changed ?
Or just need to do a SD.begin(SDCARD_CS_PIN); again when card is inserted ?

Is there a way that hot plug / remove, can be safely detected using library functions, if there is no SDCARDDETECT pin ? Some card read don' have.
I tried SD.card()->cardSize() and File dir = SD.open("/")); sometimes it works and sometimes not and even generate exception.

Thanks in advance

SdFat and RFduino SPI

I need to run SdFat with RFduino. RFduino API of SPI seems to be old and does not match SdFat, for example it does not have SPISettings class.

Is it realistic to upgrade SPI to match SdFat (If I were to do it)? Could you please provide some guidance on how to do that? For now, I'm thinking of adding SPISettings class.

Typo in SdSpiSTM32F1.cpp causes compiling error.

SdFat_Beta When trying to compile with lib Arduino_STM32, using a board with more than 3 SPI buses you get compile errors.

Line 29.. static SPIClass m_SPI2(3);

should be?

static SPIClass m_SPI3(3);

Upgrade from 2015-03-24 version to 1.0.1 - enabling CRC on AVR compile fails

As the title says, I was previously using SdFat commit from 2015-03-24 with the following config:

#define USE_SD_CRC 2

but now when I update to v1.0.1 and edit SdFafConfig.h to set the CRC flag to 2 (or 1) the compile fails.

Error window:

Arduino: 1.8.2 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Don\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10802 -build-path C:\Users\Don\AppData\Local\Temp\arduino_build_850350 -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose E:\Projects\DEC_PDP_stuff\rx02_emulator\rx02_emulator\rx02_emulator.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Don\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10802 -build-path C:\Users\Don\AppData\Local\Temp\arduino_build_850350 -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose E:\Projects\DEC_PDP_stuff\rx02_emulator\rx02_emulator\rx02_emulator.ino
Using board 'mega' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
Generating function prototypes...
Compiling sketch...
Compiling libraries...
Compiling library "SPI"
Compiling library "SdFat"

C:\Users\Don\Documents\Arduino\libraries\SdFat\src\SdCard\SdSpiCard.cpp: In member function 'bool SdSpiCard::readData(uint8_t*, size_t)':

C:\Users\Don\Documents\Arduino\libraries\SdFat\src\SdCard\SdSpiCard.cpp:386:11: error: 'SD_CARD_ERROR_READ_CRC' was not declared in this scope

     error(SD_CARD_ERROR_READ_CRC);

           ^

Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
Using library SdFat at version 1.0.1 in folder: C:\Users\Don\Documents\Arduino\libraries\SdFat 
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

support for arduino zero

seemingly there's no support for the arduino zero (arduino ide 1.6.5 r2), as i get alot of compile errors

SDFAT\SdSpiCard.cpp.o: In function SdSpiCard::spiSend(unsigned char)': C:\Users\Ramon\Documents\Arduino\libraries\SDFAT/SdSpiCard.h:263: undefined reference toSdSpi::send(unsigned char)'
SDFAT\SdSpiCard.cpp.o: In function SdSpiCard::spiInit(unsigned char)': C:\Users\Ramon\Documents\Arduino\libraries\SDFAT/SdSpiCard.h:254: undefined reference toSdSpi::init(unsigned char)'
SDFAT\SdSpiCard.cpp.o: In function SdSpiCard::spiReceive()': C:\Users\Ramon\Documents\Arduino\libraries\SDFAT/SdSpiCard.h:257: undefined reference toSdSpi::receive()'
SDFAT\SdSpiCard.cpp.o: In function SdSpiCard::spiReceive(unsigned char*, unsigned int)': C:\Users\Ramon\Documents\Arduino\libraries\SDFAT/SdSpiCard.h:260: undefined reference toSdSpi::receive(unsigned char*, unsigned int)'
SDFAT\SdSpiCard.cpp.o: In function SdSpiCard::spiReceive()': C:\Users\Ramon\Documents\Arduino\libraries\SDFAT/SdSpiCard.h:257: undefined reference toSdSpi::receive()'
C:\Users\Ramon\Documents\Arduino\libraries\SDFAT/SdSpiCard.h:257: undefined reference to SdSpi::receive()' C:\Users\Ramon\Documents\Arduino\libraries\SDFAT/SdSpiCard.h:257: undefined reference toSdSpi::receive()'
SDFAT\SdSpiCard.cpp.o: In function `SdSpiCard::spiSend(unsigned char)':

the list goes on, but i thought i'd save some reading.

Do the soft spi macros work for 1284?

Was looking at the code today and saw what looks like a few issues in utility/DigitalPin.h
with respect to the 1284 support for for bobuino, mighty, and standard.
when using Jack's 1284 core package:
( https://github.com/JChristensen/mighty-1284p )

I'm assuming that this is a typo:
#ifdef defined(VARIANT_MIGHTY)

Then I had a question about the VARIANT_XXX defines being used to determine
which variant is being used. Where are those set? The IDE doesn't set them and they are not
being defined in the 1284 core variant/{variantname}/pins_arduino.h file.

Maybe I'm missing something but I don't see these being set anywhere.
My openGLCD library also does AVR raw port i/o so I also have to determine which
variant is being used. For the 1284 I use the values of analogInputToDigitalPin()
to adjust my own internal defines.

/*
 * Now must check which mighty1284p core variant
 * Look at the pin number of the first analog pin to distinguish
 */
#if (analogInputToDigitalPin(0) == 24 )
#define GLCD_CORE_MIGHTY1284P // avr mighty1284p "standard" pin mapping
#elif (analogInputToDigitalPin(0) == 31 )
#define GLCD_CORE_SANGUINO // avr mighty1284p avr_developers pin mapping (SANGUINO)
#elif (analogInputToDigitalPin(0) == 14 && analogInputToDigitalPin(7) == 21)
#define GLCD_CORE_BOBUINO // avr mighty1284p "bobuino" pin mapping
#elif (analogInputToDigitalPin(0) == 21 && analogInputToDigitalPin(7) == 31)
#define GLCD_CORE_SBEAUTY // "SleepBeauty" variant mighty-1284p core ------
#else
#warning "Uknown 644/1284 core: Using Arduino Core-Code Mode"
#define GLCD_CORE_CORECODE
#endif

Arduino mega 2560 problem with software spi

Hi, I am trying to use MEGA with softwate SPI SdFatSoftSpi. However no luck. I have tried following example with UNO and MEGA (original hardware). All 3 modes (SdFatSoftSpi, SdFatLibSpi, SdFat) works fine with UNO. Only 2 modes (SdFatLibSpi, SdFat) work with MEGA. I have tried 2 different shield on both. An ethernet shield with SD CS pin 4 and a sparkfun CANBUS shield with SD CS 9. Both the same result. I cannot use software SPI on MEGA. Please help. I am on IDE v1.6.5

Thanks,

/**************************************************************************/

include <SPI.h>

include <SdFat.h>

if SD_SPI_CONFIGURATION >= 3 // Already set in SdFat/SdFatConfig.h

// Pin numbers in templates must be constants.
const uint8_t SOFT_MOSI_PIN = 11;
const uint8_t SOFT_MISO_PIN = 12;
const uint8_t SOFT_SCK_PIN = 13;

// SD card Chip select 4 for ethernet, 9 for canbus shield
const uint8_t SD_CHIP_SELECT_PIN = 4;

// SdFat software SPI template (works with UNO only)
SdFatSoftSpi<SOFT_MISO_PIN, SOFT_MOSI_PIN, SOFT_SCK_PIN> sd;

// Using the standard Arduino SPI library (works with UNO and MEGA)
//SdFatLibSpi sd;

// Using fast custom SPI (works with UNO and MEGA)
//SdFat sd;

// Test file.
SdFile file;

void setup() {
pinMode(10,OUTPUT); // canbus and ethernet SPI CS.
//digitalWrite(10,HIGH);
pinMode(53,OUTPUT);
//digitalWrite(53,HIGH);

Serial.begin(9600);
while (!Serial) {} // Wait for Leonardo

Serial.println("Type any character to start");
while (Serial.read() <= 0) {}

if (!sd.begin(SD_CHIP_SELECT_PIN)) {
sd.initErrorHalt();
}

if (!file.open("SoftSPI.txt", O_CREAT | O_RDWR)) {
sd.errorHalt(F("open failed"));
}
file.println(F("This line was printed using software SPI."));

file.close();

Serial.println(F("Done."));
}
//------------------------------------------------------------------------------
void loop() {}

else // SD_SPI_CONFIGURATION >= 3

error SD_SPI_CONFIGURATION must be set to 3 in SdFat/SdFatConfig.h

endif //SD_SPI_CONFIGURATION >= 3

Problem with the writing time on the microSD using sdFat SoftwareSpi

Hey!

First of all, thanks for your work!

I´m working on a project consisting on taking data from an accelerometer and saving it in a microSD card. I´m using an arduino UNO, an adafruit ADXL345 digital accelerometer, a Catalex microSD module and a Sandisk Ultra microSDHC card (8GB, class 10).

The accelerometer is using SPI, so I need to use the SoftwareSpi with the microSD module because I realised that Catalex module blocks the MISO pin, therefore it´s not possible to use it with other SPI devices at the same time. I followed the SofwareSpi example to do it.

I need a sampling frequency of 1000Hz and I managed to do it using the timerone library.
In order to check if it´s working properly, I save the microseconds each time the interruption is shot and I calculate the intervals between measures and the global frequency.
The accelerometer with timerone works fine and I always get intervals of 1000 microseconds. The problem is when I introduce the microSD module the intervals are not always 1000 microseconds. I have discovered that after a determinated amount of caracters it takes much more time to write the data.

I have tested it without using timerone library and without using the acelerometer, i.e. only writing on the microSD and calculating the intervals, and the result is the same: after a determinated amount of caracters it takes much more time to write the data.

This is the code that I'm using. I have omitted the accelerometer section in order to simplify it, so now the accelerations for each axis x, y z are always equal to 10. In this example I measure 50 data (x, y, z).

`

include <SPI.h>

include <SdFat.h>

include <TimerOne.h>

if SD_SPI_CONFIGURATION >= 3 // Must be set in SdFat/SdFatConfig.h

else // SD_SPI_CONFIGURATION >= 3

error SD_SPI_CONFIGURATION must be set to 3 in SdFat/SdFatConfig.h

endif //SD_SPI_CONFIGURATION >= 3

// Pin numbers in templates must be constants.
const uint8_t SOFT_MOSI_PIN = 5;
const uint8_t SOFT_MISO_PIN = 6;
const uint8_t SOFT_SCK_PIN = 7;

// Chip select may be constant or RAM variable.
const uint8_t SD_CHIP_SELECT_PIN = 4;

// SdFat software SPI template
SdFatSoftSpi<SOFT_MISO_PIN, SOFT_MOSI_PIN, SOFT_SCK_PIN> sd;

// Test file.
SdFile file;

const unsigned long nData = 50;
float x = 10;
float y = 10;
float z = 10;
unsigned long t[nData];

volatile unsigned long t_i;
volatile bool measured;

void measure(void){
t_i = micros();
measured = true;
}

void save_microSD(float x, float y, float z){
// Saving x
String dataString_x = "";
dataString_x = String(x);
file.println(dataString_x);
// Saving y
String dataString_y = "";
dataString_y = String(y);
file.println(dataString_y);
// Saving z
String dataString_z = "";
dataString_z = String(z);
file.println(dataString_z);
}

void setup(){

Timer1.initialize(1000);
Timer1.attachInterrupt(measure);

Serial.begin(250000);

if (!sd.begin(SD_CHIP_SELECT_PIN)) {
sd.initErrorHalt();
}
}

void loop(){

if (!file.open("data.txt", FILE_WRITE)) {
sd.errorHalt(F("open failed"));
}

Timer1.restart();

for (int j = 0; j < nData; j++){
measured = false;
while (not measured){
}
save_microSD(x, y, z);
t[j] = t_i;
}

Timer1.stop();
file.rewind();

//Print times to the terminal.
for (int j = 0; j < nData; j++){
Serial.print(j);Serial.print("T: "); Serial.print(t[j]); Serial.println(" ");
if (j >= 1){
Serial.print("Interval: "); Serial.print(t[j]-t[j-1]); Serial.println();
}
}
unsigned long tiempo = t[nData-1]-t[0];
Serial.print("Total time: "); Serial.println(tiempo);
float f = ((nData-1)*1000000)/tiempo;
Serial.print("Frequency: "); Serial.println(f);
Serial.println();

// Read microSD
while (file.available()){
Serial.write(file.read());
}
file.close();

if (sd.exists("data.txt")){
sd.remove("data.txt") ;
}

delay(5000);
}
`
The output that I obtain is the following:

0T: 5296956
1T: 5297956
Interval: 1000
2T: 5298956
Interval: 1000
3T: 5299956
Interval: 1000
4T: 5300956
Interval: 1000
5T: 5301956
Interval: 1000
6T: 5302956
Interval: 1000
7T: 5303956
Interval: 1000
8T: 5304956
Interval: 1000
9T: 5305956
Interval: 1000
10T: 5306956
Interval: 1000
11T: 5307956
Interval: 1000
12T: 5308956
Interval: 1000
13T: 5309956
Interval: 1000
14T: 5310956
Interval: 1000
15T: 5311956
Interval: 1000
16T: 5312956
Interval: 1000
17T: 5313956
Interval: 1000
18T: 5314956
Interval: 1000
19T: 5315956
Interval: 1000
20T: 5316956
Interval: 1000
21T: 5317956
Interval: 1000
22T: 5318956
Interval: 1000
23T: 5319956
Interval: 1000
24T: 5324956
Interval: 5000
25T: 5325956
Interval: 1000
26T: 5326956
Interval: 1000
27T: 5327956
Interval: 1000
28T: 5328956
Interval: 1000
29T: 5329956
Interval: 1000
30T: 5330956
Interval: 1000
31T: 5331956
Interval: 1000
32T: 5332956
Interval: 1000
33T: 5333956
Interval: 1000
34T: 5334956
Interval: 1000
35T: 5335956
Interval: 1000
36T: 5336956
Interval: 1000
37T: 5337956
Interval: 1000
38T: 5338956
Interval: 1000
39T: 5339956
Interval: 1000
40T: 5340956
Interval: 1000
41T: 5341956
Interval: 1000
42T: 5342956
Interval: 1000
43T: 5343956
Interval: 1000
44T: 5344956
Interval: 1000
45T: 5345956
Interval: 1000
46T: 5346956
Interval: 1000
47T: 5347956
Interval: 1000
48T: 5352956
Interval: 5000
49T: 5353956
Interval: 1000
Total time: 57000
Frequency: 859.00

Note that all intervals are 1000 microseconds except between data 23 - 24 and 47 - 48, which are 5000 microseconds. I don´t know why this is happening and if there is a way to get always the same writing time.

I hope you can help me with this problem. Thank you very much!

Issue opening files

Hi and many thanks for your work on this library. I have been having some difficulties using the library and in my own code and the example code for read and write of a file am hitting the same problem in that opening files fails. I have un-commented the fail macro & SD_TRACE serial print statements and the trace looks like this:

Press enter to start
Started
RB0
RB8192
RB12596
SD Init Complete
RB16384
..Arduino\libraries\SdFat\SdVolume.cpp224
..Arduino\libraries\SdFat\SdBaseFile.cpp1107
..Arduino\libraries\SdFat\SdBaseFile.cpp644
error: opening test.txt for write failed
SD errorCode: 0XF,0X1

Your assistance would be appreciated.
Many thanks, Bob.

Include SdFat library in other libraries not possible (?)

I have started to replace the old SD library with the SdFat library in my libraries, but I get the error "Type 'SdFat' could not be resolved".

Example my_Library.h:
#include <SPI.h>
#include <SdFat.h>
SdFat SD;

Interestingly the SD declaration in .h file works in the main program but not in the .h or .cpp file.

Many thanks in advance.

Importing the library correctly

I am not exactly sure how to import this library into Arduino 1.6.5. I tried copying the sdfat-master folder to the Libraries directory but that results in a compilation error unable to Locate Sdfat.h What is the correct way to get this library working in Arduino 1.6.5 and why did the Arduino folks change things in a way that breaks legacy libraries? (you don't need to answer that last, that is just me engaging in self pity).

SoftSPI works with cheap card, not with expensive card

Hi,

First of all, thanks for the lib!

I've been doing some raw block access using the Sd2Card class directly (and the writeBlock/readBlock methods). Everything works perfectly when I use the fast, custom SPI implementation (SD_SPI_CONFIGURATION = 0) and hardware SPI pins on the Arduino UNO.

Now I've moved my SD card to another SPI "bus" on pins A3 through A5, using SoftSpi (SD_SPI_CONFIGURATION = 2) to do so. Here's where it gets funky:

  1. Everything works fine on an old, cheap, no-name 128MB card;
  2. On a nicer 8GB SanDisk Extreme Pro SDHC card, reading a block and querying the card for its size works;
  3. On this faster card, writeBlock fails (error code SD_CARD_ERROR_WRITE).

Writing to this card works otherwise (hardware SPI on the Arduino or a PC), so I know it's fine. Could SoftSPI be too slow to write to this faster card?

Also, I'm at a loss as to how to debug this without tearing out my hair (I'm lacking an oscilloscope or logic analyzer), so any tips would be welcome.

Thanks!
Augusto

no known conversion for argument 1 from 'dir_t {aka directoryEntry}' to 'const dir_t* {aka const directoryEntry*}'

When I try to compile the example ino from https://github.com/tilos/DueWebServer, which uses this SdFat library, I get the following error:

F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\SdFat/utility/FatFile.h:303:18: note:   no known conversion for argument 1 from 'dir_t {aka directoryEntry}' to 'const dir_t* {aka const directoryEntry*}'
Error compiling.

I'm having some trouble on pinpointing which library is giving me the problems :)

For completeness I'll put the complete error below here:

F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.cpp: In function 'boolean WebServerHandler::get_handler(DueWebServer&)':
F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.cpp:533:47: error: invalid conversion from 'FatFile*' to 'SdBaseFile*' [-fpermissive]
     listDirectory(web_server, SdBaseFile::cwd());
                                               ^
In file included from F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.cpp:31:0:
F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.h:43:8: error:   initializing argument 2 of 'void WebServerHandler::listDirectory(DueWebServer&, SdBaseFile*)' [-fpermissive]
   void listDirectory(DueWebServer& web_server, SdBaseFile* file);
        ^
F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.cpp:544:34: error: cannot convert 'SdFile*' to 'SdBaseFile*' for argument '2' to 'void WebServerHandler::listDirectory(DueWebServer&, SdBaseFile*)'
   listDirectory(web_server, &file);
                                  ^
F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.cpp: In function 'void WebServerHandler::listFiles(const char*, SdBaseFile*, Client*, uint8_t)':
F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.cpp:632:26: error: no matching function for call to 'SdBaseFile::dirName(dir_t&, char [13])'
     file->dirName(p, name);
                          ^
F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.cpp:632:26: note: candidate is:
In file included from F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\SdFat/utility/ArduinoFiles.h:28:0,
                 from F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\SdFat/utility/FatLib.h:22,
                 from F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\SdFat/SdFat.h:27,
                 from F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.h:24,
                 from F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\DueWebServer\DueWebServer.cpp:31:
F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\SdFat/utility/FatFile.h:303:18: note: static uint8_t FatFile::dirName(const dir_t*, char*)
   static uint8_t dirName(const dir_t* dir, char* name);
                  ^
F:\Cloud\Box Sync\Arduino\Sketchbook\libraries\SdFat/utility/FatFile.h:303:18: note:   no known conversion for argument 1 from 'dir_t {aka directoryEntry}' to 'const dir_t* {aka const directoryEntry*}'
Error compiling.

SdFat Library changed dramatically?

Hi,

i am building an RFID reader (this one https://shubs.io/guide-to-building-the-tastic-rfid-thief/) but it seems that SdFat changed a lot since then. When i try to compile the project i get tons of error of missing files like "SDFile" and "SDVolume" which are no where to be found in the current repo.

I tried to find an older version but i am not able to. Should i use an old version or do i have to make changes in the project for the newer SdFat version to work?

Thank you (sorry for opening an issue for this but i don't where else to go)

AnalogBinLogger- Reading Two Analog Values and storing in SD

Hi,

I have been working on storing analog values of two inputs and storing them on the SD Card using the code and instructions given in # https://github.com/greiman/SdFat/tree/master/AnalogBinLoggerExtras . However it doesnt provide enough information on how to store two different inputs at the same time using the Timer/Counter. Being a newbie to embedded C programming ,im unable to figure how to modify this code and use it for my purpose. Any help /info would be nice.

Help to create a new file in Sd2Card.

I used Marlin FIrmware to 3d printer, and i want to save a file on its sd and it use sdfat.
The card fortmat is Sd2Card.
I tried to follow and exemple that is there:

void CardReader::write_new_file(char *buf, char* filename) {
  SdFile myNewFile;
//   if (!myNewFile.open(root, filename, O_RDWR)) {
//    SERIAL_ECHO_START;
//    SERIAL_ECHOPGM(MSG_SD_CANT_ENTER_SUBDIR);
//    SERIAL_ECHOLN(filename);
//  }
  if (!myNewFile.open("teste.txt", O_CREAT | O_EXCL | O_WRITE)) {
    SERIAL_ECHO_START;
    SERIAL_ECHOPGM(MSG_SD_CANT_ENTER_SUBDIR);
    SERIAL_ECHOLN(filename);
  }
  char* begin = buf;
  char* npos = 0;
  char* end = buf + strlen(buf) - 1;

  myNewFile.writeError = false;
  if ((npos = strchr(buf, 'N')) != NULL) {
    begin = strchr(npos, ' ') + 1;
    end = strchr(npos, '*') - 1;
  }
  end[1] = '\r';
  end[2] = '\n';
  end[3] = '\0';
  myNewFile.write(begin);
  if (myNewFile.writeError) {
    SERIAL_ERROR_START;
    SERIAL_ERRORLNPGM(MSG_SD_ERR_WRITE_TO_FILE);
  }
}

And it didn't work.
So i want to know the correct way to write a file at Sd2Card because all the exemples i found was about sdfat card format.
Thanks

Creating a hidden file

I was looking for quite a while now in both the documentation and in the web for SdFat hidden files support.
The only thing I found is the isHidden() command.
But there seems not to be a command setHidden() or equivalent.
Did I overlook it?

cardSize Failed

I'm running the sdcard info example and getting a cardSize failed error
I'm not sure what this means.

SdFat version: 1.0.1

Assuming the SD is the only SPI device.
Edit DISABLE_CHIP_SELECT to disable another device.

Assuming the SD chip select pin is: 15
Edit SD_CHIP_SELECT to change the SD chip select pin.

type any character to start
error: cardSize failed
SD errorCode: 0X52,0X7F

Enabling SPI transaction features

Thank you for this great library.
I Have just a question regarding enabling transaction within SPI, why we need to include the SPI.h into our main sketch file ?? IS this mandatory ??

SdFat only works on some SD slots

I have 2 sainsmart 4.3 TFT displays with SDcard slots and 2 3.2 TFT displays. One is a Sainsmart and one is the Coldtears original that all of these are cloned from. SD library works on all 4, but SdFat only works on the 4.3 slots. No read or write at all on the 3.2 slots. The wiring and pinouts all seem to be the same.

LFN create/write

Can you show an example of opening a new file for write (create) with long file name?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.