Hey folks … I was hoping some of you might cast your eye over my code.
It splits up a string read from EEprom into an array of separate strings. Based on String length information stored in a separate array. (tempArray[])
It reads fine … and also seems to process fine (ie. it does turn one long string into separate array items) for some reason it stops working no the 8th array item?
The splitting code (problem) starts on line 80 and i have included the output above it in comments.
http://pastebin.com/Ax4R6t6J << Full code also available here.
void reJigFromMemory(){
Serial.print("Eeprom read 1 :");
Serial.println(eepromReadOne);
Serial.print("EEprom read 2 :");
Serial.println(eepromReadTwo);
String tempArray[10];
int charLength=eepromReadOne.length()+1;
char charBuff[charLength];
eepromReadOne.toCharArray(charBuff, charLength);
//// GET MEMORY LOCATIONS
/*
converts long string of numbers:
13161717171717252533
into separate strings:
13
16
17
17
17
17
17
25
25
33
And stores them in an array.
*/
for (int i = 0; i <10 ; i++){
tempArray[i]+=charBuff[i*2];
tempArray[i]+=charBuff[(i*2)+1];
Serial.print("I just translated :");
Serial.println(tempArray[i]);
}
/// GET THE STRINGS USING THE ABOVE ARRAYS
/*
converts long list of data ie:
|0|Bingo#999#|1|Retest2#9222#|2|Retest3#92299#|3|Retest4#99339#|4|Retest5#95599#|5|Retest6#96699#|6|Retest7#99119#|7|User Defined eighth#0#|8|User Defined ninth #0#|9|User Defined tenth (last) .#0#
into individual array strings:
From Number = :0
To number : 13
Record 0 : |0|Bingo#999#
From Number = :13
To number : 29
Record 1 : |1|Retest2#9222#
From Number = :29
To number : 46
Record 2 : |2|Retest3#92299#
From Number = :46
To number : 63
Record 3: |3|Retest4#99339#
From Number = :63
To number : 80
Record 4: |4|Retest5#95599#
From Number = :80
To number : 97
Record 5: |5|Retest6#96699#
From Number = :97
To number : 114
Record 6 : |6|Retest7#99119#
From Number = :114
To number : 139
Record 7 : <<<<<< THIS ONE IS MISSING ? WHY?
From Number = :139
To number : 164
Record 8 : <<<<<< THIS ONE IS MISSING ? WHY?
From Number = :164
To number : 197
Record 9 : <<<<<< THIS ONE IS MISSING ? WHY?
*/
String tempArray2[10];
int fromLocation = 0;
int toLocation=0;
for (int i = 0; i <10 ; i++){ /////// LINE 80
toLocation += tempArray[i].toInt();
fromLocation += tempArray[i-1].toInt();
tempArray2[i]=eepromReadTwo.substring(fromLocation,toLocation);
Serial.print("From Number = :");
Serial.println(fromLocation);
Serial.print("To number : ");
Serial.println(toLocation);
Serial.print("I just translated :");
Serial.println(tempArray2[i]);
}
}
fromLocation += tempArray[i-1].toInt();
wherei=0
: behavior there is undefined (may crash immediately or override memory used later...) – jfpoilpret Oct 6 '14 at 20:51