How to use the serialport.SerialPort function in serialport

To help you get started, we’ve selected a few serialport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github serialport / node-serialport / examples / break.js View on Github external
////////////////////////////////////////////////////////
// Use the cool library                               //
// git://github.com/voodootikigod/node-serialport.git //
// to send break condition.                           //
////////////////////////////////////////////////////////               
var com = require("serialport");

var serialPort = new com.SerialPort("/dev/tty.usbserial-A700eTSd", {
    baudrate: 115200,
    parser: com.parsers.readline('\r\n')
  }, false);

serialPort.on('open',function() {
  console.log('Port open');
});

serialPort.on('data', function(data) {
  console.log(data);
});

function asserting() {
  console.log('asserting');
  serialPort.set({brk:true}, function(err, something) {
    console.log('asserted');
github vshymanskyy / blynk-library-js / bin / blynk-gateway-usb.js View on Github external
function openPort(port) {
  var serialPort = new serial.SerialPort(port.comName, {
    baudrate: port.baudrate
  }, false);

  // TODO: Retry open
  serialPort.open(function (err) {
    if (err) throw err;
    console.log('Port opened:', port.comName);
    makeTcpBridge(serialPort);
  });
}
github jamesnesfield / node-waterrower / Waterrower / index.js View on Github external
var read = function(callback) { // this should be 'setup'

      debug("in read connecting to " + portname);
      state = "connecting";
	  conn = new com.SerialPort(portname, {
	    baudrate: BAUD_RATE, disconnectedCallback:function () { callback("disconnected") },
	    parser: com.parsers.readline("\n")
	  });
	  conn.on("error", function(err) {
	    debug("in read " + err);
	    debug("Cannot connect to " + portname);
	    state = "error";
	    callback(state);
	  });
	  conn.on("open", function () {
	    debug("in read open");
	    state = "read"; // state should be 'open'
	    callback("");
	  });
	  conn.on("closed", function () {
	    debug("in read closed");
github netAction / CUL_FS20 / CUL_FS20.js View on Github external
function CUL_FS20() {
	this.serialPort = new SerialPort("/dev/ttyACM0", {
		baudrate: 9600
	});
	this.CUL_connected = false;

	this.commands = {
		// List of commands
		// http://fhz4linux.info/tiki-index.php?page=FS20%20Protocol
		// http://www.eecs.iu-bremen.de/archive/bsc-2008/stefanovIvan.pdf
		'off' : '00',
		'dim06' : '01', // Switch to Brightness level 1 (min.)
		'dim12' : '02',
		'dim18' : '03',
		'dim25' : '04',
		'dim31' : '05',
		'dim37' : '06',
		'dim43' : '07',
github FPGAwars / icestudio / icestudio / js / app.js View on Github external
$scope.serialOpen = function () {
        if (!$scope.port) {
            var openOptions = {
              baudRate: $scope.serialdata.selectedBaudRate,
              dataBits: 8,
              parity: 'none',
              stopBits: 1
            };

            $scope.port = new SerialPort.SerialPort($scope.serialdata.selectedPort, openOptions, false);

            $scope.port.on('open', function (error) {
                if (!error) {
                    $scope.port.on('data', function (data) {
                        div_terminal.innerHTML += data.toString();
                    });

                    $scope.port.on('error', function (err) {
                        console.log(err);
                    });

                    $scope.serialClear();
                    $scope.port.set({rts:false, dtr:false}, function(err, results) { });
                    $scope.port.flush();

                    document.getElementById('serial-status').style.fill = '#3DD738';
github charliegerard / leap_sphero / node_modules / spheron / lib / sphero.js View on Github external
_sphero.open = function(device, callback) {
    _serialPort = new serialPort.SerialPort(device, {
      parser:responseParser.spheroResponseParser()
    }, true, function(err){ 
      if (err){
        if (callback && typeof(callback) == 'function'){
          callback(err);
        }
      }});

    _serialPort.on('open', function() {
      _serialPort.on('data', function(packet) {
        _sphero.emit('packet', packet);
        switch (packet.SOP2) {
          case 0xFF:
            _sphero.emit('message', packet);
            break;
          case 0xFE:
github AdamMagaluk / leo / commands / console.js View on Github external
function run(env){
  if(!env.port){
    out.error('Serial port not specified.');
    process.exit(1);
  }
  


  var serialPort = new SerialPort(env.port, {
    baudrate: env.baud
  });

  serialPort.on("open", function () {
    out.log('Console open, use Ctr-c to exit.\r\n');

    process.stdin.setEncoding('utf8');

    process.stdin.on('readable', function() {
      var chunk = process.stdin.read();
      if (chunk !== null) {
	serialPort.write(chunk.toString());
      }
    });

    process.stdin.on('end', function() {
github kylemcdonald / Highsight / Control / roboteq.js View on Github external
getComName(function(err, comName) {
    if(err) {
      setSerialStatus('not found, searching');
      reconnect();
      return;
    }
    serial = new serialport.SerialPort(comName, {
      baudrate: 115200,
      parser: serialport.parsers.readline('\r'),
      disconnectedCallback: function() {
        setSerialStatus('disconnected, reconnecting');
        reconnect();
      }
    }, false);
    serial.on('data', dataCallback);
    serial.open(function(err) {
      if(err) {
        setSerialStatus('error connecting, reconnecting');
        reconnect();
      } else {
        setSerialStatus('connected');
        startupSequence();
      }
github cncjs / cncjs / src / app / controllers / grbl.js View on Github external
constructor(port, baudrate) {
        this.options = _.merge({}, this.options, { port: port, baudrate: baudrate });
        this.serialport = new serialport.SerialPort(this.options.port, {
            baudrate: this.options.baudrate,
            parser: serialport.parsers.readline('\n')
        }, false);

        this.grbl = new Grbl(this.serialport);
        this.grbl.on('raw', (data) => {
        });
        this.grbl.on('status', (status) => {
        });
        this.grbl.on('statuschange', (status) => {
        });
        this.grbl.on('parserstate', (parsestate) => {
        });
        this.grbl.on('parserstatechange', (parsestate) => {
        });
github paulcuth / esp8266-cli / src / SerialComms.js View on Github external
function SerialComms (port) {
	this._echoBuffer = '';
	this._responseBuffer = '';
	this._port = new SerialPort(port, { 
		baudrate: 9600,
		disconnectedCallback: process.exit
	}, false);

	this._initPort();
}

serialport

Node.js package to access serial ports. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!

MIT
Latest version published 8 months ago

Package Health Score

88 / 100
Full package analysis