weiway / node-serialport-worker Goto Github PK
View Code? Open in Web Editor NEWRun the node serialport module in a separate node process!
Run the node serialport module in a separate node process!
First, thank you for your hard working.
I just noticed that the disconnect event is not implemented in node-serialport-worker
, could you add it to serial_worker.js?
By now your isOpen() method is asynchronous, which is different from node-serialport:
https://github.com/voodootikigod/node-serialport/blob/master/lib/serialport.js#L254
SerialPort.prototype.isOpen = function() {
return this.fd !== null && !this.closing;
};
Since there is no special processing within the original one, I suggest you can keep an isOpen flag internally, set it to true while receiving a successful SerialPort open event, and set it to false while receiving SerialPort close / disconnect events.
On Windows 10 I have installed electron using:
npm install -g electron-prebuilt
I then created a new project using npm init
and installed node-serialport-worker
using:
npm install serial-worker --save
My application simply does:
const electron = require('electron');
const serial = require('serial-worker');
...
...
...
...
serial.list((e,ports)=>{
console.log(ports)
});
When I try to run I get:
App threw an error when running [Error: A dynamic link library (DLL) initialization routine failed.
\\?\Z:\Desktop\winplc\node_modules\serialport\build\Release\node-v47-win32-x64\serialport.node]
ATOM_SHELL_ASAR.js:157
return old.apply(this, arguments);
^
Error: A dynamic link library (DLL) initialization routine failed.
\\?\Z:\Desktop\winplc\node_modules\serialport\build\Release\node-v47-win32-x64\serialport.node
at Error (native)
at process.module.(anonymous function) [as dlopen] (ATOM_SHELL_ASAR.js:157:20)
at Object.Module._extensions..node (module.js:450:18)
at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:157:20)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (Z:\Desktop\winplc\node_modules\serialport\serialport.js:14:25)
at Module._compile (module.js:425:26)
Any guidance will be appreciated.
I construct two SerialInterface Object
let a1 = new SerialInterface()
let a2 = new SerialInterface()
when I emit a "close" Event in a1 , the listener of "close" Event in a1 and a2 will react at the save time.
The parser option is a function type, it cannot use process.send() to pass a function to serial_worker.js:
var port = new SerialPort('/dev/tty-usbserial1', {
parser: serialport.parsers.readline('\n')
});
Might be you can use an alternative way to specify the parser option. For example:
For the raw parser:
parser: 'raw'
For the readline parser:
parser: {
type: 'readline',
delimiter: '\n',
encoding: 'utf8'
}
ref. https://github.com/voodootikigod/node-serialport/blob/master/lib/parsers.js
I've noticed that after disconnecting and reconnecting, subsequent write requests are triggered twice. If I disconnect and reconnect another time, events are triggered 3 times. Looks like events or the process aren't being removed properly.
Hello,
I got some big CPU usage on Electron with serial port and I tried yours. It would be verry useful for me to make it works but I've a problem with this module. When I run it, it's said :
Identifier 'process' has already been declared
serial-worker/serial_master.js:5 Uncaught SyntaxError: Identifier 'process' has already been declared
if I replace "const process" by "var process" in this line, I've another one : "Uncaught Error: channel closed" but maybe caused by the const to var?
Thank's for this module, realy look forward to get it work
I am trying out node-serialport-worker as a drop in replacement for node-serialport and noticed that the openImmediate option doesn't seem to do anything. Calling open manually however worked as expected.
your 'serial-worker' module depends on [email protected],but there is a bug in [email protected]. when I run "port.close()" ,the event "close" can be emit correctly. if I pull BLE device out,the event "close" can't be emit and throw a error "TypeError: undefined is not a function".The [email protected] has fixed this bug.``
"dependencies": {
"serialport": "^6.0.0"
},
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.