{"action":"created","issue":{"url":"https://api.github.com/repos/jrowberg/i2cdevlib/issues/252","repository_url":"https://api.github.com/repos/jrowberg/i2cdevlib","labels_url":"https://api.github.com/repos/jrowberg/i2cdevlib/issues/252/labels{/name}","comments_url":"https://api.github.com/repos/jrowberg/i2cdevlib/issues/252/comments","events_url":"https://api.github.com/repos/jrowberg/i2cdevlib/issues/252/events","html_url":"https://github.com/jrowberg/i2cdevlib/issues/252","id":162070829,"number":252,"title":"Serious bug at Jeff Rowberg library with MPU6050 at Arduino","user":{"login":"batata004","id":8988923,"avatar_url":"https://avatars.githubusercontent.com/u/8988923?v=3","gravatar_id":"","url":"https://api.github.com/users/batata004","html_url":"https://github.com/batata004","followers_url":"https://api.github.com/users/batata004/followers","following_url":"https://api.github.com/users/batata004/following{/other_user}","gists_url":"https://api.github.com/users/batata004/gists{/gist_id}","starred_url":"https://api.github.com/users/batata004/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/batata004/subscriptions","organizations_url":"https://api.github.com/users/batata004/orgs","repos_url":"https://api.github.com/users/batata004/repos","events_url":"https://api.github.com/users/batata004/events{/privacy}","received_events_url":"https://api.github.com/users/batata004/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":22,"created_at":"2016-06-24T03:48:36Z","updated_at":"2016-10-11T16:17:02Z","closed_at":null,"body":"Sometimes my Arduino freezes or crashes when using JEFF ROWBERG library to read DMP data from MPU6050. It took me almost a full year to discover the problem and today I had some spare time and I tried to find where exactly arduino hangs/freezes.\r\n\r\nI discovered it is usually when executin getFIFOCount() or getIntStatus(). I discovered that inserting many Serial.print with tags along my entire code so I could know exactly which line hanged. So I discovered everytime my arduino hanged/freezes it was at a line with getFIFOCount() or getIntStatus(). So I decided to take a close look at it.\r\n\r\nInside the file MPU6050.cpp there is a code like this:\r\n\r\nuint16_t MPU6050::getFIFOCount() {\r\n    I2Cdev::readBytes(devAddr, MPU6050_RA_FIFO_COUNTH, 2, buffer);\r\n    return (((uint16_t)buffer[0]) << 8) | buffer[1];\r\n}\r\n\r\nI checked the function \"readBytes()\" inside I2Cdev.cpp and I found this:\r\n\r\nI2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout)\r\n\r\nYou see the problem? The function readBytes accepts one last parameter which is \"timeout\" but the function getFIFOCount uses readBytes without the timeout parameter! That's probably a bug cause sometimes I think the readBytes takes too long to execute and a TIMEOUT SHOULD BE set to avoid the function hanging out forever.\r\n\r\nI am pretty sure maaaany MAAAANY other people alterady experienced this problem and spent a lot of time trying to understand what went wrong. Some people mistakenly believe it's related to bufffer overflow in the FIFO or because of some non optimized code. It could be the problem but MY PROBLEM FOR ALMOST A FULL YEAR has been this bug reported here.\r\n\r\nI really hope someone fix this and add a timeout so nobody would spent entire months anymore seeking a problem that's is really hard to track an intermitent."},"comment":{"url":"https://api.github.com/repos/jrowberg/i2cdevlib/issues/comments/252966528","html_url":"https://github.com/jrowberg/i2cdevlib/issues/252#issuecomment-252966528","issue_url":"https://api.github.com/repos/jrowberg/i2cdevlib/issues/252","id":252966528,"user":{"login":"batata004","id":8988923,"avatar_url":"https://avatars.githubusercontent.com/u/8988923?v=3","gravatar_id":"","url":"https://api.github.com/users/batata004","html_url":"https://github.com/batata004","followers_url":"https://api.github.com/users/batata004/followers","following_url":"https://api.github.com/users/batata004/following{/other_user}","gists_url":"https://api.github.com/users/batata004/gists{/gist_id}","starred_url":"https://api.github.com/users/batata004/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/batata004/subscriptions","organizations_url":"https://api.github.com/users/batata004/orgs","repos_url":"https://api.github.com/users/batata004/repos","events_url":"https://api.github.com/users/batata004/events{/privacy}","received_events_url":"https://api.github.com/users/batata004/received_events","type":"User","site_admin":false},"created_at":"2016-10-11T16:17:02Z","updated_at":"2016-10-11T16:17:02Z","body":"Thanks jeff and I didnt want to offend you. No. I appreciate your help, but I think it would be smart to let people know that your library sometimes crashes. Yes, I executed this same code many times with no problem. But sometimes when I just add some lines of code it gets completely unstable, and after a while it does not generate any other problem.\r\n\r\nJeff, I dont have bad wiring, this is not my case. The wires are very well connected to arduino.  I realized this bug happens when you call mpu.getFIFOCount() too many times in small time frame. It almost always freezes at mpu.getFIFOCount() (right when it gets executed). I know that for a fact cause I puted serial.println before and after that function, and it freezes the only the first serial.println.\r\n\r\nYou library may work fine in a moment, in another it just does not work. Adding some lines make the code break sometimes, and other times dont (there is no conflict between your code and those new lines).\r\n\r\nJeff, I appreciate your attention and efforts into this library but something is not right. Maybe you are right and it's bad wiring, but in my case it surelly is not. I tested this setup in other arduinos and got similar results.\r\n\r\nI dont know if you ever heard of SEBRAE here in Brazil. It's an education institution \"for free\", with small fees. I know at least 2 good friends which are teachers of this institution in electronics and also confirmed the problem I was facing. It was them who made me come here and report this. \r\n\r\nI tried to report this problem in many different foruns and in almost all cases, in the middle of the thread, other people confirmed what I said and had the same problem with different setups.\r\n\r\nIf you think this problem happens of because of some lines of I2C getting LOW, why cant you setup and interrupt in your code to check if the line is LOW for too long and maybe reset the device it that timeout happens? I never used an original arduino, I always used clones, maybe some poor build in those clones cause this problem? \r\n\r\nSorry if I disrespected you, you are a nice guy who devoted lots of time to this library however I think, IMHO, that it's not safe using your library in quadcopters, robotic arms... someone could get seriously hurt."}}
{"actor":{"display_login":"batata004"}}