View Single Post
  #1   Spotlight this post!  
Unread 11-02-2016, 19:24
nickbrickmaster's Avatar
nickbrickmaster nickbrickmaster is offline
Not Allowed Near Power Tools
AKA: Nick Schatz
FRC #3184 (Blaze Robotics)
Team Role: Leadership
 
Join Date: Jan 2015
Rookie Year: 2014
Location: Eagan MN
Posts: 149
nickbrickmaster is an unknown quantity at this point
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):
  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:
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.
__________________
I have approximate knowledge of many things.

FRC 3184: 2014-, FTC 10648: 2015-
Reply With Quote