![]() |
I2C Error on read() or write()
I'm trying to use the ITG3200 gyro on the AndyMark breakout board (am-2314). I translated some code I found from Java to Python, which you can find on PasteBin below, along with the original.
I'm getting the below error when both using my custom ITG3200 class and the ADXL345_I2C class. Code:
Traceback (most recent call last):My translated code: http://pastebin.com/CKr5prZs Original: https://github.com/bussell/SparkFun6...roITG3200.java RobotPy is 2016.2.0 on robot and driver station. Is this a bug in robotpy or am I messing up somewhere? Thanks for the help. |
Re: I2C Error on read() or write()
Quote:
What value are you passing in for 'port' to the I2C constructor? I ask because I see that in HAL it checks to see if port < 0, and returns -1 if so -- which wouldn't set errno (and perhaps why you're seeing the 'success' message). I'll add a check for that so it can't happen in the future... This error also reminds me of this bug that someone reported for WPILib. |
Re: I2C Error on read() or write()
Also, once this works, it'd make for a nice pull request to robotpy-wpilib-utilities. Just saying. :)
|
Re: I2C Error on read() or write()
Another thought. The java I2C function does not throw if there's an error, it just returns true. Can you add some error checking to the java code (maybe throw an exception if it returns false from i2c.read?), rerun it, and see if you get an error?
|
Re: I2C Error on read() or write()
Thanks for the suggestions. The port is I2C.Port.kOnboard. I don't have access to the robot at the moment, but I'll test the Java code later.
|
Re: I2C Error on read() or write()
Thanks for the help. Turns out that I had connected the board incorrectly, and that the data I was getting from Java was random noise, which I did not get in Python because I never ran initialize() in Java.
Again, thanks for the help. I got the gyro working. It still throws an error every once in a while (but good data otherwise), which the code catches and replaces with an array of zeroes. I'd like a better solution, and to get to the bottom of the I2C errors, but that is a project for later. I'll definitely add it to robotpy-wpilib-utilities once decoding and calibration is all figured out. |
| All times are GMT -5. The time now is 19:52. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi