Hi All,
I have searched the forum for a way to get the length of a uint8_t*, but to no avail. Many posts using this datatype have a specified length, but I do not know what the length will be. I guess there is a way to do it, and I have played with/searched for length, len(), size, etc But no luck yet, hope someone here can help.
I have an Arduino with Xbee in API mode receiving data. I am trying to get the data into a string eventually. To get the data from the package I received, I do:
uint8_t* rxData = rx.getData();
Then I want to go through all the elements in rxData and convert them to byte. With a testprogramm I send “Hello World!” and I am able to convert that into readable format using:
Serial.print(rx.getData(0), BYTE);
Serial.print(rx.getData(1), BYTE);
Serial.print(rx.getData(2), BYTE);
Serial.print(rx.getData(3), BYTE);
Serial.print(rx.getData(4), BYTE);
Serial.print(rx.getData(5), BYTE);
Serial.print(rx.getData(6), BYTE);
Serial.print(rx.getData(7), BYTE);
Serial.print(rx.getData(8), BYTE);
Serial.print(rx.getData(9), BYTE);
Serial.print(rx.getData(10), BYTE);
Serial.println(rx.getData(11), BYTE);
But that is only useful if I know up front how much data is coming. How could I get from an unknown length to a String on which I can do the various manipulations I want to do? (concat another string, split up, etc)
Regards,
Arno
p.s. I am currently using a fixed length but that is set way higher than what is needed, just in case. I would like to know so the code uses the minimum amount of memory.