sandeepmistry / node-chip-io

Johnny-Five IO Plugin for the Next Thing Co. C.H.I.P.
MIT License
96 stars 28 forks source link

I2C over hard-coded /dev/i2c-1 not working #11

Closed ugate closed 8 years ago

ugate commented 8 years ago

I tested a PCA9685 with chip-io (master branch) and noticed that nothing was happening using the johnny-five example. It looks like errors are just consumed in i2c.js so there's no way of knowing unless debugging (headless chip, used node --inspect flag with devtools from remote PC). Maybe a better approach when encountering errors would be to emit an error event instead of throwing or ignoring? I noticed that chip-io.js uses a hard-coded 1 for the bus value in /dev/i2c-1 here and here, but a ls /dev only shows i2c-0 and i2c-2 (Linux 4.4.11-ntc).

@rwaldron I'm trying to understand what the proper way to pass in the bus identifier when using the johnny-five API/Board.i2c functions for boards that support more than one I2C bus?

rwaldron commented 8 years ago

Platform specific bus property support needs to be handled by the IO Plugin—all Johnny-Five does is forward the options passed to the component class constructor, through to the the i2cConfig(...) call.

rwaldron commented 8 years ago

What version of Node.js is on the Chip?

rwaldron commented 8 years ago

nvm, I see that this project points to the nodesource install instructions—very smart.

rwaldron commented 8 years ago

I just found this: https://github.com/xtacocorex/CHIP_IO/issues/11

rwaldron commented 8 years ago

@ugate This should allow you to specify the bus as shown in the following:

var a = new five.Servo({
  bus: 1,
  address: 0x40,
  controller: "PCA9685",
  pin: 0,
});
ugate commented 8 years ago

@rwaldron Thanks for the update! I noticed the same thing on #9. What threw me off is the docs that state that Board.i2cConfig([milliseconds]) takes an optional millisecond parameter rather than an object of options. Should the docs be updated to reflect an options object instead?

sandeepmistry commented 8 years ago

@ugate it would be awesome if you could submit a pull request to the Johnny Five docs your Board.i2cConfig([milliseconds]) observation.

ugate commented 8 years ago

@sandeepmistry done :+1: