Hi,
I just install Bonescript on my cloud9. Now I'm trying to use some simple examples.
However, when I tried to use them I got some error, nevertheless, I didn't understand why, and how I can solve them.
First example : Toogle LED
var b = require('bonescript');
var leds = ["USR0", "USR1", "USR2", "USR3","P8_07"];
for(var i in leds) {
b.pinMode(leds[i], b.OUTPUT);
}
var state = b.LOW;
for(var i in leds) {
b.digitalWrite(leds[i], state);
}
setInterval(toggle, 1000);
function toggle() {
if(state == b.LOW) state = b.HIGH;
else state = b.LOW;
for(var i in leds) {
b.digitalWrite(leds[i], state);
}
}
The error that I got :
/root/labs/cloud9_app/node_modules/bonescript/src/hw_mainline.js:84
if(!pinmux) { throw p + " was not found under " + my.is_ocp(); }
^
ocp:P8_07_pinmux was not found under /sys/devices/platform/ocp
Remark : if I change the line
var leds = ["USR0", "USR1", "USR2", "USR3","P8_07"];
by
var leds = ["USR0", "USR1", "USR2", "USR3",];
My program is working because it didn't use a gpio pin which request a configuration.
Second example : set a PWM signal and change the duty cycle of it :
source :
http://beagleboard.org/support/BoneScript/ServoMotor/var b = require('bonescript');
var SERVO = 'P9_14';
var duty_min = 0.03;
var position = 0;
var increment = 0.1;
//b.pinMode(SERVO, b.OUTPUT);
updateDuty();
function updateDuty() {
// compute and adjust duty_cycle based on
// desired position in range 0..1
var duty_cycle = (position*0.115) + duty_min;
b.analogWrite(SERVO, duty_cycle, 60, scheduleNextUpdate);
console.log("Duty Cycle: " +
parseFloat(duty_cycle*100).toFixed(1) + " %");
}
function scheduleNextUpdate() {
// adjust position by increment and
// reverse if it exceeds range of 0..1
position = position + increment;
if(position < 0) {
position = 0;
increment = -increment;
} else if(position > 1) {
position = 1;
increment = -increment;
}
// call updateDuty after 200ms
setTimeout(updateDuty, 200);
}
Error :
/root/labs/cloud9_app/node_modules/bonescript/src/hw_mainline.js:84
if(!pinmux) { throw p + " was not found under " + my.is_ocp(); }
^
ocp:P9_14_pinmux was not found under /sys/devices/platform/ocp
To confirm that my code was working I have tested it on the original kernel install on the beaglebone.
Both were working on it. So, I was wondering if it didn't come from the dts/dtbo file.
To test that I copy the one form the original kernel in my own one. It didn't succeed either.
Here are my current configuration :
# node --version
v0.12.7
# npm --version
2.11.3
# node -pe "require('bonescript').getPlatform().bonescript"
0.5.0
# uname -a
Linux beagle09 4.1.21-bone-rt-r20 #3 Wed May 25 13:55:22 CEST 2016 armv7l GNU/Linux
Did someone have an Idea on what's wrong ? Am I missing something ?
If you have any questions do not hesitate.
Thanks by advance for your help
Regards
Vincent
" Enjoy life no matter what ! "