These are chat archives for nebrius/raspi-io

11th
Jun 2015
Peter Mellett
@wadtech
Jun 11 2015 09:40
Hi chaps, I'm having a node crash when the i2c read is giving input/output error. We've got our magnetometer at the end of a ludicrously long cable (so this is obviously the culprit)
it's fine that the reading isn't strong enough, the real issue is: is it possible to handle those i2c read errors in my app?

like

compass.on('error', function(){}) 

style?

If this should be directed more towards johnny-five let me know
Brian Cooke
@fivdi
Jun 11 2015 11:26
The error is emitted by the corresponding Raspi object here: https://github.com/bryan-m-hughes/raspi-io/blob/master/index.js#L456, so I guess it should be possible to listen for the event on the Raspi object, which would be the one passed to the five.Board constructor like it is here: https://github.com/bryan-m-hughes/raspi-io/blob/master/test/two-devices.js#L6. However, even if this works, I'm not sure if it's the correct usage pattern.
Brian Cooke
@fivdi
Jun 11 2015 11:32
Hmm..., maybe the error is happening during initialization and not during read. If this is the case, the synchronous write methods are used and an error will be thrown, an 'error' event will not be emitted, but it should be possible to catch the error.
Peter Mellett
@wadtech
Jun 11 2015 14:10
I can replicate the error by unplugging my i2c device mid-flow (which is basically what was happening in a low-power situation) thanks for the ideas @fivdi , I'll have a play around.
Peter Mellett
@wadtech
Jun 11 2015 14:28

Huh, it also seems that the Button class isn't successfully setting the pin mode. For whatever reason the button I've been supplied with (on wiringPi 25 to ground with no external pullup) only works when the pin mode is OUTPUT.

        this.io.pinMode(this.pin, this.io.MODES.OUTPUT);

on line 26-ish of button.js doesn't appear to be doing the trick.

(I've edited that line to select OUTPUT over INPUT which is the default)
if I use gpio mode 25 out the program works as expected. It looks like the pin is floating value weirdly so I get constant up and down events everywhere
Bryan Hughes
@nebrius
Jun 11 2015 18:02
@wadtech would you mind filing an issue on GitHub for the pin mode thing?
It may not be raspi-io specific bug, in the classic sense, but I can at least get the ball rolling on figuring out where the issue is
as for the i2c thing, raspi-io should behave the same as an Arduino Uno. I’m on a train, headed out to NodeConf at the moment, so I’m a bit indisposed at the moment. If you have an Uno (or some sort of Atmel based Arduino), would you mind running this same test and let me know how it behaves?
I suspect it shouldn’t be throwing an error, but I would like to confirm first
Derek Wheelden
@frxnz
Jun 11 2015 18:14
@wadtech Does the button behave as expected with a pullup? I have a button working perfectly with raspi-io, but it was behaving as you mention until I added a pullup