Dear All
I don't meant to hijack this thread, but I also got same problem with sdfatlib, and when I put sdfatlib as search keyword it refer to this thread.
So here we go.
I have a data file like this :
1474,254
1616,253
2998,254
3153,253
3925,254
4094,253
4642,254
4827,253
5255,254
5459,253
5810,254
6039,253
6336,254
6597,253
6851,254
7160,253
7379,254
7768,253
7957,254
8547,253
8705,254
10133,255
10293,254
10831,255
11031,254
11365,255
11617,254
11866,255
12210,254
12405,255
13096,254
13240,255
13600,256
13744,255
14413,256
14614,255
14931,256
15209,255
15431,256
15918,255
16077,256
16803,257
16963,256
17434,257
17664,256
17922,257
18298,256
18474,257
19442,258
19619,257
19981,258
20254,257
20468,258
21838,259
22057,258
22318,259
22746,258
22905,259
23336,260
23494,259
23917,260
24187,259
24395,260
25432,261
25643,260
25905,261
26455,260
26592,261
26613,262
26757,261
27244,262
27523,261
27721,262
28491,263
28690,262
28963,263
30133,264
30414,263
30605,264
31214,265
31406,264
31682,265
32712,266
32995,265
33180,266
33666,267
33852,266
34131,267
35051,268
35337,267
35517,268
35902,269
36082,268
36364,269
37199,270
37488,269
37662,270
37963,271
38138,270
38424,271
39185,272
39479,271
39648,272
39873,273
40042,272
40335,273
41035,274
41333,273
41497,274
41662,275
41826,274
42122,275
42768,276
43072,275
43231,276
43333,277
43491,276
43797,277
44401,278
44717,277
44870,278
44891,279
45039,278
45369,279
45949,280
46294,279
46436,280
46457,281
46621,280
46899,281
47374,282
47659,281
47817,282
47869,283
48025,282
48314,283
48764,284
49059,283
49211,284
49232,285
49389,284
49670,285
50078,286
50366,285
50518,286
50539,287
50699,286
50967,287
51327,288
51599,287
51754,288
51775,289
51932,288
52199,289
52528,290
52797,289
52951,290
52972,291
53133,290
53385,291
53673,292
53928,291
54086,292
54107,293
54268,292
54517,293
54773,294
55019,293
55179,294
55200,295
55361,294
55603,295
55835,296
56079,295
56238,296
56259,297
56427,296
56655,297
56844,298
57069,297
57236,298
57257,299
57418,298
57651,299
57837,300
58073,299
58231,300
58252,301
58427,300
58636,301
58760,302
58962,301
59140,302
59184,303
59356,302
59565,303
59682,304
59889,303
60061,304
60082,305
60251,304
60461,305
60567,306
60773,305
60943,306
60964,307
61139,306
61338,307
61406,308
61594,307
61777,308
61798,309
61965,308
62170,309
62247,310
62447,309
62617,310
62638,311
62827,310
63006,311
63027,312
63205,311
63392,312
63429,313
63616,312
63793,313
63814,314
64001,313
64177,314
64198,315
64391,314
64561,315
64582,316
64788,315
64947,316
64968,317
65219,316
65354,317
65375,318
and here is what I got from SdFatTail.pde

Question :
How to put each "field" of the output into to different variable (ie: var1, var2) rather than printing it out.
here is the code (small edited from original sample)
/*
* This sketch reads and prints the tail of all files
* created by SdFatAppend.pde, SdFatPrint.pde, and
* SdFatWrite.pde.
*/
#include <SdFat.h>
#include <SdFatUtil.h>
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
// store error strings in flash to save RAM
#define error(s) error_P(PSTR(s))
void error_P(const char *str)
{
PgmPrint("error: ");
SerialPrintln_P(str);
if (card.errorCode()) {
PgmPrint("SD error: ");
Serial.print(card.errorCode(), HEX);
Serial.print(',');
Serial.println(card.errorData(), HEX);
}
while(1);
}
void setup(void)
{
Serial.begin(9600);
Serial.println();
Serial.println("type any character to start");
while (!Serial.available());
Serial.println();
// initialize the SD card
if (!card.init()) error("card.init");
// initialize a FAT volume
if (!volume.init(card)) error("volume.init");
// open the root directory
if (!root.openRoot(volume)) error("openRoot");
}
/*
* Print tail of all SdFat example files
*/
void loop(void)
{
dir_t dir;
char name[13];
// read next directory entry
if (root.readDir(dir) != sizeof(dir)) {
Serial.println("End of Directory");
while(1);
}
// check for file name "APPEND.TXT", "PRINT*.TXT"
// or "WRITE*.TXT"
// first 8 bytes are blank filled name
// last three bytes are blank filled extension
if ((strncmp((char *)dir.name, "MYSTEP", 6)) ||
strncmp((char *)&dir.name[8], "TXT", 3)) {
return;
}
// format file name
SdFile::dirName(dir, name);
// remember position in root dir
uint32_t pos = root.curPosition();
// open file
if (!file.open(root, name, O_READ)) error("file.open");
// restore root position
if (!root.seekSet(pos)) error("root.seekSet");
// print file name message
Serial.print("Tail of: ");
Serial.println(name);
// position to tail of file
//if (file.fileSize() > 100) {
// if (!file.seekSet(file.fileSize() - 100)) error("file.seekSet");
//}
int16_t c;
// find end of line
//while ((c = file.read()) > 0 && c != '\n');
// print rest of file
while ((c = file.read()) > 0)
{
Serial.print((char)c);
}
file.close();
Serial.println();
}
Sincerely
-bino-