# serial-worker

> Run node-serial module in another node thread

Latest version **1.0.5** (published 2016-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install serial-worker
pnpm add serial-worker
yarn add serial-worker
bun add serial-worker
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2016-03-25 |
| First published | 2016-02-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | weizhi wang |
| Maintainers | weiway |

## Links

- npm: https://www.npmjs.com/package/serial-worker
- Repository: https://github.com/weiway/node-serialport-worker
- Homepage: https://github.com/weiway/node-serialport-worker#readme
- Issues: https://github.com/weiway/node-serialport-worker/issues
- npm.io page: https://npm.io/package/serial-worker

## Dependencies (1)

- [serialport](https://npm.io/package/serialport.md) ^2.0.5

## Recent versions

- 1.0.5 (latest) — 2016-03-25
- 1.0.4 — 2016-03-25
- 1.0.3 — 2016-03-10
- 1.0.2 — 2016-03-09
- 1.0.1 — 2016-02-25
- 1.0.0 — 2016-02-23

## README

[![Build Status](https://travis-ci.org/weiway/node-serialport-worker.svg?branch=master)](https://travis-ci.org/weiway/node-serialport-worker)
[![Dependency Status](https://david-dm.org/weiway/node-serialport-worker.svg)](https://david-dm.org/weiway/node-serialport-worker)

## 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 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.on('error')```
- ```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.
- ```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

---
_Source: https://npm.io/package/serial-worker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
