Skip to content
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

The underlying i2c implementation would always block infinitely on reads #45

Merged
merged 1 commit into from
Oct 2, 2021

Conversation

obra
Copy link
Contributor

@obra obra commented Oct 1, 2021

The underlying i2c implementation would always block infinitely on read events if it didn't get an answer from the i2c device.

This change adds the same timeout countdown we use elsewhere in the library.

…ad events if it didn't get an answer from the i2c device.

This change adds the same timeout countdown we use elsewhere in the library.
@obra obra requested a review from maxgerhardt October 1, 2021 23:37
@obra
Copy link
Contributor Author

obra commented Oct 1, 2021

We should discuss before merging this. It's specced as a blocking read in the code comments, but I can't believe it's supposed to be a "lock your program hard" blocking read.

@obra
Copy link
Contributor Author

obra commented Oct 1, 2021

@maxgerhardt maxgerhardt merged commit f2babd5 into main Oct 2, 2021
@maxgerhardt
Copy link
Member

It's good that there's a timeout now, eventually we should move to specifying timeouts as microseconds because that's what e.g. the AVR Wire library is doing

https://github.com/arduino/ArduinoCore-avr/blob/master/libraries/Wire/src/utility/twi.c#L216-L223

The Wire library is riddled with simply decrement-counter CPU delays which are extremely CPU clock sensitive.

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

Successfully merging this pull request may close these issues.

2 participants