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

Logic can infinite loop while using Wire API incorrectly. #17

Closed
nkolban opened this issue Dec 26, 2015 · 2 comments
Closed

Logic can infinite loop while using Wire API incorrectly. #17

nkolban opened this issue Dec 26, 2015 · 2 comments

Comments

@nkolban
Copy link
Collaborator

nkolban commented Dec 26, 2015

I recently came across a sketch that had coded:

Wire.beginTransmission(0x77);
Wire.receiveFrom(0x77, 1);
...

In principle, this is bad logic as we are asking for the start of an I2C write and then immediately asking for the star of an I2C read... however, despite being bad, it shouldn't crash (lock up) the logic. When Wire.receiveFrom is called in this example, it locks up and does not return. Nothing is transmitted on the I2C bus.

@me-no-dev
Copy link
Owner

This is because of my thread safety implementation in cases whan you have threads running and two threads want to write to the Wire bus. Need to investigate that a bit further and maybe try to distinguish the threads and only when there are two or more threads trying to access it, then it should lock in between (the second thread that wants to gain access)

@me-no-dev
Copy link
Owner

I removed that functionality and I'm closing this ticket

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

No branches or pull requests

2 participants