These the lines that are doing most of the work in the original program
for( str = strtok_r(stringBuffer, ",", &p); // split using comma
str = strtok_r(NULL, ",", &p) // get subsequent tokens
Investigate the strtok_r function to see whether it is of any help to you splitting the message at the #'s