esp32-i2c-mpu6050 icon indicating copy to clipboard operation
esp32-i2c-mpu6050 copied to clipboard

r[0] ?

Open thealch3m1st opened this issue 8 years ago • 2 comments
trafficstars

In mpu6050.cpp, line 70 you declare uint8_t r[0]; and then you read 2 bytes into it.

I don't really understand what's happening here. Could you please explain what's going on?

I would like to know: Why did you do that? Where is the memory for r? What are the consequences/limitations of doing this? Any additional information you think is relevant :)

Thanks

thealch3m1st avatar Nov 19 '17 18:11 thealch3m1st

I believe it is a mistake. Although the code works, the memory is never allocated for r. It may point to anywhere and risk crashing the program. Since I don't have MPU6050 at hand, I can't test if it works well afterwards. Maybe you can correct it and open a pull request :)

imxieyi avatar Nov 20 '17 05:11 imxieyi

Sorry for the late reply. Thanks for explaining. When I tried it it seemed to have been working fine. I will probably submit a PR soon :)

thealch3m1st avatar Dec 06 '17 21:12 thealch3m1st