Hi everybody,
I've tried to find a solution to freezing situations of the Arduino Uno Wire Library.
For details, the functions twi_writeTo and twi_readFrom contain some while loop and it can be impossible to exit without a reset.
Attached is my solution to solve these problems.
The file wire.c must be replaced by the new one in folder C:\arduino-1.0.6\libraries\Wire\utility (adapt the path).
twi.c (17.8 KB)
jmparatte: I just came across this posting linked from some others. I have spent hours trying to figure out a solution to my Wire.endTransmission() and reading the posts from others (all helpful but no solution worked so far). I have 2 Unos on a I2C: the sender hangs when the other Uno is unplugged. I am new to programming and Arduino: If I learn "C" will I then be able to understand the workings of twi.c? Thank you for the advice in advance: I will try your twi.c now.
I am running Arduino 1.8x and I have 2 Uno R3 connected via I2C. I just replaced the stock twi.c with yours (exact same file name, exact same location) and this is the error I got trying to compile. I apologize but I do not know anything beyond Arduino interms of programming so the compile error as well as the twi.c file is Greek to me 
Thank you for any and all help!
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_readFrom'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_writeTo'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_transmit'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_init'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_setAddress'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_attachSlaveRxEvent'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_attachSlaveTxEvent'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_reply'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_stop'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
libraries\Wire\utility\twi.c.o (symbol from plugin): In function `twi_readFrom':
(.text+0x0): multiple definition of `twi_releaseBus'
libraries\Wire\utility\STOCK ARDUINO LIB twi.c.o (symbol from plugin):(.text+0x0): first defined here
SamBrownADK:
I am running Arduino 1.8x and I have 2 Uno R3 connected via I2C. I just replaced the stock twi.c with yours (exact same file name, exact same location) and this is the error I got trying to compile. I apologize but I do not know anything beyond Arduino interms of programming so the compile error as well as the twi.c file is Greek to me 
Thank you for any and all help!
Hi SamBrownADK,
TWI is probably one of the most complex peripheral of UNO. I continue to work on Wire Library and its dependences (twi.h, twi.c) but I'm not ready to publish a common alternative to Wire.h because there are lot of I2C cases. For example, I've written a new LiquidCrystal_I2C without any kinds of delay (LiquidCrystral delays and Wire delays).
I've never checked the case of I2C communication between to Arduino. I prefer to use a Serial port.
OK, thanks. I just googled the serial port to try to see how to use that as well... maybe that is my best route.. Thank you again!