I'm trying to make a function to read the length of an array that is not created at compile time, but am having some trouble with it. My code looks something like this
char testdata[ ] = {0x09, 0x00, 0x56, 0x79, 0xC8}; //this is just for testing, real data is created during the program.
.
.
.
unsigned long dataLength(char data00[ ]){ //data is terminated with 0xC8
unsigned long i0 = 0;
while (data00[i0] != 0xC8) //read everything up until 0xC8
{Serial.write(data00[i0]); i0++; delay(600);} // Serial & delay included for debugging
return i0; //return length of the data
}
The program starts gets to 0xC8 and just keeps going. It never exits the while loop.
Any suggestions?