Go to Post I may not like the songs, but I love FIRST! :) - ScoutingNerd175 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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: 151
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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 06:26.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi