Im using a modificated void for setting the time of a DS3232 RTC IC. The problem is, that the code is very buggy, when the circuit is reset or someting is transmitted over serial. Because of that, i want to use a preffix and suffix with the time code.
Currently my windows cmd applications sends:1329002001137
I want this convert to: S1329002001137X
Could someone help me with this? My current code is below!
void setSerialTime() {
if (Serial.available() > 0) {
int i = 0;
//read incoming
memset(incoming, 0, sizeof(incoming));
//time will be send in format HHmmssddMMyyw, z.B. 1329002001137
while (Serial.available() > 0 && i < sizeof(incoming) - 1) {
incoming[i] = Serial.read();
i++;
delay(3);
}
char SIhr[3] = {};
char SImin[3] = {};
char SIsec[3] = {};
char SIday[3] = {};
char SImonth[3] = {};
char SIyr[3] = {};
char SIweekday[2] = {};
SIhr[0] = incoming[0];
SIhr[1] = incoming[1];
SImin[0] = incoming[2];
SImin[1] = incoming[3];
SIsec[0] = incoming[4];
SIsec[1] = incoming[5];
SIday[0] = incoming[6];
SIday[1] = incoming[7];
SImonth[0] = incoming[8];
SImonth[1] = incoming[9];
SIyr[0] = incoming[10];
SIyr[1] = incoming[11];
SIweekday[0] = incoming[12];
byte Ssecond = atoi(SIsec); //0-59
byte Sminute = atoi(SImin); //0-59
byte Shour = atoi(SIhr); //0-23
byte SweekDay = atoi(SIweekday); //0-6 -> sunday - Saturday
byte SmonthDay = atoi(SIday); //1-31
byte Smonth = atoi(SImonth); //1-12
byte Syear = atoi(SIyr); //0-99
RTCsetTime(Ssecond, Sminute, Shour, SweekDay, SmonthDay, Smonth, Syear);
printTime();
printTime();
}
}