View Single Post
  #1   Spotlight this post!  
Unread 06-08-2016, 19:19
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 325
fovea1959 will become famous soon enough
Receiving data from Arduino over i2c?

just doing some off-season tinkering.

Students got comms going from Java to a RIODuino over I2C just fine; the Arduino Wire library's receive_slave example hooks up perfectly to the WPIlib I2C class write methods.

We're stumped on receiving data from the RIODuino. We added a onRequest handler to the Arduino receive_slave example.

If we do a
Code:
boolean b = rioDunio.read(44, yy.length, yy);
the Arduino gets a 1 byte onReceive event with the 44 register number. The Arduino's onRequest event never fires off.

If we do a
Code:
boolean b = rioDunio.readOnly(yy, yy.length);
and yy is a 6 byte array, and we have the Arduino's onRequest handler do a
Code:
Wire.write("hello ");
we can see the Arduino's onRequest handler firing off, but the readOnly call always returns a true value (indicating an aborted transfer), and the returned buffer is always full of zeroes.

Has anyone successfully read data from an Arduino using I2C?

We're prepared to do serial (and know how), but we are really trying to figure out the pros and cons of both, and want to make sure that we have an accurate idea of limitations of I2C between a RoboRIO and Arduino...
Reply With Quote