If some data is available at the receiving terminal, the very first character that is read is stored in "inchar" (this is capable of storing only a single character right?). if the first character is the SOP, it sets index as 0 and clears the first element of array "inData" and sets the started and ended stuffs as true and false.
All true. Except that the reading happens in a while loop, so "the very first character" is a bit incorrect. It should be 'the next character".
Just to be pedantic, first can not be modified. Something can be very hot, where hot can take on shades of meaning from warm to hotter than the surface of the sun. Something is either first or it isn't. there are no degrees of first.
If it is an EOP, ended is made as true and loop is exited.
The while loop is exited, yes.
After detecting the SOP, and if data is still available, it again stores the value in "inchar" this time it is not an SOP and hence it checks for the "index" value. The index value was initialized wen the SOP was detected and hence now it'll be <199(in my case) and it stores the value in inData, then index is incremented and inData is cleared to store the next new character.
This is true.
Finally if started and ended flags are true, it resets all the values.
After the while loop ends, either because the end of packet marker arrived or because there was no more data to read, the flag are tested, and, if both are true, then everything is reset.
You are expected, of course, to have used the data before you reset things. In your case, apparently, this means storing MAC IDs and dates on an SD card.
dtafile.print(inData) will store the data that was read initially right?
That will store the whole packet on the SD card. It would make more sense, to me, to parse the data, and store each device's information as a separate record.
But, first things first.