Skip to content

Repository files navigation

node-serialport-rs

Rust-backed serial ports for Node.js, with a SerialPort 13-compatible API.

  • Parallel I/O through a dedicated, bounded Rust worker pool.
  • Consistently lower p95 and p99 latency with a comparable median in recorded Linux ARM64 PTY runs. Measurements.
  • Streams, parsers, bindings, and a pure-JavaScript mock in one package.
  • No JavaScript runtime dependencies.
  • Bounded read-ahead and explicit ownership of queued buffers.

One active port starts one I/O worker. More ports share up to four workers, which retire after their last port closes. Original SerialPort also uses native threads; this implementation separates serial I/O from Node's shared libuv worker pool.

Install

Requires Node.js 20 or newer. Get the latest npm release:

npm install @dragonwork/node-serialport-rs

Quick start

import {SerialPort, ReadlineParser} from '@dragonwork/node-serialport-rs';

const port = new SerialPort({path: '/dev/ttyUSB0', baudRate: 115200});
const lines = port.pipe(new ReadlineParser({delimiter: '\r\n'}));

port.on('error', error => console.error(error.message));
lines.on('data', line => console.log(line));
port.on('open', () => {
  port.write('status\r\n', error => {
    if (error) console.error(error.message);
  });
});

CommonJS works too: const {SerialPort} = require('@dragonwork/node-serialport-rs').

Documentation

Acknowledgements

Thanks to the SerialPort maintainers and contributors. Its API and testing approach helped shape this project.

License

Copyright 2026 DragonWork. Apache-2.0. See NOTICE and third-party licenses.

About

Rust-backed serial ports for Node.js with parallel I/O and SerialPort-compatible APIs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages