Closed ryoshu closed 10 years ago
Using your code for blink all: https://www.youtube.com/watch?v=Hk7H5HkWHQA
What version of Galileo-IO is running in that video?
So...
root@quark016c31:~# ps | grep node
174 root 34656 S /usr/bin/node /opt/xdk-daemon/main.js
194 root 78244 S /usr/bin/node /opt/xdk-daemon/current/appDaemon.js
205 root 2488 S grep node
root@quark016c31:~#
/me shrugs
What does journalctl -f say?
@rwaldron 0.3.6
@ashishdatta I'll pull that in the morning.
Hey so I was having the same issue with pin 11 ... but all of a sudden it started working once I changed the code to:
1 // Use require("galileo-io") when running from an npm installation
2 var Galileo = require("../lib/galileo");
3 var board = new Galileo();
4
5 board.on("ready", function() {
6 console.log("READY");
7 var byte = 0;
8 var byte2 = 0;
9
10 setInterval(function() {
11 board.digitalWrite(11, (byte ^= 1));
12 board.digitalWrite(13, (byte2 ^= 1));
13 }, 500);
14 });
But based on your video you already did something similar ... so I am not sure. I just know now it works. Also just out of curiosity do you have anything in your /sketch
folder?
Just did this: https://www.youtube.com/watch?v=X6iaGVFIOhQ
Here's the MRAA based code:
var m = require('mraa');
console.log('MRAA Version: ' + m.getVersion());
var leds = [];
for(var i = 0; i < 14; ++i) {
var pin = new m.Gpio(i);
pin.dir(m.DIR_OUT);
leds.push(pin);
}
var ledState = true;
periodicActivity();
function periodicActivity() {
for(var i = 0; i < leds.length; ++i) {
leds[i].write(ledState?1:0);
}
ledState = !ledState;
setTimeout(periodicActivity,1000);
}
@ashishdatta journalctl -f doesn't show anything for the call to the Galileo-IO script and there's no sketch in the folder and no process running.
btw Rick, I'm using your "Blink, all pins, Galileo-IO" code for the Galileo portion of the video.
@ryoshu with the latest changes (v0.3.7), I tried both your code and then this:
var Galileo = require("galileo-io");
var board = new Galileo();
board.on("ready", function() {
for (var i = 2; i < 14; i++) {
this.pinMode(i, this.MODES.OUTPUT);
}
var state = 0;
setInterval(function() {
state ^= 1;
for (var i = 2; i < 14; i++) {
this.digitalWrite(i, state);
}
}.bind(this), 1000);
});
And they do exactly the same thing. I've also added a set of unit tests, based on this example, that verify the correct calls to mraa bindings are made.
@ryoshu any updates?
Apologies. Haven't had a chance to try 0.3.7 yet. Will try to do so on Monday and report back.
Thanks! Just grab the latest, because that number is old now
Just grabbed the latest (0.3.8) and tried running it again. Same results as last time, galileo-io only blinks non-PWM pins, mraa blinks all digital pins. I ran the tests and here's the output:
https://gist.github.com/ryoshu/a770f1cf0107f16564c1
It hangs on that last line for at least half an hour, so I'm going to assume something has gone sideways. I reboot and now... digital pins 0, 10, 12 are all high on boot. Do a shutdown on power back on, 0, 10, 12 are still high (this is the first time I've seen that behavior).
root@quark016df6:~# ls /sys/class/gpio export gpiochip16 gpiochip32 gpiochip64 unexport gpiochip0 gpiochip2 gpiochip48 gpiochip8
Is that what your pin export looks like on boot?
This is very interesting. On boot:
root@quark016c31:~# ls /sys/class/gpio
export gpio15 gpio23 gpio31 gpio39 gpio46 gpio54 gpio61 gpio74 gpiochip32
gpio0 gpio16 gpio24 gpio32 gpio4 gpio48 gpio55 gpio62 gpio76 gpiochip48
gpio1 gpio17 gpio25 gpio33 gpio40 gpio49 gpio56 gpio64 gpio77 gpiochip64
gpio10 gpio18 gpio26 gpio34 gpio41 gpio5 gpio57 gpio66 gpio78 gpiochip8
gpio11 gpio19 gpio27 gpio35 gpio42 gpio50 gpio58 gpio68 gpio79 unexport
gpio12 gpio20 gpio28 gpio36 gpio43 gpio51 gpio59 gpio7 gpiochip0
gpio13 gpio21 gpio29 gpio37 gpio44 gpio52 gpio6 gpio70 gpiochip16
gpio14 gpio22 gpio30 gpio38 gpio45 gpio53 gpio60 gpio72 gpiochip2
I just popped the same SD card into a different Gen 2 and got the same output I did originally. Points to a possible software problem, but let me poke around some more.
Thanks!
What if we just add a script, which exports all the gpios, that runs when galileo-io is npm installed?
Nevermind, I hate that idea and it shouldn't be necessary to do such a thing.
I'm seeing the pins being exported when I run a script, but I'm still getting the wonky results. I tried a fresh install of IOTDK and I'm seeing the same issue with GPIO export on boot. Still poking around.
Can you dump the output of ps
after a reboot so I can compare?
PID USER VSZ STAT COMMAND
1 root 4308 S {systemd} /sbin/init
2 root 0 SW [kthreadd]
3 root 0 SW [ksoftirqd/0]
4 root 0 SW [kworker/0:0]
5 root 0 SW< [kworker/0:0H]
6 root 0 SW [kworker/u:0]
7 root 0 SW< [kworker/u:0H]
8 root 0 SW< [cpuset]
9 root 0 SW< [khelper]
10 root 0 SW [kdevtmpfs]
11 root 0 SW< [netns]
12 root 0 SW [bdi-default]
13 root 0 SW< [kblockd]
14 root 0 SW [kworker/0:1]
15 root 0 SW [kswapd0]
16 root 0 SW [fsnotify_mark]
17 root 0 SW< [crypto]
21 root 0 SW [kworker/u:1]
22 root 0 SW< [deferwq]
23 root 0 SW [kworker/u:2]
24 root 0 DW [mmcqd/0]
25 root 0 SW< [kworker/0:1H]
26 root 0 SW [kjournald]
34 root 0 SW [flush-179:0]
39 root 0 SW [kworker/0:2]
58 root 0 SW [irq/57-0-0027]
64 root 6728 S /lib/systemd/systemd-journald
74 root 0 SW [khubd]
78 root 0 SW [spi0]
79 root 0 SW [spi1]
88 root 9360 S /lib/systemd/systemd-udevd
101 root 0 SW< [cfg80211]
104 root 0 SW [file-storage]
105 root 0 SW< [iwlwifi]
112 root 0 SW< [hci0]
113 root 0 SW< [kworker/u:1H]
136 root 4400 S /usr/lib/bluez5/bluetooth/bluetoothd
138 root 5284 S /usr/sbin/ofonod -n
140 root 3188 S /bin/sh /opt/cln/galileo/launcher.sh
141 root 2644 S /lib/systemd/systemd-logind
142 root 2216 S /opt/cln/galileo/clloader --escape --binary --zmodem --disable
143 avahi 3396 S avahi-daemon: running [quark016c31.local]
144 messageb 3012 S /usr/bin/dbus-daemon --system --address=systemd: --nofork --no
145 root 18388 R /sketch/sketch.elf /dev/pts/0
146 avahi 3240 S avahi-daemon: chroot helper
151 root 2472 S /lib/systemd/systemd-networkd
153 root 6156 S /usr/sbin/connmand -n
159 avahi-au 2208 S avahi-autoipd: [enp0s20f6] sleeping
160 root 1972 S avahi-autoipd: [enp0s20f6] callout dispatcher
162 root 2380 S /lib/systemd/systemd-hostnamed
164 root 3192 S {xdk-daemon} /bin/sh /opt/xdk-daemon/xdk-daemon
168 root 5592 S /usr/sbin/tcf-agent -d -L- -l0
173 root 34656 S /usr/bin/node /opt/xdk-daemon/main.js
176 root 2336 S /usr/sbin/lighttpd -D -f /etc/lighttpd.conf
180 root 5320 S /usr/sbin/wpa_supplicant -u
182 root 2188 S /sbin/agetty -8 --keep-baud ttyS1 115200 xterm
183 root 2188 S /sbin/agetty --noclear tty1 linux
187 root 19940 S /usr/bin/redis-server /etc/redis/redis.conf
188 root 0 SW< [krfcommd]
192 root 78244 S /usr/bin/node /opt/xdk-daemon/current/appDaemon.js
199 root 5248 R sshd: root@pts/1
201 root 3308 S -sh
202 root 2724 R ps
ps
looks the same excect for PIDs. Here's my latest:
{boot} root@quark016df6:~/projects/galileo-test# ls /sys/class/gpio export gpiochip16 gpiochip32 gpiochip64 unexport gpiochip0 gpiochip2 gpiochip48 gpiochip8 root@quark016df6:~/projects/galileo-test# node blink-all.js ready (blink does not work on all pins) root@quark016df6:~/projects/galileo-test# ls /sys/class/gpio export gpio13 gpio22 gpio34 gpio44 gpio55 gpio7 gpio78 gpiochip48 gpio0 gpio14 gpio24 gpio36 gpio45 gpio6 gpio70 gpio79 gpiochip64 gpio1 gpio15 gpio26 gpio38 gpio46 gpio60 gpio72 gpiochip0 gpiochip8 gpio10 gpio16 gpio28 gpio4 gpio49 gpio64 gpio74 gpiochip16 unexport gpio11 gpio18 gpio30 gpio40 gpio5 gpio66 gpio76 gpiochip2 gpio12 gpio20 gpio32 gpio42 gpio51 gpio68 gpio77 gpiochip32 root@quark016df6:~/projects/galileo-test# node mraa-blink-all.js MRAA Version: v0.5.0-12-g3898182 (blink works on all pins) root@quark016df6:~/projects/galileo-test# ls /sys/class/gpio export gpio13 gpio22 gpio34 gpio44 gpio55 gpio7 gpio78 gpiochip48 gpio0 gpio14 gpio24 gpio36 gpio45 gpio6 gpio70 gpio79 gpiochip64 gpio1 gpio15 gpio26 gpio38 gpio46 gpio60 gpio72 gpiochip0 gpiochip8 gpio10 gpio16 gpio28 gpio4 gpio49 gpio64 gpio74 gpiochip16 unexport gpio11 gpio18 gpio30 gpio40 gpio5 gpio66 gpio76 gpiochip2 gpio12 gpio20 gpio32 gpio42 gpio51 gpio68 gpio77 gpiochip32 {reboot} pin 0, 12 high on shutdown, pin 10 also becomes high on reboot root@quark016df6:~# ls /sys/class/gpio export gpiochip16 gpiochip32 gpiochip64 unexport gpiochip0 gpiochip2 gpiochip48 gpiochip8 root@quark016df6:~/projects/galileo-test# node mraa-blink-all.js MRAA Version: v0.5.0-12-g3898182 (blink works on all pins) root@quark016df6:~/projects/galileo-test# ls /sys/class/gpio export gpio13 gpio22 gpio34 gpio44 gpio66 gpio76 gpiochip48 gpio0 gpio14 gpio24 gpio36 gpio45 gpio68 gpio77 gpiochip64 gpio1 gpio15 gpio26 gpio38 gpio46 gpio7 gpiochip0 gpiochip8 gpio10 gpio16 gpio28 gpio4 gpio5 gpio70 gpiochip16 unexport gpio11 gpio18 gpio30 gpio40 gpio6 gpio72 gpiochip2 gpio12 gpio20 gpio32 gpio42 gpio64 gpio74 gpiochip32 root@quark016df6:~/projects/galileo-test# node blink-all.js ready root@quark016df6:~/projects/galileo-test# ls /sys/class/gpio export gpio13 gpio22 gpio34 gpio44 gpio55 gpio7 gpio78 gpiochip48 gpio0 gpio14 gpio24 gpio36 gpio45 gpio6 gpio70 gpio79 gpiochip64 gpio1 gpio15 gpio26 gpio38 gpio46 gpio60 gpio72 gpiochip0 gpiochip8 gpio10 gpio16 gpio28 gpio4 gpio49 gpio64 gpio74 gpiochip16 unexport gpio11 gpio18 gpio30 gpio40 gpio5 gpio66 gpio76 gpiochip2 gpio12 gpio20 gpio32 gpio42 gpio51 gpio68 gpio77 gpiochip32 {reboot} pin 0, 12 high on shutdown, pin 10 also becomes high on reboot
Export might be red herring. I'll continue to dig.
Back in the saddle again. Apologies for the delay. I just unpacked a new Gen 2, installed a fresh copy of IoT DevKit, updated to the latest version of mraa (v0.5.1-18-ge5c3e49) and installed a fresh copy of galileo-io (v0.3.9). Blink sketch using galileo-io only blinks on non-pwm pins. Blink sketch using mraa blinks on all pins.
I dropped into the galileo-io module and tried running the unit tests with -d -v flags:
Testing galileo.js
Galileo - shape...OK
Galileo - readonly...OK
Galileo - emitter...OK
Galileo - connected...OK
Galileo - ready...OK
Galileo.prototype.analogRead - correctMode...OK
Galileo.prototype.analogRead - analogPin...
It hangs indefinitely on analogRead. Running journalctl -f while running the unit tests I see:
Sep 13 15:19:29 quark016e92 libmraa[276]: libmraa initialised for platform 1
So mraa is being invoked. Any ideas on where I should poke around next?
Thanks.
Are you running the unit tests on the Galileo? mraa
shouldn't actually be invoked for the tests, I'm using a mock.
Have we looked at write permissions yet?
Hmm. Something appears(?) to call mraa when I run the unit test. Steps to reproduce:
grunt -d -v nodeunit
when Running tasks: nodeunit
Running "nodeunit" task [D] Task source: /home/root/projects/node_modules/galileo-io/node_modules/grunt-contrib- nodeunit/tasks/nodeunit.js
Running "nodeunit:tests" (nodeunit) task [D] Task source: /home/root/projects/node_modules/galileo-io/node_modules/grunt-contrib-nodeunit/tasks/nodeunit.js Verifying property nodeunit.tests exists in config...OK Files: test/galileo.js, test/galileo-mraa.js, test/pin.js, test/mraa.js, test/not-implemented.js -> tests
runs journalctl reports:
Sep 13 15:32:42 quark016e92 libmraa[217]: libmraa initialised for platform 1
Might be unrelated (another process?) but I can get it to happen after every reboot.
Something appears(?) to call mraa when I run the unit test.
Right, I said "shouldn't" because they shouldn't—not that they don't. Which is why I asked if you were running these on the board itself, which would cause that. It's really beside the point though because the unit tests aren't integration tests, so the only thing I will do about that is make sure that real mraa absolutely never gets used in the tests (just the mock). Forgive me if that sounds curt, but the tests correctly report that mraa apis are called where expected, when run in a dev environment. The tests were never intended to run directly on the board (because there should be no reliance there) and this feels distracting.
Did you see this:
Have we looked at write permissions yet?
I'll insert some debug statements and see where exactly it hangs. Totally understand they aren't integration tests.
I'm unsure what permissions I should be looking at. Everything runs as root on the Galileo and it's rare to have something a-w by default, but maybe it's possible on a fresh install?
Thanks.
I'll insert some debug statements and see where exactly it hangs.
They don't hang when run correctly.
but maybe it's possible on a fresh install?
I have no idea, but there is also no obvious reason why this doesn't "just work".
Okay, let's assume that mraa being invoked running the unit tests is a red herring. Where should I look for permission issues? The mraa example works with the same permissions from the same folder as the galileo-io example that doesn't work.
Thanks.
I'm not sure, but it may be helpful at this point for me to get one of the boards + sd that's not working correctly. I'm all out of ideas :\
Can we arrange a hand off for later today? Shoot me an email.
I had issues getting the latest version to install, if 0.3.x gets stuck, clear the npm cache:
rm -rf ~/.npm; npm cache clear;
Expected behavior: Digital write should send HIGH on all digital pins.