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 process
My goal is to have the same api as the original node-serialport https://github.com/voodootikigod/node-serialport.
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('disconnect')
SerialPort Disconnect 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)
$ 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!');
});
})
Please let Me know any problem/issues
For serialport
API https://github.com/voodootikigod/node-serialport
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