Hello I found an Arduino project that works with serial port parsing and it had very interesting parsing code. I am trying to use it in my project but I still don't understand some lines and what is going there. (I marked them with ???).
char inData[82]; //create 82 char array
byte index = 0; //index byte (0 - 255)
String string_convert; //String
int PCdata[20]; //int array
void setup() {
Serial.begin(9600); //init port
}
void loop() {
parsing(); //loop the function
}
void parsing() {
while (Serial.available() > 0) {
//while there is data in serial buffer (128 bytes)
char aChar = Serial.read(); //aChar - current symbol in buffer
if (aChar != 'E') {
//if aChar isnt the 'E' (End) symbol do:
inData[index] = aChar;
//(inData - array, index - loop № counter) write all Buffer to the array
index++; //index + 1 - loop count
inData[index] = '\0';
//set the next position to '\0' or null symbol
} else {
//if aChar or current buffer symbol is 'E' (End) do:
char *p = inData; //create inData address pointer
char *str; //create pointer
index = 0; //set counter to 0
String value = ""; //create string
while ((str = strtok_r(p, ";", &p)) != NULL) { //???
string_convert = str; //???
PCdata[index] = string_convert.toInt(); //???
index++; //counter + 1 - loop count
}
index = 0; //counter to 0
}
}
}
Thank you for help!