Intento leer una sucesión consecutiva de números(123456..) enviada por un Arduino a mi aplicación. El problema estriba al intentar ejecutarlo con npm start
, devuelve un error con log.
> [email protected] start /home/juan/desarrollo web/arduino/arduino
> node server/index.js
Segmentation fault (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 139
npm ERR! [email protected] start: `node server/index.js`
npm ERR! Exit status 139
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/juan/.npm/_logs/2019-01-11T14_16_02_470Z-debug.log
Anexo el contenido del log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/juan/desarrollo web/arduino/arduino/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
9 verbose lifecycle [email protected]~start: CWD: /home/juan/desarrollo web/arduino/arduino
10 silly lifecycle [email protected]~start: Args: [ '-c', 'node server/index.js' ]
11 silly lifecycle [email protected]~start: Returned: code: 139 signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `node server/index.js`
13 verbose stack Exit status 139
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:188:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:188:13)
13 verbose stack at maybeClose (internal/child_process.js:978:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/juan/desarrollo web/arduino/arduino
16 verbose Linux 4.15.0-43-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
18 verbose node v11.6.0
19 verbose npm v6.5.0-next.0
20 error code ELIFECYCLE
21 error errno 139
22 error [email protected] start: `node server/index.js`
22 error Exit status 139
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 139, true ]
Código fuente
const SerialPort = require('serialport');
const Readline = SerialPort.parsers.Readline;
const parser = new Readline();
var mySerial = new SerialPort('/dev/ttyACM0', {
baudRate: 9600
});
Anexo el package.json
{
"name": "arduino",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"serialport": "^7.1.0"
}
}
Código del Arduino
int counter = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print(++counter, DEC);
delay(2000);
}
Como observación, he probado cat /dev/ttyACM0
y ha respondido satisfactoriamente, pero no encuentro causa del porqué no funciona en Node.js.