Hello. I have a few month programing with XOD. I´m not c++ programer, but i have a general idea. I´m trying to make a node to read from a .txt file into de SD-card. I´v succes making a “file erase” node. But when i store information into the file with sd-log, then i read with the new node, it´s shows only one digit and it seems that it´s on hexadecimal format. I mean that into the file is the number 21 saved, but the node only reads the first digit “2”, and shows it like in byte format plus 30. For example: 32, but then output in decimal: 50. Simplyfing: i saved 2, but reads 32, and shows me 50. I post the code here. It´s based on the sd-log. The “while (myFile.available())” doesn´t work, so y hide from the code with dash //. I´v edited the node with a byte output that displays the 32 i mean. Also i linked the table of conversion by refference. Thanks alot.
#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_W
#pragma XOD error_raise enable
{{#global}}
#include <SPI.h>
#include <SD.h>
{{/global}}
struct State {
bool begun;
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
auto state = getState(ctx);
if (!isInputDirty<input_W>(ctx))
return;
if (!state->begun) {
// First time use, initialize
auto csPin = getValue<input_CS>(ctx);
state->begun = SD.begin(csPin);
}
if (!state->begun) {
raiseError(ctx);
return;
}
char filename[16] = { 0 };
dump(getValue<input_FILE>(ctx), filename);
// re-open the file for reading:
File myFile = SD.open(filename, O_READ);
if (myFile) {
// while (myFile.available()){
emitValue<output_OUT>(ctx, myFile.read());
// }
} else {
state->begun = false;
raiseError(ctx); // Can’t open file
return;
}
// close the file:
myFile.close();
emitValue<output_DONE>(ctx, 1);
}