Closed francescoc93 closed 7 years ago
I have commited the fix for that. Could you please confirm if it works now?
now doesn't provoke an exception, but i can't get the response from the device when the index of array is greater than 127
a workaround may be to set the size of the array to 128. The instruction register.compareAndSet(256, 1) will become register.compareAndSet(128, 1)
Unfortunately I haven't managed to reproduce the issue.
Another way around this bug is subscribing a listener and receiving updates continously. This way you don't have to invoke ask
method all the time.
i2cDevice.subscribe(new I2CListener() {...});
i2cDevice.startReceivingUpdates(messageLength);
Register type was promoted from byte to int in 2.3.5 and it fixes described bug.
There's a numerical overflow in "ask" method of FirmataI2CDevice class. The type byte in Java is signed. So, when the AtomicInteger return a value greater than 127, the value of variable "reg" is negative, and that, provoke an array index bound exception