How to read a char from FullDuplexSerial without removing it from buffer?
william chan
Posts: 1,326
Hi,
Actually I am using FullDuplexSerial_rr004 which is quite similar.
Does anyone know how to read a char received without removing it from the receive buffer?
Thanks.
Actually I am using FullDuplexSerial_rr004 which is quite similar.
Does anyone know how to read a char received without removing it from the receive buffer?
Thanks.
Comments
I have to ask... why??? There is probably a better way to handle your business logic.
You will notice it is just the routine Rxbyte with the buffer decrement line removed.
If you just want to know if there is a char in the buffer you can use Rxavail.
-Phil
I just change this line
rx_tail := (rx_tail + 1) & bufmsk
to become
rx_tail := rx_tail & bufmsk
for the lookahead method?
Thanks.
I should remove this line
rx_tail := (rx_tail + 1) & bufmsk
totally for the lookahead method right?
I feel so stupid, thanks Cluso and Mike.
I'm not sure if it would be useful in your case or not, but I modifed Tim Moore's four port serial driver to watch for an end of message character.
With a 512 byte rx buffer, I just let the message sit in the rx buffer until it's complete and then process the message. It has really simplified a lot of my projects. I don't have to continually move bytes from one buffer to another as I watch for the final byte of the message.
The modified driver is attached to post #9 of this thread.