Last active
August 29, 2015 14:08
-
-
Save karlosgliberal/ea642bd38716dbb0d470 to your computer and use it in GitHub Desktop.
Definición básica del modulo serialport
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var serialport = require("serialport"), //modulo puerto serie | |
| SerialPort = serialport.SerialPort, | |
| portName = process.argv[2], | |
| ledState = false; | |
| //Configuración básica del puerto y su tasa de transferencia (dependerá de tu sistema) | |
| var myPort = new SerialPort("/dev/ttyACM0", { | |
| baudRate: 115200, | |
| options: false, | |
| parser: serialport.parsers.readline("\r\n") | |
| }); | |
| // Llamada cuendo el pueto serie esta abierto: | |
| myPort.on('open', function() { | |
| console.log('port open'); | |
| //Definimos la pripeidad abierta como verdadera: | |
| myPort.options.open = true; | |
| }); | |
| // Llamada cuando hay datos en el puerto serie: | |
| myPort.on('data', function (data) { | |
| //Pintamos estas datos en el output: | |
| console.log('data: ', data); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment