I would like to have some advice regarding an application that I am building which requires handling data packets coming from an external device via USART. I should mention first that I am working with SAMD21 Microcontroller from Atmel and using Atmel Studio for development.
I am using a simple ring buffer to handle the incoming data over USART and once a message is received I set an event flag. Since the data packets are variable in length I am using a timeout on the packets so as soon as the timer runs out and no further data is received, the flag is set. Now, my task is waiting for port_MaxDelay on this event flag to be set, once the flag is set I read the ring buffer and evaluate the message. This is working as far as I can say until now.
What I want to ask here is, since the task has a vtaskdelay which means that if the incoming messages are very fast lets say if the task delay is 500 then any messages coming in this duration will be lost. How can I handle this case so that a complete communication is done without any messages lost and what are the general practices for handling such communication?
Thanks in advance. Hope to hear from someone soon.