Community
cancel
Showing results for 
Search instead for 
Did you mean: 
HDown
Beginner
874 Views

Trouble reading multiple bytes from I2C device using MRAA and Javascript

I've been trying to read several (i.e. > 2) bytes from a given register of a device on a I2C channel.

I know in C there is a call readBytesReg listed in the documentation (http://iotdk.intel.com/docs/master/mraa/classmraa_1_1_i2c.html mraa: I2c Class Reference):

http://iotdk.intel.com/docs/master/mraa/classmraa_1_1_i2c.html# a811fabe49072ede2144d3118b5b8ba8f readBytesReg (uint8_t reg, uint8_t *data, int length)

 

but in the Javascript documentation (http://iotdk.intel.com/docs/master/mraa/node/classes/i2c.html# method_I2c I2c), there is no equivalent listed. In the debugger, I see the function attached to my I2C object

but I'm not sure what the parameters are. I tried this:

 

var buffer = this.i2cChannel.readBytesReg(register,numToRead) ;

 

and I thought it was working but I'm having trouble with one call in which the numToRead parameter equals 3. I keep getting an "I2c write failed" message.

 

Can anyone tell me if (1) this call does exist and works within the Javascript bindings and (2) is this the correct way to call it.

 

Thanks!

 

 

Tags (1)
2 Replies
Sergio_A_Intel
Employee
29 Views

Hi,

Do you mind posting the full error log and the code you are using? From just "I2c write failed" it's hard to tell if the error was because of the different syntax used in the mraa and Javascript documentation.

You also mention debugging; do you have the output of the debugging log?

Are you using the mini breakout board or the Arduino expansion board? What image version and mraa version are you using?

Sergio

HDown
Beginner
29 Views

Hi Sergio,

I found the error...turned out to be unrelated in that the chip wasn't coming up. Still it would be nice to have the Javascript version of the documentation (http://iotdk.intel.com/docs/master/mraa/node/classes/i2c.html# method_I2c I2c) reflect the availability of the call and the format.

MRAA version 0.6.2

Yocto...configure_edison --version doesn't work so probably old

Cheers,

Hunter