SdFat parseInt

I've just installed new Arduino IDE (1.6.4) and also SdFat libraries (version 20150324), so I want to use the parseInt() function (which, I've read, was recently added to SdFat as it was in old SD) but compiler still answer to me :

Arduino:1.6.4 (Windows Vista), Scheda:"Arduino Uno"

Uso la libreria SPI nella cartella: C:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI

Uso la libreria SdFat nella cartella: C:\Users\internet\Documents\Arduino\libraries\SdFat (legacy)

C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Users\internet\Documents\Arduino\libraries\SdFat C:\Users\internet\AppData\Local\Temp\build7259032078456199248.tmp\StreamParseInt.cpp -o C:\Users\internet\AppData\Local\Temp\build7259032078456199248.tmp\StreamParseInt.cpp.o

StreamParseInt.ino: In function 'void setup()':
StreamParseInt.ino:38:16: error: 'class File' has no member named 'parseInt'
'class File' has no member named 'parseInt'

...And yes, :wink: I have "detailed output" ON.
I have also tried to change "ARDUINO_FILE_USES_STREAM" to 0 or 1 if file "SdFatConfig.h", but result still remain the same.
I've just had, time ago, my workaround to this problem writing my own parseInt() function...

But... question remains... Why is parseInt() not working to me like Greiman says in his replys ? What's wrong?

File inherits the Stream class, it definitely has parseInt() in IDE versions later than August 2011.

https://github.com/arduino/Arduino/blame/master/hardware/arduino/avr/cores/arduino/Stream.h#L74

This compiles fine for me:

#include <SPI.h>
#include <SD.h>

File file;

void setup(){
  file.parseInt();
}

void loop(){}

Hi pYro_65 :slight_smile: and thank you for your answer, but I think you have confused something... Of course that with normal (&old) SD library it will compile... I just say that in my post "...was recently added to SdFat as it was in old SD)..."
the problem comes with SdFat library, a newer and more functional library for SD card, that will not compile to me even if Greiman, the Author of both SD & SdFat, says that it will...

You will need to provide more than the version number of the SdFat library. Like, a link...

PaulS:
You will need to provide more than the version number of the SdFat library. Like, a link...

??? A link ??? Sorry, but I thought that SdFat library was a well known library of Arduino and most of people here know how to install & use... If You search "sdfat" in this forum You get more than 3,5K results...

Anyway... the link is GitHub - greiman/SdFat: Arduino FAT16/FAT32 exFAT Library and, of course, the "StreamParseInt.ino" sketch that is visible in the "IDE error report" is an Example that will be installed along with the libraries themselves.

Sorry, but I thought that SdFat library was a well known library of Arduino and most of people here know how to install & use

Not an invalid assumption.

If You search "sdfat" in this forum You get more than 3,5K results...

But, why should we? And, which of the 3500 did YOU follow?

Did you read the comments in FatLibConfig.h? Did you do what is suggested?

Bah.... I cannot understand such replies ! :frowning:

I don't want to spent time and space in this beatiful forum answering again to Your comments...
It's clear to all that You don't want to help me nor the people who is reading all this...
So, PLEASE, don't answer again here and go somewhere else possibly trying to HELP someother.

I think it should be quite clear to all that my first post it's NOT something like :

"I need to do this... I can't do it... please help me"

Sure, I'm not an expert, but I can understand that I have to do the job if I want to create something...

What I wanted to say with my post is that, PROBABILY (I'm not sure and that's why i'm asking here...), there is something that did not work correctly with SdFat library, or with new 1.6.4 IDE, or with the DOCUMENTATION supplied with, or maybe :), also with my knowledge of the matter...

The situation here, simply, is that I can't complile a sketch with parseInt() & SdFat, and, more precisely, I'm not able to understand why this is not possible for me while for others it is...

Obviously... the same what is happening to me, could happen to other... And that's another important reason why I posted all these here.

So, summarizing all that, if WE, all together :slight_smile: , can solve this issue, explaining also WHY, I think we would make Arduino IDE better...

P.S.: I just wrote this in my first post... But I'll say it again... I just have a workaround for my problem, writing my own parseInt() function, but I think it's better to understand why this happen, not only for me...

but I think it's better to understand why this happen, not only for me...

The FatLibConfig.h file explains why. There is a #define statement in it, with a value of 1. If you change the value to 0, the base class (that FILE derives from) changes, to Stream, where the parseInt() method is defined.

With a value of 1, the base class is NOT Stream, so the methods that the Stream class provides are not available.

Well... :wink: hi PaulS, nice to meet You,

and I will say that I appreciate Your help... but, if i'm not misunderstanding somewhat, I think You mean the ARDUINO_FILE_USES_STREAM #define in FatLibConfig.h...

I've just tried all that and I wrote about this in my first post...

andres26:
...
I have also tried to change "ARDUINO_FILE_USES_STREAM" to 0 or 1 if file "SdFatConfig.h", but result still remain the same.
...

I've read all the file and other files around searching for other useful #define but I could't find them...
There must be something else that is wrong here...

There must be something else that is wrong here...

I can't see what it is. I can't actually test your code, since I am borrowing this laptop, and I can't install the Arduino software or libraries.

andres26--

There could be an issue with how the library is installed.

After reading this thread, I decided to migrate my SdFat to the new core. I went to github and clicked on the download ZIP button. GitHub - greiman/SdFat: Arduino FAT16/FAT32 exFAT Library
SdFat-master.zip showed up.

I am using 1.6.4 and with sketch>include library>add.zip library produced the error " zip doesn't contain a library"

I tried to add it manually by unzipping to a folder on the destop which was named SdFat-master. I then moved this folder into my user libraries. It appeared in the IDE, and I could load the examples, but StreamParseInt would not compile. I've attached the file structure in the folder.

I had to pull out everything that was in the SdFat folder and bring it to a higher level, so that the final library folder looks line the next attachment. When it was all unwrapped like that, the StreamParseInt example would compile and run.

Yessss... we got it! :smiley:

After reading Cattledog's reply I investigate more in my SdFat installed directory and found my problem (a bit stupid error... I must say ::slight_smile: )
I had 2 copies of SdFatConfig.h file, one in "SdFat-master" dir and the other in "SdFat" subdir, created probabily during my inital tries to let SdFat compile correctly. Obviously, i was changing "Sdfat" version while IDE read "SdFat-master" one...
So, I changed the correct one and finally I got my long awaited parseInt compiled sketch... :slight_smile:

After that big result... :slight_smile: I tried to do exactly what Greiman says in his installation notes (SdFat.html) :
"You must manually install SdFat by copying the SdFat folder from the download package to the Arduino libraries". So I've erased all my old SdFat garbage and copied a new and fresh copy of "SdFat" dir to Arduino extra libraries folder.
And here comes an other bug... :o :fearful: Compiling now my sketch gives a compiler hang-on like Cattledog says (a screenshot in the attached img).

Well... :astonished: wrong try... I've restored my old SdFat-master, renamed it to Sdfat, goes to SdFat subdir and deleted all replicated files to avoid other future errors... Now it works! ;D

And... Last but not least :open_mouth: ... as we say here in Italy, "not all the bad comes to damage", my parseInt() function is faster ! than the library ones... Yes, very strange to say, but true... about 50% faster... and, because my sketch is used to show RGB leds figures, it's a god notice... :slight_smile:
So, finally, I revert back to my old version and got also the result to have a smaller executable version (due to ARDUINO_FILE_USES_STREAM 0 setting)

And now... :grin: I'm proud to release my parseUInt() version here to our forum! :grinning:

int parseUInt (void) { // ----------------- Read an UINT from file -----------------------------------------------
int num=-1; // set error code on
while (true) {
int c=file.read(); // read char from file. Must be int to allow EOF
if (c>47 && c<58) { // is char a number ?
if (num<0) num=0; // switch off error code
num=num*10+c-48;
} else if (num>-1 || c==-1) return num; // EOF or number ready
}
} // -------------------------------------------- end parseUInt ---------------------------------------------------

Cheers :wink: , Andres

Might I suggest that this:

    if (c>47 && c<58) {                              // is char a number ?

would be more obvious as

    if (c >= '0' && c <= '9') {                              // is char a number ?

Or, use the isdigit() macro.