Giter VIP home page Giter VIP logo

node-serialport-worker's Introduction

Build Status Dependency Status

Node-Serialport-Worker

Run Node-serialport in a separate thread!###

Extremely high CPU usage inside Electron? electron/electron#2928

Try this module. Electron + SerialPort = better IOT

This module is aimed for creating a interface for using node-serialport in a seperate node thread

My goal is to have the same api as the original node-serialport https://github.com/voodootikigod/node-serialport.

API

I'm trying to create a uniform api to make using serial-worker as easy as re-writting require("serialport") to require("serial-worker")

Current Supported API:

  • Serial.SerialPort SerialPort Constructor
  • Serial.list List current available ports
  • Serial.parser Original serialport parsers
  • SerialPort.isOpen(callback) Note this method is Async, which is different than the original serialport.isOpen
  • SerialPort.on('open') SerialPort Open Event
  • SerialPort.on('data') SerialPort Data Event
  • SerialPort.on('close') SerialPort Close Event
  • SerialPort.pause() Pause Connection
  • SerialPort.resume() Resume Connection
  • SerialPort.close(callback) Close port
  • SerialPort.open(callback) Open port
  • SerialPort.set(options,callback)
  • SerialPort.write(buffer,callback) Writes data to the SerialPort.

Usage

$ npm install serial-worker

Use serial worker just like the original node-serialport

const serial = require('serialport-worker');
var port = new serial.SerialPort(path, options, immediate, callback);

serial.list((e,ports)=>{
    console.log(ports)
});

port.on('data',(data)=>{
  console.log(data);
});

port.open(()=>{
    port.write(new Buffer('Hello!','utf8'),()=>{
        console.log('Written!');
    });
})

###Known Issue###

Please let Me know any problem/issues

For serialport API https://github.com/voodootikigod/node-serialport

###Pending API###

  • SerialPort.flush(callback)
  • SerialPort.drain(callback)
  • SerialPort.on('error',callback)

###Testing###

I'm trying to figure out how to test port connection on travis-ci Right now I'm testing locally with a Arduino Uno

If you want to test locally, please set noTravis to true in test/serialport-0.js

Currently some tests are copied from node-serialport ( https://github.com/voodootikigod/node-serialport ), in the future, hope serialport worker will pass all node-serialport tests

node-serialport-worker's People

Contributors

dudeofawesome avatar tibus avatar weiway avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.