ecto / duino Goto Github PK
View Code? Open in Web Editor NEW:bulb: Arduino framework for node.js
:bulb: Arduino framework for node.js
Sometimes signals will be sent from the Arduino before we bind for data events. To fix this, we'll have to refactor the autoconnection.
There is no need to parse on the JavaScript level at 115k baud when C can do it for us inside node-serialport.
Hello,
I am a member of the GitHub Security Lab (https://securitylab.github.com).
I've attempted to reach a maintainer for this project to report a potential security issue but have been unable to verify the report was received. Please could a project maintainer could contact us at [email protected], using reference GHSL-2020-118?
Thank you,
Kevin Backhouse
GitHub Security Lab
Hi, there is a little bug in your board.analogRead
, the code should be:
Board.prototype.analogRead = function (pin) {
pin = this.normalizePin(pin);
this.log('info', 'analogRead from pin ' + pin);
this.write('04' + pin + this.normalizeVal(0));
}
I'm sorry I haven't created a pull request, but my repository is too messed up right now :D
LiquidCrystal is the built in LCD lib that ships with Arduino, see also: http://www.arduino.cc/en/Reference/LiquidCrystal
I'm not going to pretend that this will be a simple "drop-in" addition, it will definitely require a new handler in du.ino, but I can promise that it will be totally awesome!
When no board is found, the board initialization routine throws an error inside an internal callback (board.js:88).
I propose emitting an "error" event instead of throwing.
Update: Sorry I didn't make a pull request initially, just didn't think that I'd implement it that quickly.
1345814061925 duino info attempting to find Arduino board
1345814061952 duino info found board at undefined
1345814061953 duino info binding serial events
events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: EACCES, open '/dev/usbmon0'
Hi, mi arduino its connect on /dev/ttyACM0, but duino can't open that.
To narrow this down, I added the following to handleServo
:
Serial.println(atoi(val));
Serial.println(atoi(aux));
An example of the output:
1331739178315 duino receive 98A00265
1331739178315 duino receive ss
1331739178315 duino receive got signal
1331739178315 duino receive 26 /* atoi(val) */
1331739178315 duino receive 5 /* atoi(aux) */
If the message being parsed is 98A00265
, then the expected values are:
1331739178315 duino receive 2 /* atoi(val) */
1331739178315 duino receive 65 /* atoi(aux) */
Otherwise, this block:
} else if (atoi(val) == 2) {
Serial.println("writing to servo");
Serial.println(atoi(aux));
servo.write(atoi(aux));
}
...While never be entered.
The issue is here:
strncpy(val, messageBuffer + 4, 3);
val[3] = '\0';
strncpy(aux, messageBuffer + 7, 3);
aux[3] = '\0';
By changing this to:
strncpy(val, messageBuffer + 4, 2);
val[3] = '\0';
strncpy(aux, messageBuffer + 6, 3);
aux[3] = '\0';
... The servo values are written.
I will test this against all of the other modules + hardware and submit a patch when complete.
/Users/rick/clonez/duino/lib/board.js:191
this.log('info', 'analogRead to pin ' + pin + ': ' + val.green);
^
ReferenceError: val is not defined
Love this framework. led.blink() works fine, but I can't get my servo to respond. The servo sweep example that comes with the arduino software works well so I don't think its the servo. Here is what I'm seeing in the log:
1337133106943 duino info attempting to find Arduino board
1337133106947 duino info set pin 13 mode to out
1337133106947 duino info serial not ready, buffering message: 0013001
Express server listening on port 3000 in development mode
1337133106957 duino info found board at /dev/tty.usbmodem411
1337133106957 duino info binding serial events
1337133107459 duino info board ready
1337133107459 duino info sending debug mode toggle on to board
1337133107465 duino write 9900001
1337133107467 duino info processing buffered messages
1337133107467 duino info writing buffered message
1337133107467 duino write 0013001
board ready, attaching servo { board:
{ debug: true,
writeBuffer: [],
_events: { ready: [Function], data: [Function] },
serial:
{ port: '/dev/tty.usbmodem411',
fd: 7,
readStream: [Object],
_events: [Object] } },
pin: '09',
_events: { attached: [Function] } }
1337133107469 duino write 980901
And then it stops. Thoughts? This is my code (pretty much straight from your example):
var arduino = require('duino'),
board = new arduino.Board({debug:true});
var led = new arduino.Led({
board: board,
pin: 13
});
var servo = new arduino.Servo({
board: board,
pin: 9
});
servo.on('attached', function(err) {
console.log('attached');
this.on('read', function(err, pos) {
console.log(pos);
});
this.on('detached', function(err) {
console.log('detached');
});
this.on('aftersweep', function(err) {
led.blink();
this.read();
this.detach();
});
this.sweep();
});
This should probably be done at the same time as Issue #1
anyone know how to connect a DS1820 sensor OneWire to receive temperature data?
I run the basic.js example and the event listener 'on message' isn't triggered.
In lib/board.js:
// 1 is up
// 0 is down
if (m[1] == '1' && self.down) {
self.down = false;
self.emit('up');
}
if (m[1] == '0' && !self.down) {
self.down = true;
self.emit('down');
}
...which is backwards; button "up/unpressed" will be LOW/0/gnd and button "down/pressed" will be HIGH/1/5v
Lets say for instance I have a particular library for a sensor, how would I go about adding this library so it can be accessed through duino.
Seems like it should be really easy, but I'm finding it confusing. How the heck do I access the examples?
It also isn't clear what needs to be running in order for the examples to work. Does srv.web.js need to be listening whilst srv.app.js is also running? I'm not sure.
I've tried:
node srv.web.js
info - socket.io started
Listening on http://localhost:8080
http://localhost:8080/examples/walkLED.html //404
and this:
node srv.app.js
define(['kickstart', 'module', 'path', 'fs'], function (kickstart, module, pat
^
ReferenceError: define is not defined
at Object.<anonymous> (/Users/joshuamcginnis/Dropbox/Joshua/sandbox/node-js-projects/noduino/srv.app.js:11:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Hi,
just installed duino module
var arduino = require('duino'),
board = new arduino.Board();
var led = new arduino.Led({
board: board,
pin: 13,
debug: true
});
led.blink();
$ node duino-1.js
events.js:2725: Uncaught Error: Cannot open /dev/usbdev5.1
My Env: Ubuntu 12.04 LTS on MK803 mini PC (ARM), Node v0.8.14
How can I fix this?
Since board.js is trying to open a device from the *nix /dev
folder, this library cannot possibly work on Windows.
On Windows, the path
(the first argument to SerialPort
constructor) is simply COM1
, COM2
etc., which is the name of the COM port that the driver is using (also see this related thread on using CreateFile
to open a serial port communication channel).
Once the path is correct, things work as expected. Very awesome!
In the long term, I would recommend a general-purpose config that allows for the path to be user-selected, or, if supported on the system, to be looked up automatically.
It would be awesome to have some basic support for a reed sensor in duino.
Hi--,
I attached 2 servo motors on my arduino (declaring servo1, servo2 in node server with different pin).
It always only works with the 2nd motor I attach, duino seems to ignore the first one?
Do you know how to fix this?
Thanks,
If I run the examples/basic.js
the application crashes because the serial port is not opened on the 'connected'
event. Shouldn't the 'connected'
event only be emitted after the SerialPort 'open'
event?
Here https://github.com/ecto/duino/blob/master/lib/board.js#L28, instead of:
self.emit('connected');
do this:
self.serial.on('open', function(){
self.emit('connected');
});
The title says it all.
Current version in npmjs is 0.0.8, which doesn't have the device name fix.
Just for reference, i'm using 0.0.9 on a raspberry pi and it works perfectly
Thankyou
I am running example sensor.js and getting following error:
`1458988219328 duino info attempting to find Arduino board
1458988219400 duino info set pin A0 mode to in
1458988219403 duino info serial not ready, buffering message: 00A0000
1458988219455 duino debug attempting to open serial conn.: ttyACM0
1458988219462 duino info found board at /dev/ttyACM0
1458988219464 duino info binding serial events
1458988219471 duino info analogRead from pin A0
1458988219472 duino write 04A0000
Error: Serialport not open.
at SerialPortFactory.SerialPort.write (/home/pi/SmartHome/node_modules/duino/node_modules/serialport/serialport.js:288:17)
at Board.write (/home/pi/SmartHome/node_modules/duino/lib/board.js:163:17)
at Board.analogRead (/home/pi/SmartHome/node_modules/duino/lib/board.js:235:7)
at null. (/home/pi/SmartHome/node_modules/duino/lib/sensor.js:17:16)
at wrapper as _onTimeout
at Timer.listOnTimeout as ontimeout`
I will appreciate your help
Hi,
has anyone tried to use duino with an Raspberry Pi (with Raspbian)?
The communication using duino is working perfectly on my Mac but if I use my app on the pi the serial communication does not work properly as you can see as follows:
1359682670868 duino info binding serial events
1359682670888 duino receiveA#C� >�2 $$$�
1359682671387 duino info board ready
What could be wrong? I tried baud rates of 9600 and 115200.
Following the instructions I just keep getting a "define not defined" message. Example:
$ node examples/led.js
/Users/ruben/projects/arduino/noduino/node_modules/duino/lib/board.js:1
(function (exports, require, module, __filename, __dirname) { define(function(
^
ReferenceError: define is not defined
at Object.<anonymous> (/Users/ruben/projects/arduino/noduino/node_modules/duino/lib/board.js:1:63)
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.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/Users/ruben/projects/arduino/noduino/node_modules/duino/index.js:3:11)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
Right now only digital pins are supported.
The current npm package is missing the button up/down fix in dc7e870
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.