PDA

View Full Version : Teensy3 and SdFat.h



November
12-13-2012, 03:35 AM
Anyone have any ideas on why this code fails to compile. I cant tell if its my install or the code...


//#include <SD.h>
#include <SdFat.h>
//#include <Sd2Card.h>
//#include <SdVolume.h>
//#include <SdFile.h>

Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;

void setup() {
Serial.begin(9600);
card.init(SPI_FULL_SPEED);
volume.init(&card);
root.openRoot(&volume);
}

void loop(){
file.open(&root,"cat.txt",O_READ);
int16_t n;
uint8_t buf[7];

while ((n = file.read(buf, sizeof(buf))) > 0){
for (uint8_t i = 0; i < n; i++) Keyboard.print(buf[i]);
}

file.close();
}


Errors:

In file included from /Users/November/Documents/Arduino/libraries/SdFat/SdFile.h:24,
from /Users/November/Documents/Arduino/libraries/SdFat/SdFat.h:35,
from sketch_dec12a.ino:2:
/Users/November/Documents/Arduino/libraries/SdFat/SdBaseFile.h:36: error: using typedef-name 'fpos_t' after 'struct'
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/include/stdio.h:59: error: 'fpos_t' has a previous declaration here
In file included from /Users/November/Documents/Arduino/libraries/SdFat/iostream.h:26,
from /Users/November/Documents/Arduino/libraries/SdFat/SdStream.h:27,
from /Users/November/Documents/Arduino/libraries/SdFat/SdFat.h:36,
from sketch_dec12a.ino:2:
/Users/November/Documents/Arduino/libraries/SdFat/istream.h:144: error: 'istream& istream::operator>>(int16_t&)' cannot be overloaded
/Users/November/Documents/Arduino/libraries/SdFat/istream.h:126: error: with 'istream& istream::operator>>(short int&)'
/Users/November/Documents/Arduino/libraries/SdFat/istream.h:153: error: 'istream& istream::operator>>(uint16_t&)' cannot be overloaded
/Users/November/Documents/Arduino/libraries/SdFat/istream.h:135: error: with 'istream& istream::operator>>(short unsigned int&)'
In file included from /Users/November/Documents/Arduino/libraries/SdFat/ArduinoStream.h:26,
from /Users/November/Documents/Arduino/libraries/SdFat/SdFat.h:37,
from sketch_dec12a.ino:2:
/Users/November/Documents/Arduino/libraries/SdFat/bufstream.h: In member function 'virtual void ibufstream::getpos(fpos_t*)':
/Users/November/Documents/Arduino/libraries/SdFat/bufstream.h:62: error: request for member 'position' in '* pos', which is of non-class type 'long int'
/Users/November/Documents/Arduino/libraries/SdFat/bufstream.h: In member function 'virtual void ibufstream::setpos(fpos_t*)':
/Users/November/Documents/Arduino/libraries/SdFat/bufstream.h:73: error: request for member 'position' in '* pos', which is of non-class type 'long int'


Sorry, I know its a long post -- just wanted to get it all out there.


Kind Regards,


November

CheapB
12-13-2012, 04:18 AM
Use SD instead of SdFat?

#include <SD.h>
//#include <SdFat.h>


You may be using the wrong version of SDfat. is this what you are using: http://code.google.com/p/beta-lib/downloads/detail?name=SdFatBeta20121203.zip&can=2&q=

with this your code compiles fine..

November
12-13-2012, 04:35 AM
Use SD instead of SdFat?

#include <SD.h>
//#include <SdFat.h>


You may be using the wrong version of SDfat. is this what you are using: http://code.google.com/p/beta-lib/downloads/detail?name=SdFatBeta20121203.zip&can=2&q=

with this your code compiles fine..

Yes, this is the version I am compiling with.

CheapB
12-13-2012, 12:10 PM
Yes, this is the version I am compiling with.

Strange.. I compiled your code with the "non-beta" version of SDfat and I got the compilation errors you have. then I changed to the beta version referenced above and everything was fine.
Can you compile if you change the board type to Leonardo?

November
12-13-2012, 01:10 PM
Strange.. I compiled your code with the "non-beta" version of SDfat and I got the compilation errors you have. then I changed to the beta version referenced above and everything was fine.
Can you compile if you change the board type to Leonardo?


Yes -- Can I download my code to the teensy 3 this way?

PaulStoffregen
12-13-2012, 08:16 PM
Which operating system are you using? Maybe MacOS? Snow Leopard, Lion, Mountain Lion?

CheapB
12-14-2012, 03:02 AM
Yes -- Can I download my code to the teensy 3 this way?

I am running windows 7 64bit and it compiles fine with for Teensy 3. The reason I asked about lenoardo is the previous version of SDfat does compile for leonardo but not for teensy 3. can you try to download the library again and make sure you place in the correct folder.

November
12-16-2012, 07:57 PM
I got the lib to compile. I downloaded the newest version (from Dec of this year) and installed.