dump icon indicating copy to clipboard operation
dump copied to clipboard

Usage of Wire.requestFrom() and bug with local scope of buffer.

Open Koepel opened this issue 8 years ago • 0 comments

Hi, I don't know the purpose of this "dump" repository, but I noticed some issues. With a casual glance, you probably can spot them immediate when looking at the code.

In the file "dump/arduino/ard-04/lilypod.ino", the while-loop between Wire.requestFrom() and the Wire.read()s is not needed. There is not need to wait for something.

In the file "dump/arduino/ard-06/hmc5883l.cpp", in the function "Read()", the Wire.requestFrom() should not have the Wire.beginTransmission() and Wire.endTransmission(). A serious bug is the pointer that is returned, because the buffer is out of scope as soon as the function returns. A quick and dirty fix is to make the buffer static. It's dirty, I know. There is no original for the loveelectronics.co.uk code on github. I also mentioned the issue here: https://github.com/landis/arduino/issues/2

Koepel avatar Sep 09 '17 21:09 Koepel