so the first part says, if it has a < at the beginning and a > at the end, then the whole string has been revived.
Revived? Why, was it dead?
It says that the start of a packet begins with a <. Anything before that can be ignored. It says that once a < has been received, the following data should be stored in an array, until the > is received. When the > arrives, stop reading and recording the data, as a complete packet has been received.
then the second part gets the data (if all data has been recieved) through atoi(inData); then writes it to serial, correct? with or without the < >?
The data is received in the first part. It is processed, without the < and >, in the second part. That processing, in this snippet, consists of converting the packet to an int, printing the value, and storing it in an array.
but then what is this doing?
Storing the int in an array.
if(Serial.available() >= 0){
char number1[3] = { Serial.read(), Serial.read() , '\0'};
Serial.read();//flush the delim
char number2[3] = { Serial.read(), Serial.read() , '\0' };
Serial.read();//flush the delim
char number3[3] = { Serial.read(), Serial.read() , '\0' };
If there is at least one byte of data in the serial buffer, read 8 characters. Hmmm, something fishy, here.
A better proposition, in my opinion, is to send the data between packet markers, like the other code.
<123,6,89>.
This way, the data for each number is not limited to exactly 2 characters.
Then, use strtok() to get each token ("123", "6", and "89"), and pass each token to atoi(), to get 123, 6, and 89.
does it read up to the first comma then stores the data in a char, then reads up to the next comma and so on?
It has no awareness of the data that it is reading. It reads and stores two characters, although there may only be one available. Then it reads and discards a character, although there may none available. Then, it reads and stores two characters, although there may none available. Then it reads and discards a character, although there may none available. Finally, it reads and stores two characters, although there may none available.