Yo Ho HO!
I am working on a commercial application where I am going to receive a few simple commands in ASCII and the application will send back various status information from a couple of sensors.
I have always used a simple receive buffer such as:
and then in my USART ISR I have a simple pluck the byte from UDRx, and put it in the buffer and increment the write-to counter by one. Should the received byte be the \r or \n then a flag is set to indicate the EOL. and the main code then reacts to the buffer contents when it sees the EOL flag.
Simple enough, and this would work just fine in this application.
So, heres the deal. When I use CodeVisons wizard it always sets up a circular buffer. I always convert it to my simple array type of buffer as the circular buffer always confuses me. I have read teh wikipedia on circular buffers and have been reading the online articles about their implementation and my takeaway is this:
1) They can be either fill and wait, or fill and overwrite
2) They have separate write and read indexes.
3) They are good for constant stream data.
4) They store the most recent data when used in overwrite mode.
I am sure there are more that I havent come up with.
So that being said, for simple intermittent command/react data, do I need to use the circular buffer? The commands are not coming in constantly, more like every 10 seconds to one minute.
Does it even matter which one I use? Since I am sensing an EOL termination, the Wizard generated ring buffer is essentially being used as an array type buffer anyway correct?
Should I reset the write and read indexes after I finish reading the data out of the buffer,>>like a regular array type buffer<< or should I simply leave them be and just write/fetch from the next available location?