Skip to content

TwoWire::flush(void) to flush rxBuffer missing #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RobTillaart opened this issue Oct 7, 2013 · 3 comments
Closed

TwoWire::flush(void) to flush rxBuffer missing #253

RobTillaart opened this issue Oct 7, 2013 · 3 comments
Assignees
Labels

Comments

@RobTillaart
Copy link

Missing in Wire lib is the flush() which can be quite straightforward.

void TwoWire::flush(void)
{
  rxBufferIndex = 0;
  rxBufferLength = 0;
}

maybe it should be called rxFlush() to allow a txFlush() in the future.

This allows one to flush the receive buffer e.g. after reading first byte which indicates the type of the answer.

if (Wire.Read() != 5)
{
  Wire.flush();
}
else processBuffer();
@sngl
Copy link

sngl commented Feb 28, 2014

Hello @RobTillaart ,
usually the flush() function is used to wait that all the data present in a buffer is transmitted/processed (see Serial.flush() ) and not to clear the rxBuffer.
That flush function you implemeted can be misleading if some user used other flush functions.

@RobTillaart
Copy link
Author

Thanks, I've looked at Serial.FLush() and understand the interpretation

Maybe the function I needed can be called

Wire.clearRxBuffer()
{
rxBufferIndex = 0;
rxBufferLength = 0;
}

@sandeepmistry sandeepmistry transferred this issue from arduino/Arduino Sep 16, 2019
@sandeepmistry
Copy link
Contributor

I'm marking this as won't fix, flush() is intended for TX only and is not needed in the Wire lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants