0

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.

> arduino@1.0.0 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! arduino@1.0.0 start: `node server/index.js`
npm ERR! Exit status 139
npm ERR!
npm ERR! Failed at the arduino@1.0.0 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 npm@6.5.0-next.0
3 info using node@v11.6.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle arduino@1.0.0~prestart: arduino@1.0.0
6 info lifecycle arduino@1.0.0~start: arduino@1.0.0
7 verbose lifecycle arduino@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle arduino@1.0.0~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 arduino@1.0.0~start: CWD: /home/juan/desarrollo web/arduino/arduino
10 silly lifecycle arduino@1.0.0~start: Args: [ '-c', 'node server/index.js' ]
11 silly lifecycle arduino@1.0.0~start: Returned: code: 139  signal: null
12 info lifecycle arduino@1.0.0~start: Failed to exec start script
13 verbose stack Error: arduino@1.0.0 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 arduino@1.0.0
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 arduino@1.0.0 start: `node server/index.js`
22 error Exit status 139
23 error Failed at the arduino@1.0.0 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.

1 respuesta 1

0

El problema se arregla bajando la versión del paquete serialport a la 6.2.2, a partir de la 7 hay problemas con él.

https://github.com/node-serialport/node-serialport/issues/1770

Tu Respuesta

Al pulsar en “Publica tu respuesta”, muestras tu consentimiento a nuestros términos de servicio, política de privacidad y política de cookies

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.