i've got the following problem: ( the code is used to select all gcode-files from an SD-card and save their names into an String-Array).
String file_names = String(printDirectory(root));
String cmd = split(file_names, '<', 13);
unsigned int i = 1;
while (true) {
cmd = split(file_names, '<', i);
cmd.trim();
if (cmd == "" or cmd == NULL or cmd == "//") {
break;
} else {
Serial.println(String(i) + String(cmd));
//gcode_files[i] = cmd;
delay(200);
i++;
}
}
Well it runs well, but if i remove the comment in line 8, the output is broken. Same problem with variables if their not declarated as an array.
The variable gcode_files is an global variable of typ String btw.
String gcode_files[] = {};
Im not sure, do i need some pointer?
The "normal" output, without the array is here:
14:59:38.768 -> 1EINS~1.GCO 14:59:38.768 -> 2ZWEI~1.GCO 14:59:38.768 -> 3DREI~1.GCO 14:59:38.768 -> 4VIER~1.GCO 14:59:38.816 -> 5FUENF~1.GCO
But when i add the array into the code, i have the following output:
15:03:53.824 -> 1EINS~1.GCO
and the code stops at this point (sometimes after 2 or 3 loops). So the loop never really ends correctly.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire