These are chat archives for nebrius/raspi-io

4th
Jan 2015
Gabriel Baciu
@motiooon
Jan 04 2015 00:58
hi all, I have a problem while truing to use raspi-io
what am I doing wrong?
the error is
/home/pi/projects/johnny-five/node_modules/raspi-io/lib/index.js:231
throw new Error('Unknown pin "' + pin + '"');
Bryan Hughes
@nebrius
Jan 04 2015 01:01
@motiooon can you give me the full stack trace?
btw, the console.log call you have on line 5 needs to go inside of the 'ready' event handler
I suspect that's what's causing it, but I can't say for certain without seeing the full stack trace
Gabriel Baciu
@motiooon
Jan 04 2015 01:03
/home/pi/projects/johnny-five/node_modules/raspi-io/lib/index.js:231
throw new Error('Unknown pin "' + pin + '"');
^
Error: Unknown pin "P2-16"
at Raspi.Object.defineProperty.value [as $271828_5$] (/home/pi/projects/johnny-five/node_modules/raspi-io/lib/index.js:231:13)
at Raspi.Object.defineProperty.value [as pinMode] (/home/pi/projects/johnny-five/node_modules/raspi-io/lib/index.js:240:43)
at Raspi.<anonymous> (/home/pi/projects/johnny-five/start.js:18:9)
at Raspi.emit (events.js:92:17)
at /home/pi/projects/johnny-five/node_modules/raspi-io/lib/index.js:204:10
I have a raspberry pi model b+ 40 pins
I've tried with both p1-16 and p2-16, I don't really get it how to select a pin
Bryan Hughes
@nebrius
Jan 04 2015 01:06
is the file you posted in your gist start.js? The line numbers don't seem to line up for some reason (line 18 is whitespace)
so the p# represents which header we are using
the B+ only has one header though, p1
Gabriel Baciu
@motiooon
Jan 04 2015 01:06
yes it's the gist, the spacing is not right because of the editor
Bryan Hughes
@nebrius
Jan 04 2015 01:07
the B rev 2 has the main header and an optional, secondary header called p5, so I use the p# to differentiate between them
Gabriel Baciu
@motiooon
Jan 04 2015 01:07
even if i use only p1-16, p-18 still same errir
so should i go for p#16 ?
i'm basically trying to reach out pin number 16, where top left is number 1
Bryan Hughes
@nebrius
Jan 04 2015 01:08
the format should be 'p1-16'
Gabriel Baciu
@motiooon
Jan 04 2015 01:08
ok, but it doesn't seem to work using 'p1-16'
Bryan Hughes
@nebrius
Jan 04 2015 01:09
this seems like a bug. Would you mind opening an issue on github?
Gabriel Baciu
@motiooon
Jan 04 2015 01:09
ok, sure, will do
what would be an alternative to make my project work?
Bryan Hughes
@nebrius
Jan 04 2015 01:09
thanks, in the mean time, try 'GPIO23' and see if that works
Gabriel Baciu
@motiooon
Jan 04 2015 01:10
a, ok, so i should reffer them as the perhipherals name
Bryan Hughes
@nebrius
Jan 04 2015 01:10
they should all work
Gabriel Baciu
@motiooon
Jan 04 2015 01:10
ok, I'll give it a try, and file the issue
Bryan Hughes
@nebrius
Jan 04 2015 01:10
you can specify by peripheral name, physical pin, or the Wiring Pi virtual pin
thanks for filing
Gabriel Baciu
@motiooon
Jan 04 2015 01:11
yes, but the 'p1-16' (phisical) is not working right?
not for me at least
Bryan Hughes
@nebrius
Jan 04 2015 01:11
it's supposed to work
Gabriel Baciu
@motiooon
Jan 04 2015 01:13
for a pin named like this "GPIO18/PWM0" i use only "GPIO18" right ?
Bryan Hughes
@nebrius
Jan 04 2015 01:13
you can use whichever one you prefer
naming schemes for the RPi are kinda annoying, so I setup raspi-io so that you can use whichever naming scheme you are most comfortable with...it makes no difference to the library
Gabriel Baciu
@motiooon
Jan 04 2015 01:15
just filed bryan-m-hughes/raspi-io#9
Bryan Hughes
@nebrius
Jan 04 2015 01:15
awesome, thanks!
Gabriel Baciu
@motiooon
Jan 04 2015 01:15
ill try to use the 'GPIO23' instead of p1-16 for now to see if it works
Bryan Hughes
@nebrius
Jan 04 2015 01:15
let me know if it works, I'm curious :)
Gabriel Baciu
@motiooon
Jan 04 2015 01:16
sure, I'll give it a try right now
doesn't work either
Bryan Hughes
@nebrius
Jan 04 2015 01:22
I'm not too surprised...it would be strange if one mapping worked when the other one didn't :(
So I notice that you aren't using Johnny-Five, any particular reason?
Gabriel Baciu
@motiooon
Jan 04 2015 01:24
i can fork the lib/index.js, meantime, what should i look for ? maybe this ? getPinNumber(pin);
i can use it with jonny five, should i try that?
Bryan Hughes
@nebrius
Jan 04 2015 01:26
it probably won't make a difference, just curious really. Raspi-io was designed as a plugin for J5. I created a suite of libraries, check out https://github.com/bryan-m-hughes/raspi-core for the details. Raspi-io uses this suite under the hood
I think it's a little easier to use personally. Totally you're choice, and it probably won't make a difference
I suspect that the problem is occuring because raspi-io (technically raspi-board) isn't able to figure out what board revision you're using
oh, what distro are you using, raspbian?
Gabriel Baciu
@motiooon
Jan 04 2015 01:31
yes raspbian
Bryan Hughes
@nebrius
Jan 04 2015 01:32
k, thanks. I’m bringing up my raspberry-pi B+ right now so I can test
Gabriel Baciu
@motiooon
Jan 04 2015 01:41
another think that might happen is that I've install all dependencies using default user "pi" and then i start the application as 'root' via sudo.
Bryan Hughes
@nebrius
Jan 04 2015 01:42
I would be pretty surprised if that made a difference
Bryan Hughes
@nebrius
Jan 04 2015 01:51
small update, I can reproduce as well
@motiooon ooooooohhhhh, I figured it out
Bryan Hughes
@nebrius
Jan 04 2015 01:56
I forgot that the pinMode method doesn’t normalize pin numbers automatically
so you have to call board.normalize() and send that value to pinMode
you might find it easier to use raspi-core directly, since all of those methods do normalize pin numbers for you
it’s just a side effect of this being a plugin for J5 (which normalizes things on its end)
Gabriel Baciu
@motiooon
Jan 04 2015 01:59
i've just tried with j5 and heres's the stack
might be a little better
o I see, so first normalize then send the output mode
Bryan Hughes
@nebrius
Jan 04 2015 02:01
yep, or use J5 which will normalize for you, and get you a bunch of other awesome stuff
Bryan Hughes
@nebrius
Jan 04 2015 02:02
yeah that looks good, althought the normalize step isn’t necessary anymore
and actually, you can now use the pin API https://github.com/rwaldron/johnny-five/wiki/Pin, which will make everything much simpler
Gabriel Baciu
@motiooon
Jan 04 2015 02:04
so if i do var pin = new five.Pin(16); will select the 16th pin? and then i do pin.high()?
Bryan Hughes
@nebrius
Jan 04 2015 02:04
you will need to do var pin = new five.Pin(‘P1-16’)
Gabriel Baciu
@motiooon
Jan 04 2015 02:13
this is what i get now:
Bryan Hughes
@nebrius
Jan 04 2015 02:16
hmm...I'll need to check in more depth to see what's going on, but I think I'm not quite handling something right
I'm actually heading out to dinner now, and it'll be a while before I get back on
in the mean time, try commenting out this if statement: https://github.com/bryan-m-hughes/raspi-io/blob/master/lib/index.js#L283
it will get you around that check (I don't think it will hurt anything)
Gabriel Baciu
@motiooon
Jan 04 2015 02:17
ok, thanks a lot for your help
Bryan Hughes
@nebrius
Jan 04 2015 02:17
thanks for the bug reports!
Alan Yorinks
@MrYsLab
Jan 04 2015 20:12
Brian, I am not sure if you have seen any of the threads on this, the i2c interface has changed. The Galileo io-plugin reflects the latest signatures, but the implementation is likely to change (from what I gather). I don't know if you are still intending upon supporting i2c, but the BBB has moved away from the i2c npm library to the i2c-bus npm library. The i2c libary did not work in certain cases. Also, Rick has asked Brian Cooke, the i2c-bus author, to look at moving the Galileo implementation to use this library as well. This just a heads up.
Bryan Hughes
@nebrius
Jan 04 2015 20:14
Thanks Alan. I started work on raspi-i2c, which is independent from J5 and uses Wiring Pi, but haven’t done any raspi-io/J5 integration yet
in any case, I won’t be using any third party NPM modules for it since Wiring Pi gives it to me as well, and it’s already a requirement elsewhere
Alan Yorinks
@MrYsLab
Jan 04 2015 20:23
OK. When you get to the J5 interface, you can find a description of the new interface here: https://github.com/rwaldron/johnny-five/wiki/IO-Plugins. You can safely ignore the "Ensure pin mode is UNKNOWN (99)" comments - Rick will be removing them, but I believe everything else is still correct.
BTW, just to add to the fun, some of the methods are overloaded.
Bryan Hughes
@nebrius
Jan 04 2015 20:24
kk, thanks