File Read from SD Card

Sorry if this is in the wrong location (having trouble searching for the right place).

I have my code reading and dividing it up with out a problem, with the exception that I would like to read (for lack of better terms) the info and skip the comments.

Is there a way to cause the StreamReader to go to the next line, regardless of whether or not there is anything remaining on the current line.

Here is sample of my file:

TRUE;					//Enable AC Power Supply #1 Monitoring
FALSE;					//Enable AC Power Supply #2 Monitoring
TRUE;					//Enable Forward Combustible Fume Detection

I want the true and ignore the semi-colon and comments. Here is what I have reads it all:

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

String val;

void setup() {
  Serial.begin(9600);           // Start Serial for Debugging

  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);

  if(!SD.begin(4)) Serial.println("SD fail");
  else Serial.println("SD ok");

  File cfg = SD.open("cfg.ini", FILE_READ);
  int i = 0;
  while (cfg.available()) {
    
    val = cfg.readStringUntil(';');
    Serial.println(i);
    Serial.println(val); //Printing for debugging purpose 
    i++;        
    //move val to my parameters
  }

  cfg.close();
  
}

void loop() {
  // put your main code here, to run repeatedly:

}

Here is the current output, obviously the first one is perfect but the balance is off.

SD ok
0
TRUE
1
					//Enable AC Power Supply #1 Monitoring
FALSE
2
	//Enable AC Power Supply #2 Monitoring
TRUE

Any assistance is much appreciated!!

You need to write code for that... basically it seems that you need to read one word and then ignore till the end of line

I was hoping that there was an easier way, but I guess that this method of what you are saying is simple enough after 2 more drinks and some thought.

Here is what works unless there is a simpler way that some one knows about.

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

String val;
String trash;

void setup() {
  Serial.begin(9600);           // Start Serial for Debugging

  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);

  if(!SD.begin(4)) Serial.println("SD fail");
  else Serial.println("SD ok");

  File cfg = SD.open("cfg.ini", FILE_READ);
  int i = 0;
  while (cfg.available()) {
    
    val = cfg.readStringUntil(';');
    Serial.println(i);
    Serial.println(val); //Printing for debugging purpose 
    trash = cfg.readStringUntil('\n');
    i++;        
    //move val to my parameters
  }

  cfg.close();
  
}

void loop() {
  // put your main code here, to run repeatedly:

}

exactly. Now if you do that without the String class, it's even better :slight_smile: