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.
Traceback (most recent call last):
File "/home/lvuser/py/robot.py", line 268, in <module>
wpilib.run(MyRobot)
File "/usr/local/lib/python3.5/site-packages/wpilib/_impl/main.py", line 101, in run
retval = options.cmdobj.run(options, robot_class, **kwargs)
File "/usr/local/lib/python3.5/site-packages/hal/main.py", line 11, in run
return robot_class.main(robot_class)
File "/usr/local/lib/python3.5/site-packages/wpilib/robotbase.py", line 178, in main
robot.startCompetition()
File "/usr/local/lib/python3.5/site-packages/wpilib/iterativerobot.py", line 78, in startCompetition
self.robotInit()
File "/home/lvuser/py/robot.py", line 252, in robotInit
self.subsystems'drive'] = DriveSubsystem()
File "/home/lvuser/py/robot.py", line 39, in __init__
self.gyro.init()
File "/home/lvuser/py/ITG3200.py", line 142, in init
if not self.testConnection():
File "/home/lvuser/py/ITG3200.py", line 236, in testConnection
return self.getDeviceID() == 0b110100
File "/home/lvuser/py/ITG3200.py", line 246, in getDeviceID
return self.getRegisterBits(RA_WHO_AM_I, DEVID_BIT, DEVID_LENGTH)
File "/home/lvuser/py/ITG3200.py", line 268, in getRegisterBits
containingByte = self.getRegisterByte(register)
File "/home/lvuser/py/ITG3200.py", line 265, in getRegisterByte
return self.readI2C(register, 1)[0]
File "/home/lvuser/py/ITG3200.py", line 83, in readI2C
return self.i2c.read(register, count)
File "/usr/local/lib/python3.5/site-packages/wpilib/i2c.py", line 145, in read
return self.transaction([registerAddress], count)
File "/usr/local/lib/python3.5/site-packages/wpilib/i2c.py", line 84, in transaction
dataToSend, receiveSize)
File "/usr/local/lib/python3.5/site-packages/hal/functions.py", line 407, in i2CTransaction
raise IOError(_os.strerror(C.get_errno()))
OSError: Success
The gyro works in Java using the original, but I find it strange that the accelerometer produces the same error. I’ve verified the addresses and the other numbers.
My translated code:
http://pastebin.com/CKr5prZs
Original:
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.