# HG changeset patch # User Paul Boddie # Date 1421714455 -3600 # Node ID 082a1288126973d16c7cc3202474da62ec4af9dd # Parent e8f1b52c1d1755ec55e95ffe2898387bb6fa4202 Added a simple timeout to prevent the program from hanging. diff -r e8f1b52c1d17 -r 082a12881269 ArduinoAm29F010.cpp --- a/ArduinoAm29F010.cpp Tue Jan 20 00:58:34 2015 +0100 +++ b/ArduinoAm29F010.cpp Tue Jan 20 01:40:55 2015 +0100 @@ -163,7 +163,7 @@ bool waitForCompletion(int high, int low, int written) { - int data; + int data, then = millis(); do { @@ -171,7 +171,8 @@ data = readOp(high, low); } while ( ((data & 0x80) != (written & 0x80)) && - ((data & 0x20) == 0) + ((data & 0x20) == 0) && + (millis() - then < 2000) ); return readOp(high, low) == written;