SerialPilot

/02 — Reference

CLI tools

Three small binaries — list, terminal, repl — for the things you'd otherwise script ad hoc. Install them per-project with npm i or globally with npm i -g; they all use the same N-API bindings as the library.

Install

# once, globally
$ npm install -g @serialpilot/list @serialpilot/terminal @serialpilot/repl

# or per-project; they’re already there if you installed serialpilot $ npx serialpilot-list —format json

serialpilot-list

Enumerate every serial port the OS knows about. The fastest way to verify your device is even visible.

$ serialpilot-list
/dev/tty.usbmodem1421    USB-VID_2341&PID_0043       Arduino LLC
/dev/tty.Bluetooth-Incoming-Port

$ serialpilot-list —format json [{“path”:“/dev/tty.usbmodem1421”,“manufacturer”:“Arduino LLC”,…}]

$ serialpilot-list —format jsonl # one JSON object per line

FlagDefaultNotes
-f, --formattextOne of text, json, jsonl / jsonline.
-h, --helpShow usage.

Pipe the JSON output into jq for ad-hoc filtering:

$ serialpilot-list --format json | jq '.[] | select(.manufacturer | test("arduino"; "i"))'

serialpilot-terminal

An interactive console for talking to a port. Connect, type, see live response, exit on Ctrl-C.

$ serialpilot-terminal --list
# shows ports and exits

$ serialpilot-terminal -p /dev/tty.usbmodem1421 -b 115200 # interactive — bytes you type are sent, bytes received print live

FlagDefaultNotes
-l, --listList ports and exit.
-p, --pathRequired when not listing.
-b, --baudRequired when not listing.
--databits85 / 6 / 7 / 8.
--paritynonenone · even · odd · mark · space.
--stopbits11 · 1.5 · 2.
--no-echoDon't print characters as you type them.
--flow-ctlXONOFF · RTSCTS.

serialpilot-repl

A scriptable Node REPL with SerialPilot and a connected port already in scope. The fastest way to poke at a device interactively.

$ serialpilot-repl
# globals: SerialPilot, SerialPilotMock, path, port
> port = new SerialPilot({ path: '/dev/tty.usbmodem1421', baudRate: 9600 })
> port.on('data', console.log)
> port.write('PING\n')

Set the DEBUG environment variable to trace internals:

$ DEBUG=serialpilot* serialpilot-repl

Scripting tips

  • Pair serialpilot-list --format json with jq to drive shell scripts off device fingerprints.
  • Run serialpilot-terminal --no-echo when piping into a logfile so you don't double-record what you typed.
  • The repl honours NODE_OPTIONS — pass --inspect to attach a debugger.

Edit this page on GitHub