-
• #2
If you do:
try { I2C3.readFrom(...); } catch (e) { console.log("Oops"); }
then it should work? your inability to catch the error might be because your External_Clk function is itself called from a timeout?
Worst case you can use
uncaughtException
, but that's a bit of a hack :) http://www.espruino.com/Reference#l_process_uncaughtException -
• #3
Thanks @Gordon for the prompt reply.
I'll try your suggestions later today.
It may be a bit more complex but that makes it fun. (see snippet)
Send reset or change clock and then catch the error and retry on a subsequent read of a status register using the snippet./** Readbyte(BusAddress,SubAddress) */ BNO055.prototype.ReadByte=function(subAddress){ var data=Uint8Array(1); this.i2c.writeTo(this.BusAddress, subAddress); data=this.i2c.readFrom(this.BusAddress, 1); return data[0]; };//end ReadByte
The error message
Uncaught InternalError: Timeout on I2C Read Receive
The usual suspect are pull up resistors
Other causes
You send a command via I2C that causes the device to require a delay before it is ready to talk I2C again.
Examples for the BNO055 are reset, change clock between internal and external
One solution is to use a callback
Is there a way to throw and catch the error and then try again N times or until the error clears?
The external clock function with callback