serial-worker
v1.0.5
Published
Run node-serial module in another node thread
Downloads
4
Readme
Node-Serialport-Worker
Run Node-serialport in a separate thread!###
Extremely high CPU usage inside Electron? https://github.com/atom/electron/issues/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 ConstructorSerial.list
List current available portsSerial.parser
Original serialport parsersSerialPort.isOpen(callback)
Note this method is Async, which is different than the originalserialport.isOpen
SerialPort.on('open')
SerialPort Open EventSerialPort.on('data')
SerialPort Data EventSerialPort.on('close')
SerialPort Close EventSerialPort.on('error')
SerialPort.pause()
Pause ConnectionSerialPort.resume()
Resume ConnectionSerialPort.close(callback)
Close portSerialPort.open(callback)
Open portSerialPort.set(options,callback)
SerialPort.write(buffer,callback)
Writes data to the SerialPort.SerialPort.flush(callback)
SerialPort.drain(callback)
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
###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