Thread: I2C advice
View Single Post
  #8   Spotlight this post!  
Unread 03-11-2014, 14:46
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: I2C advice

Quote:
Originally Posted by 2B || !2B View Post
Are you referring to a master I2C class, or a master GY-85 class? The FIRST I2C class kept hanging up the robot because it would start another transaction when another was already active. I'm just making this class to make sure that doesn't happen, and to make the code look cleaner and nicer to read in general.
Perhaps I'm reading too much into your choice of name. I think you should attempt to write a class that is capable of interacting with the sensor you care about and nothing more. Speculative generality is your enemy. It will add complexity and give you nothing positive in return. You can always refactor in the future when you have new requirements.

I'm surprised that the Java class allowed more than one write at a time to the I2C bus. I haven't looked to see if that is a bug or a misunderstanding. Certainly on the new roboRIO that should not be possible due to the Linux device driver that must be talked to on the new system. Your class should not need to deal with this level of synchronization.