Your question about saving your results was a little confusing to me but, I will tell you what I am doing.
I receive the data and save it as a byte in an array using this snippet of code.
byte inByte = Serial1.read();
buf[counter] = inByte;
Then, I save to my SD card the variable that I want. They will always be in the same positions in the string that comes from the ECU. I shared those positions with you months ago when you started this project. When I look at my SD card I find decimal numbers that are easily readable.
I was looking over your code that you shared a few days ago, and I have a great time stamp function that I use for the SD card. At the moment, I am using a buffer for storing the values. Using SDFAT, I use.... sprintf(buffer, "%02d:%02d:%02d.%03d", h, m, s, ms); to buffer time string.
void displayResult()
{
int h,s,m,ms; //hour, second, minute, milliseconds
unsigned long over;
elapsed = finished-start;
h = int(elapsed/3600000); //calculate the hour
over = elapsed%3600000;
m = int(over/60000); //calculate the minute
over = over%60000;
s = int(over/1000); //calculate the second
ms = over%1000; //calculate the millisecond
char buffer[14];
sprintf(buffer, "%02d:%02d:%02d.%03d", h, m, s, ms); //buffer time string
//file.print(buffer); //print the time
// log data and flush to SD
logfile << buffer << flush;
//Serial.println(" the header" );
}
Here is how I make my header for the SD file the first time that I save to the card.
void SDHEADER(){
// use buffer stream to format line
obufstream bout(SDbuf, sizeof(SDbuf));
// format data for sending to sd card
bout << ("Log Time") << ',' << ("RPM") << ',' << ("TPS") << ',' << ("IAP") << ',' << ("HO2") << ',' << ("HO2 Wideband") << ',' << ("IGN") << ',' << ("STP")
<< ',' << ("GEAR") << ',' << ("CLUTCH") << ',' << ("NT") << ',' << ("BOOST") << ',' << ("IP") << ',' << ("AP") << ',' << ("CLT") << ',' << ("IAT")
<< ',' << ("BATT") << ',' << ("PAIR") << ',' << ("FUEL1") << ',' << ("FUEL2") << ',' << ("FUEL3") << ',' << ("FUEL4") << ',' << ("HOX_ON") << ',' << ("MTS AFR")
<< ',' << ("New Data Rate %");
bout << endl;
// log data and flush to SD
logfile << SDbuf << flush;
}
Here is how I save my variables to the SD card. Notice that I am writing a CSV file so, I have "," commas saved between each variable saved.
void SDDATASAVES(){
// use buffer stream to format line
obufstream bout(SDbuf, sizeof(SDbuf));
displayResult(); // save the timestamp first
// format data for sending to sd card
bout << ',' << (Rpm) << ',' << (tps) << ',' << (Iap) << ',' << (Ho2) << ',' << (HO2_Wideband)<< ',' << (ign) << ',' << (Stp) << ',' << (Gear)
<< ',' << (szClutch) << ',' << (szNeutral) << ',' << (Boost) << ',' << (Ip) << ',' << (Ap) << ',' << (Clt) << ',' << (Iat) << ',' << (Battery) << ','
<< (Pair) << ',' << (Fuel1) << ',' << (Fuel2) << ',' << (Fuel3) << ',' << (Fuel4) << ',' << (Hox_On) << ',' << (Mts_Afr) << ','
<< (New_Data_Rate);
bout << endl;
// log data and flush to SD
logfile << SDbuf << flush;
}
I also wanted to let you know that this bit of your code is a complicated way of saying delay();, because nothing can happen during this time except this while loop.
while (time < cycletime+recive_send_delay) {
if (debug >= 2) console.println("waiting");
time = millis();
}