Closed captain1991cv closed 5 years ago
It's a fairly long post, but the way i2c-bus categorizes and handles errors is described here.
In the code posted above, 0xff is passed to i2cRead
as the I2C device address. 0xff is not a valid I2C address. A valid I2C address is a integer >= 0 and <= 0x7f. Passing anything that is not a valid I2C address to i2cRead
is regarded as a programming error or bug and results in an error being thrown. Note that throwing an error is the correct way for the asynchronous i2cRead
method to handle the programming error.
The programming error or bug in this case is that the program forgot to validate the user input of 0xff. If the program is modified to validate the user input it can avoid passing the invalid address to i2cRead
and the error will not be thrown.
Hi @fivdi
I'm using your library in my code, im gonna illustrate my problem in a short code, when i run the fallowing code, im expecting to see
console.log("errorOnServer", err);
on the screen:But, what I'm getting is this:
I'm receiving my Address directly from the user. How can I handle this ?