Arduino serial read

Status
Not open for further replies.

dr pepper

Well-Known Member
Most Helpful Member
If I got this right:
If I have some data in the serial buffer, then I go serial.read the processor will read the first byte of data in the buffer, executing serial.read successive times reads the next byte and the next.
So there must be a pointer, is there a way I can reset said pointer to zero.
I want to mod some existing software and make it 'think' the serial buffer hasnt been messed with.
 
Can't you do
Code:
while(Serial.available())
      dummy = Serial.read();

Mike.
Edit, you can also do Serial.flush() to wait until the output buffer is empty. In an earlier version this also cleared the input buffer but not any more.
 
There isnt a function call to clear the pointer but there is an rxbuffer pointer in the .h file, but its a protected not a public variable.
There are several routines in my code that use serial, all copied & pasted from other programs I've bodged that only had one routine that looked at serial, pom's idea is a way to do it, use a dummy array for the incomming serial, only thing is I'd have to modify every function using serial, not the end of the world I spose.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…