jadonk / bonescript Goto Github PK
View Code? Open in Web Editor NEWScripting tools for BeagleBone and PocketBeagle
Home Page: http://beagleboard.org
License: MIT License
Scripting tools for BeagleBone and PocketBeagle
Home Page: http://beagleboard.org
License: MIT License
Is it possible to make a analogWrite function?
I am currently wondering how this could be achieved. I see there are file paths where you write values to. Sadly I do not exactly know how that works in the system. If you tell me what values I need to write, I could implement it and send a pull request.
Example from Simon Monk:
var sp = require("serialport");
var port = '/dev/ttyO4';
var options = { baudrate: 9600, parser: sp.parsers.readline("\n") };
Hi
I want to understand if it is possible to read a digital or analog signal and show the state in a Tv through the HDMI output of the beagle bone black. I mean use an HTML page and show the state of the digital or analog signals of the BBB directly through the HDMI output.
I know that the input and output are controlled using bonescript but I don´t know how to link one variable from bonescript to a HTML page in the same board.
Thanks a lot for your help and best regards.
I am running BeagleBone black with LCD3 cape and latest Angstrom image. and am looking to generate a frequency sweep function sweeping through a range of frequencies using analogWrite.
When using bonescript I get a EINVAL invalid argument error if my frequency increments are greater than 2000Hz. If increments are less than (or equal to) 2000Hz then I can increment all the way from 2kHz up to 50kHz. Example code shown below.
var b = require('bonescript');
var pwm = 'P9_29';
for (var i=2000; i<51000; i += 2000) {
console.log('output '+i);
b.analogWrite(pwm, 0.5, i);
}
If I manually set pwm frequency by using echo 500000 > period then I go can from 2kHz to 50kHz in one step.
I am battling to bonescript (package.json shows it as 0.2.2) upgraded to 0.2.4 so am unsure if this is something address in later bonescript version or not.
Not sure if this an issue or not but was definitely not expected and is repeatable.
Any help appreciated and I am more than willing to assist where I can.
Colin
Tried installing Bonescript on Mac OSX 10.8.4, Node 0.9.12 (also 0.10.18) with no success, got the following:
npm http GET https://registry.npmjs.org/bonescript
npm http 304 https://registry.npmjs.org/bonescript
[email protected] preinstall /Users/cs/Sites/lab/bonescript/node_modules/bonescript
node-gyp clean || (exit 0); node-gyp configure build
gyp http GET http://nodejs.org/dist/v0.9.12/node-v0.9.12.tar.gz
gyp http 200 http://nodejs.org/dist/v0.9.12/node-v0.9.12.tar.gz
CXX(target) Release/obj.target/misc/misc.o
../misc.cpp:1:9: warning: 'BUILDING_NODE_EXTENSION' macro redefined
^
:4:9: note: previous definition is here
^
../misc.cpp:8:10: fatal error: 'sys/epoll.h' file not found
^
1 warning and 1 error generated.
make: *** [Release/obj.target/misc/misc.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make
failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:255:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:97:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:733:12)
gyp ERR! System Darwin 12.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /Users/cs/Sites/lab/bonescript/node_modules/bonescript
gyp ERR! node -v v0.9.12
gyp ERR! node-gyp -v v0.8.4
gyp ERR! not ok
npm ERR! [email protected] preinstall: node-gyp clean || (exit 0); node-gyp configure build
npm ERR! sh "-c" "node-gyp clean || (exit 0); node-gyp configure build"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the bonescript package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp clean || (exit 0); node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls bonescript
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 12.4.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "bonescript"
npm ERR! cwd /Users/cs/Sites/lab/bonescript
npm ERR! node -v v0.9.12
npm ERR! npm -v 1.2.12
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/cs/Sites/lab/bonescript/npm-debug.log
npm ERR! not ok code 0
Thanks for any help.
Was wondering what the correct/preferred way is to shut down a PWM output. In my project I use the PWM to vary a frequency (as opposed to duty cycle) and depending on user input I need to be able to shut the frequency output off.
I see in the device tree there is a run parameter we could write to but it doesn't look as if this is exposed. Is it safe/okay to write a 0 to duty cycle?
Much appreciate all your efforts on this project!
~C
Why is it that when rapidly reading a gpio value file I eventually just get all zeros? It works fine for a few seconds, then I just get nothing.
For example, I'm trying a digital read on an input pin. It reads all ones, as it should ( I have pullup enabled), but then it becomes zero. I am hitting the file 20 times/second.
Is this a constraint of linux and/or file I/O?
P9_15 will blink in my sample, but P9_17 wont:
var b = require('bonescript');
var state = b.LOW;
b.pinMode("P9_15", b.OUTPUT, 7, 'pulldown', 'fast');
b.pinMode("P9_17", b.OUTPUT, 7, 'pulldown', 'fast');
setInterval(toggle, 1000);
function toggle() {
if(state == b.LOW) state = b.HIGH;
else state = b.LOW;
b.digitalWrite("P9_15", state);
b.digitalWrite("P9_17", state);
}
It does appear to be setting up the pin in the OS correctly, do I perhaps have a defective unit? Can someone else verify that this should work?
root@beaglebone:/var/lib/cloud9/demo# ls -al /sys/class/gpio
total 0
drwxr-xr-x 2 root root 0 Jan 1 15:01 .
drwxr-xr-x 48 root root 0 Jan 1 15:01 ..
--w------- 1 root root 4096 Jan 1 15:04 export
lrwxrwxrwx 1 root root 0 Jan 1 15:04 gpio48 -> ../../devices/virtual/gpio/gpio48
lrwxrwxrwx 1 root root 0 Jan 1 15:04 gpio5 -> ../../devices/virtual/gpio/gpio5
lrwxrwxrwx 1 root root 0 Jan 1 15:01 gpiochip0 -> ../../devices/virtual/gpio/gpiochip0
lrwxrwxrwx 1 root root 0 Jan 1 15:01 gpiochip32 -> ../../devices/virtual/gpio/gpiochip32
lrwxrwxrwx 1 root root 0 Jan 1 15:01 gpiochip64 -> ../../devices/virtual/gpio/gpiochip64
lrwxrwxrwx 1 root root 0 Jan 1 15:01 gpiochip96 -> ../../devices/virtual/gpio/gpiochip96
--w------- 1 root root 4096 Jan 1 15:01 unexport
text only modules like socket.io and socket.io-client should be included in git so all bonescript examples work
getPinMode() will fail to fetch the mux mode if /sys/kernel/debug/pinctrl/44e10800.pinmux/pins isn't already mounted.
Mount command is:
mount -t debugfs none /sys/kernel/debug/
Need to find a good place to put this.
There seems to be an issue with accessing socket.io in the beaglebone black (this problem never occurred in the original [white] beaglebones).
With code that starts out as follows:
var app = require('http').createServer(handler); var io = require('socket.io').listen(app); var fs = require('fs'); var bb = require('bonescript');
I get the following error:
module.js:340 throw err; ^ Error: Cannot find module 'socket.io' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:362:17) at require (module.js:378:17) at Object.<anonymous> (/var/lib/cloud9/sensorSocketServer.js:5:10) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10)
This is with the latest angstrom distribution for BBB.
Is socket.io not bundled with the bonescript distribution? If so, it may make sense to include it.
Thanks.
On a beaglebone black, the default bonescript installed through opkg (or even pulled from github) does not support reading using analogRead
It fails with file not found "undefined/AIN3". Also, the beaglebone black does not need any value scaling, since the ADC returns raw voltage directly (in millivolts).
The patch below seems to fix the problem.
Package: bonescript
Version: 1.0-r21.3
Linux beaglebone 3.8.11 #1 SMP Wed May 8 07:34:27 CEST 2013 armv7l GNU/Linux
diff --git a/node_modules/bonescript/index.js b/node_modules/bonescript/index.js
index e762e47..947521f 100644
--- a/node_modules/bonescript/index.js
+++ b/node_modules/bonescript/index.js
@@ -366,7 +366,7 @@ f.analogRead = function(pin, callback) {
pin = getpin(pin);
if(typeof this.ainPrefix == 'undefined') {
if(load_dt('cape-bone-iio')) {
- var helper = file_find('/sys/module/bone_iio_helper/drivers/platform:bone-iio-helper', 'helper.', 10000);
+ var helper = file_find('/sys/devices/ocp.2', 'helper.', 10000);
this.ainPrefix = helper + '/AIN';
this.indexOffset = 0;
this.scale = 1800;
@@ -397,7 +397,8 @@ f.analogRead = function(pin, callback) {
delete this.ainPrefix;
throw('analogRead(' + pin.key + ') returned ' + data);
}
- data = data / scale;
+ if(f.getPlatform().name == 'Beaglebone')
+ data = data / scale;
if(isNaN(data)) {
delete this.ainPrefix;
throw('analogRead(' + pin.key + ') scaled to ' + data);
Has anyone seen this issue when doing a git pull command? What is this file and how can I get around git thinking it has modified and not allowing me to pull?
I noticed some garbage data in the pinmux section of the cape I flashed with bonescript. It went away by doing cat /dev/zero > /sys/bus/i2c/blah/eeprom before running the flasher.
any code that exist outside the bounds of the setup or loop functions gets executed twice.
analogRead function as in Arduino.
I get the message Optional package './misc' not loaded
running Ubuntu 12.10 with latest npm version of bonescript (0.0.1)
I have installed angstrom image BBB-eMMC-flasher-2013.09.04.img on BBB and am trying to update bonescript using NPM as stated.
On running npm install -g bonescript command I get a python version related error.
It says to try pass --python switch but I am not sure how to do this.
I am not sure if later python is absolutely necessary so I thought I'd try upgrade it as well but it seems like latest version with opkg is version 2.7.3
Appreciate any help
Colin
npm http GET https://registry.npmjs.org/bonescript
npm http 304 https://registry.npmjs.org/bonescript
> [email protected] preinstall /usr/lib/node_modules/bonescript
> node-gyp clean || (exit 0); node-gyp configure build
gyp ERR! configure error
gyp ERR! stack Error: Python executable "python" is v2.7.3, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
gyp ERR! stack at failPythonVersion (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:118:14)
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:107:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:538:7)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack at maybeClose (child_process.js:638:16)
gyp ERR! stack at Process._handle.onexit (child_process.js:680:5)
gyp ERR! System Linux 3.8.13
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /usr/lib/node_modules/bonescript
gyp ERR! node -v v0.8.22
gyp ERR! node-gyp -v v0.8.5
gyp ERR! not ok
npm ERR! [email protected] preinstall: `node-gyp clean || (exit 0); node-gyp configure build`
npm ERR! `sh "-c" "node-gyp clean || (exit 0); node-gyp configure build"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the bonescript package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp clean || (exit 0); node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls bonescript
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.8.13
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "bonescript"
npm ERR! cwd /usr/lib/node_modules/npm/node_modules/node-gyp/bin
npm ERR! node -v v0.8.22
npm ERR! npm -v 1.2.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /usr/lib/node_modules/npm/node_modules/node-gyp/bin/npm-debug.log
npm ERR! not ok code 0
the 'path' var is undefined, a fix is available at koenkooi@c5851b0
Currently you need to cheat if you want to export a gpio only if it wasn't previously exported:
var path = require('path');
// Set IO enable pins to disabled.
if(!path.existsSync('/sys/class/gpio/gpio38/value')) {
pinMode(bone.P8_3, 'out', 7, 'pulldown', 'slow');
pinMode(bone.P8_5, 'out', 7, 'pullup', 'slow');
}
On the cape I'm working with these pins turn on the high current electronics, so glitching due to re-initializing the pins should be avoided.
If I try to use EHRPWM1A and EHRPWM1B:
b.pinMode('P9_14', b.OUTPUT);
b.pinMode('P9_16', b.OUTPUT);
b.analogWrite('P9_14', 0.5, 100);
b.analogWrite('P9_16', 0.5, 100);
...whichever is initialized second doesn't work. If I look in /sys/devices/ocp.2,
# ls pwm*
pwm_test_P9_14.14:
driver duty modalias period polarity power run subsystem uevent
pwm_test_P9_16.15:
modalias power subsystem uevent
I get the following error on analogWrite
Error: ENOENT, no such file or directory '/sys/devices/ocp.2/pwm_test_P9_14.14/polarity'
There's an analogWrite function, but no function to read the current settings. A crude implementation can be seen at koenkooi@345d6cf
The current output:
debug - websocket writing 5:::{"name":"PWM","args":[[0,0,0]]}
Is way too chatty and should be turned off by default.
Here is something really odd, using the latest bonescript from the repo, I can crash the network connection by trying to use pin P9_15. Here is the sample code that will crash stuff:
var b = require('bonescript');
b.pinMode("P9_15", b.OUTPUT);
@jadonk to the rescue...
Here's the fix in /usr/lib/node_modules/bonescript/autorun.js:
function appExists(exists) {
if(exists) {
if(file.match(/\.js$/)) {
winston.info('start: ' + file);
apps[file] = child_process.spawn(process.argv[0], [ar + '/' + file]);
apps[file].on('close', appClosed);
onStdout = function(data) {
winston.info('stdout (' + file + '): ' + data);
};
onStderr = function(data) {
winston.info('stderr (' + file + '):' + data);
};
apps[file].stdout.on('data', onStdout);
apps[file].stderr.on('data', onStderr);
}
}
}
It shouldn't be required to create node modules to add C functions that are compiled on the target. Need to merge in support for C routines that leverage Arduino-for-Userspace-Linux.
I see that by default bone101 will run when the device starts, what is the best way to auto run my node app when the bone starts up? Arduino is so awesome about this.
I am receiving the following error:
Error: ENOENT, no such file or directory '/sys/class/gpio/gpio38/value'
at Object.fs.openSync (fs.js:338:18)
at Object.fs.writeFileSync (fs.js:756:15)
at exports.digitalWrite (/***/node_modules/bonescript/index.js:247:12)
at open (/***/app.js:38:3)
at callbacks (/***/node_modules/express/lib/router/index.js:161:37)
at param (/***/node_modules/express/lib/router/index.js:135:11)
at pass (/***/node_modules/express/lib/router/index.js:142:5)
at Router._dispatch (/***/node_modules/express/lib/router/index.js:170:5)
at Object.router (/***/node_modules/express/lib/router/index.js:33:10)
at next (/***/node_modules/express/node_modules/connect/lib/proto.js:199:15)
The code is:
require('bonescript');
var pin = bone.P8_3;
setup = function() {
pinMode(pin, OUTPUT);
};
var on = function(){
digitalWrite(pin, HIGH);
};
on();
Hi,
I've an error during bonescript installation (global installation). The error happen when the installation call node-gyp configure build. Can you help me?
Tks
Donato
ERROR LOG:
[email protected] preinstall /usr/lib/node_modules/bonescript
node-gyp clean || (exit 0); node-gyp configure build
make: Entering directory /usr/lib/node_modules/bonescript/build' make: Warning: File
../../npm/node_modules/node-gyp/addon.gypi' has modification time 428685850 s in the future
ACTION Regenerating Makefile
gyp: binding.gyp not found (cwd: /usr/lib/node_modules/bonescript/build) while trying to load binding.gyp
make: *** [Makefile] Error 1
make: Leaving directory /usr/lib/node_modules/bonescript/build' gyp ERR! build error gyp ERR! stack Error:
make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Linux 3.8.13
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /usr/lib/node_modules/bonescript
gyp ERR! node -v v0.8.22
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0
doing 'node bonescript/eeprom.js -w bonescript/test-eeproms.json test-dvi-cape.eeprom /nonexistent/file' creates a backtrace, it should check for the file existence first.
make: Entering directory `***/node_modules/bonescript/build'
CXX(target) Release/obj.target/misc/misc.o
../misc.cpp:1:0: warning: "BUILDING_NODE_EXTENSION" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
../misc.cpp:21:27: error: variable or field ‘pollpri_event’ declared void
../misc.cpp:21:27: error: ‘EV_P_’ was not declared in this scope
../misc.cpp:21:46: error: expected primary-expression before ‘int’
../misc.cpp:32:5: error: ‘ev_io’ does not name a type
../misc.cpp:148:31: error: ‘EV_P_’ has not been declared
../misc.cpp:148:43: error: expected ‘,’ or ‘...’ before ‘*’ token
../misc.cpp: In static member function ‘static void Pollpri::Init(v8::Handle<v8::Object>)’:
../misc.cpp:37:34: warning: statement has no effect [-Wunused-value]
../misc.cpp:38:38: warning: left operand of comma operator has no effect [-Wunused-value]
../misc.cpp:47:33: warning: statement has no effect [-Wunused-value]
../misc.cpp: In constructor ‘Pollpri::Pollpri()’:
../misc.cpp:51:49: warning: statement has no effect [-Wunused-value]
../misc.cpp:54:18: error: ‘event_watcher’ was not declared in this scope
../misc.cpp:54:46: error: ‘ev_init’ was not declared in this scope
../misc.cpp:56:9: error: ‘ew’ was not declared in this scope
../misc.cpp: In destructor ‘virtual Pollpri::~Pollpri()’:
../misc.cpp:60:48: warning: statement has no effect [-Wunused-value]
../misc.cpp:63:20: error: ‘EV_DEFAULT_’ was not declared in this scope
../misc.cpp:63:33: error: ‘event_watcher’ was not declared in this scope
../misc.cpp:63:46: error: ‘ev_io_stop’ was not declared in this scope
../misc.cpp: In static member function ‘static v8::Handle<v8::Value> Pollpri::New(const v8::Arguments&)’:
../misc.cpp:67:32: warning: statement has no effect [-Wunused-value]
../misc.cpp:84:49: warning: left operand of comma operator has no effect [-Wunused-value]
../misc.cpp:84:55: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:84:73: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:88:53: warning: left operand of comma operator has no effect [-Wunused-value]
../misc.cpp:88:73: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:93:56: warning: left operand of comma operator has no effect [-Wunused-value]
../misc.cpp:93:60: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:93:63: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:93:83: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:99:43: warning: left operand of comma operator has no effect [-Wunused-value]
../misc.cpp:99:47: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:99:64: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:102:48: warning: left operand of comma operator has no effect [-Wunused-value]
../misc.cpp:102:52: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:102:55: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:102:74: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:105:22: error: ‘class Pollpri’ has no member named ‘ew’
../misc.cpp:105:32: error: ‘EV_READ’ was not declared in this scope
../misc.cpp:105:39: error: ‘ev_io_set’ was not declared in this scope
../misc.cpp:106:21: error: ‘EV_DEFAULT_’ was not declared in this scope
../misc.cpp:106:38: error: ‘ev_io_start’ was not declared in this scope
../misc.cpp:111:32: warning: statement has no effect [-Wunused-value]
../misc.cpp: In member function ‘void Pollpri::Event(Pollpri*, int)’:
../misc.cpp:117:57: warning: left operand of comma operator has no effect [-Wunused-value]
../misc.cpp:117:61: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:117:67: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:118:23: error: ‘EV_READ’ was not declared in this scope
../misc.cpp:126:43: warning: left operand of comma operator has no effect [-Wunused-value]
../misc.cpp:126:47: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:126:64: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:129:48: warning: left operand of comma operator has no effect [-Wunused-value]
../misc.cpp:129:52: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:129:55: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp:129:74: warning: right operand of comma operator has no effect [-Wunused-value]
../misc.cpp: In static member function ‘static void Pollpri::pollpri_event(int)’:
../misc.cpp:149:42: warning: statement has no effect [-Wunused-value]
../misc.cpp:150:44: error: ‘req’ was not declared in this scope
../misc.cpp:151:21: error: ‘revents’ was not declared in this scope
../misc.cpp:152:42: warning: statement has no effect [-Wunused-value]
../misc.cpp: In function ‘void init(v8::Handle<v8::Object>)’:
../misc.cpp:160:33: warning: statement has no effect [-Wunused-value]
make: *** [Release/obj.target/misc/misc.o] Error 1
make: Leaving directory `***/node_modules/bonescript/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (***/.nvm/v0.10.5/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
i found this on the NPM registry
https://github.com/fivdi/onoff
it would be nice to see this form of watch used in bonescript
@jadonk hey man, I see you are at oscon, wish I could be there. I had a question regarding getting the weather station sample app going. It looks like I need to pick up a sensor for that right? http://www.adafruit.com/products/391
When I get that, do you have any docs to show which port to plug that in to? Perhaps there is a blogpost or some other instructions somewhere that I am missing?
Cant say enough about this beagle bone project, love hacking on my embedded projects in nodejs! Looking forward to contributing once I've got my bearings in place. Overall great stuff..!
in eeprom.js:
if(bone[pin].eeprom){ ...
should be:
if(bone[pin].eeprom != undefined) { ...
If not it fails on pin P9_22 where eeprom has index 0.
Hi guys,
So here's an interesting bug I stumbled across. According to all =
versions of the schematics P9.15 is connected to gpio1_16 (U5_R13) via =
R160, but also gpio2_0 (U5_T13) via R161, which is not marked as DNI. I =
assume this was done to get gpmc_csn3 out to a cape pin which of course =
is very useful. But unlike P9.41 and P9.42 this feature isn't documented =
in the SRM or spreadsheets that I could find. After a fresh boot both =
are configured as inputs so the connection to gpio2_0 goes unnoticed by =
anyone using P9.15 (the inputs are configured for opposite pull =
directions which might cause some confusion if they measure the pin and =
find it's biased at 1.56V).
There is a related problem with the pin definition in bone.js for =
gpio1_16. It uses the pinmux reg offset and mode names for gpio2_18 =
(U5_L17) which doesn't go to the cape headers at all (it's mii1_rxd3).
Apologies if I'm wrong about all this..
Regards,
John
*** bone.js.orig 2013-12-01 08:14:48.000000000 +1300
--- bone.js 2013-12-08 16:33:54.000000000 +1300
*** 1023,1041 ****
{
"name": "GPIO1_16",
"gpio": 48,
! "mux": "mii1_rxd3",
"eeprom": 32,
"key": "P9_15",
! "muxRegOffset": "0x134",
"options": [
! "mii1_rxd3",
! "NA",
! "rgmii1_rd3",
! "mmc0_dat5",
! "mmc1_dat2",
! "NA",
! "mcasp0_axr0",
! "gpio2_18"
]
},
{
--- 1023,1041 ----
{
"name": "GPIO1_16",
"gpio": 48,
! "mux": "gpio1_16",
"eeprom": 32,
"key": "P9_15",
! "muxRegOffset": "0x040",
"options": [
! "gpmc_a0",
! "gmii2_txen",
! "rgmii2_tctl",
! "rmii2_txen",
! "gpmc_a16",
! "pr1_mii_mt1_clk",
! "ehrpwm1_tripzone_input",
! "gpio1_16"
]
},
{
Test case:
var b = require('bonescript');
var pin = "P8_13";
b.pinMode(pin, b.OUTPUT);
b.analogWrite(pin, 0.5);
Result
error: Unable to load capemgr slot for bone_pwm_P8_13: Error: EEXIST, file already exists
error: Unable to load capemgr slot for bspm_P8_13_c: Error: EEXIST, file already exists
/usr/lib/node_modules/bonescript/index.js:483
fs.writeFileSync(path+'/request', '0');
^
ReferenceError: path is not defined
at Object.f.analogWrite (/usr/lib/node_modules/bonescript/index.js:483:30)
at Object.<anonymous> (/var/lib/cloud9/ProgBBB/06_03_analogWrite.js:7:3)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:245:9)
Issue is that a devicetree overlay for the pin is already loaded. Multiple ways exist to work-around this or resolve this, such as:
I'm getting unexpected behavior with attachInterrupt. My interrupt handlers are firing only the first 30 seconds or so of running the code, then they stop responding, even though digitalRead shows the pins dropping/changing state. Even when they do respond in the first 30 seconds, sometimes only one handler works, while the other doesn't, or they work only intermittently, or only one stops working for a bit, then both after 20-30 seconds or so.
Here's the code to reproduce. I'm using pullup resistors on both, for a home security system:
ARM_PIN = bone.P9_12;
DISARM_PIN = bone.P9_42;
function arm(x) {
console.log("arm");
}
function disarm(x) {
console.log("disarm");
}
setup = function() {
pinMode(ARM_PIN, INPUT, 7, 'pullup');
pinMode(DISARM_PIN, INPUT, 7, 'pullup');
attachInterrupt(ARM_PIN, arm, 'falling');
attachInterrupt(DISARM_PIN, disarm, 'falling');
}
loop = function() {
// do nothing
}
I get the same behavior whether I have both handlers attached or only one, so it's not a multiple-handler issue.
Any ideas?
What is the best way to see the winston.debug statements in index.js? Is there a flag I pass in? I assume they will show up in the console? It would help while debugging to take a look at those. Thanks.
I am trying to upgrade my bonescript package on my beaglebone black (3.8). My current version is 1.0.12 (per opkg info). When I run the opkg update, it does not actually update. I then tried to install via npm, and get the following error:
error [email protected] preinstall: node-gyp clean || (exit 0); node-gyp configure build
94 error sh "-c" "node-gyp clean || (exit 0); node-gyp configure build"
failed with 1
95 error Failed at the [email protected] preinstall script.
95 error This is most likely a problem with the bonescript package,
95 error not with npm itself.
95 error Tell the author that this fails on your system:
95 error node-gyp clean || (exit 0); node-gyp configure build
95 error You can get their info via:
95 error npm owner ls bonescript
95 error There is likely additional logging output above.
96 error System Linux 3.8.13
97 error command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "bonescript"
98 error cwd /usr/lib/node_modules
99 error node -v v0.8.22
100 error npm -v 1.2.14
101 error code ELIFECYCLE
102 verbose exit [ 1, true ]
Any idea what is going on?
Thanks, Josh.
Errors occur when attempting to install or use BoneScript on Ubuntu. I am sure this is a known issue, but is there any workaround for it? If not, are there any plans to add support for distros other than Angstrom in the future?
I'm finding myself going in circles on enabling and using PWM outputs. Presently I have only HDMI cape running (with external HDMI monitor attached) and no other plugin boards although I am wanting to add a LCD3 cape in near future.
If I look at documents it appears that P9_22 as PWM should be available as it's not used by HDMI or LCD but when I perform and analogWrite to this pin I get
fs.js:429
return binding.write(fd, buffer, offset, length, position);
^
Error: EINVAL, invalid argument
error.
I was under the impression that bonescript does setup the mux to correct value but now I am not so sure.
My question is do I need to set pin modes myself or should bonescript take care of this for me?
npm info bonescript is showing version 0.2.4
Thanks in advance,
Colin
I hope you do not bother that we make issues for the ones still missing to get the functions from Arduino working.
I am thinking about helping implementing those functions, if I can figure out how this works :).
This is only a file read, right?
It should be possible to interchange digital and analog functions for them to do something rational.
digitalRead on AIN: if > THRESHOLD then return HIGH, otherwise return LOW
analogRead on DIN: return 0 or 1 depending on digital state
digitalWrite on PWM: set duty cycle to 0 or 1
analogWrite on DOUT: if > THRESHOLD then set to HIGH, otherwise set to LOW
THRESHOLD = 0.5
I'd like to hook up a wireless transceiver via SPI. The existing shiftOut() function seems to support only writing to the SPI bus.
I think it would make a lot of sense to have something similar (or even idential to Arduino's SPI library): http://arduino.cc/en/Reference/SPI
I've setup my BBB with the overlay and could hack/test anything related...
Evaluate how to best utilize http://semu.github.com/noduino/ and contribute back to it.
Was reading over the code in index.js and identified a potential bug.
on line 144: gpio[n] = {'path': gpioFile};
on line 178: gpio[n] = {};
However "n" is not created until line 186
Can you please make clear under what license the code is available e.g. add a LICENSE file. Thank you.
When would bonescript have the capability to change the mux on ports?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.