Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When initiating an I2C communication as master, there is a chance of losing arbitration of the bus if there are other masters on the bus. This is a perfectly normal scenario and it is handled by trying to start the communication again. If arbitration was lost during the first try, now the bus state is busy so the second call to startTransmissionWIRE will wait until the bus is idle again before retrying.
I made this change on my MKRZERO over a month ago and since then I didn't have any more errors. I have a system with 7 masters on the same I2C bus sending messages at about 10Hz each, so loss of arbitration happens frequently (2 masters starting to communicate at the same time). One of the 2 gets priority over the other while the other loses arbitration. The loser simply retries the communication when loss of arbitration is detected, and everything works smoothly without data loss.
Without this check we can't be aware of any loss of arbitration and the library would detect the NACK without understanding that it was not a real NACK from the slave.