I loaded test.txt with 20 lines of CSV text with three numbers (all numbers <= 255), and this got them all.
#include <SD.h>
char netBuffer[32];
byte myTest[3];
void setup() {
Serial.begin(9600);
// disable w5100
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
Serial.print("Starting SD...");
if(!SD.begin(4)) Serial.println("failed");
else Serial.println("ok");
File fh = SD.open("test.txt",FILE_READ);
int chPos = 0;
int lineNo = 0;
if(!fh)
{
Serial.println("SD open fail");
return;
}
while(fh.available())
{
char ch = fh.read();
if(ch == '\n') {
chPos = 0;
sscanf(netBuffer,"%u,%u,%u",&myTest[0],&myTest[1],&myTest[2]);
Serial.print(netBuffer);
Serial.print(" A = ");
Serial.print(myTest[0]);
Serial.print(" B = ");
Serial.print(myTest[1]);
Serial.print(" C = ");
Serial.println(myTest[2]);
lineNo++;
}
else if(ch == '\r') {
// do nothing
}
else if(chPos < 31) {
netBuffer[chPos] = ch;
chPos++;
netBuffer[chPos] = 0;
}
}
fh.close();
}
void loop() {
}
edit: Removed extra blank lines.