Skip to content

serial-tools

serial-tools is a serial port toolkit: the xmake monitor command, plus a serial module the other addons reuse.

PayloadWhat it provides
plugins/monitorthe xmake monitor command, it streams a serial port to your terminal
modules/serialthe serial module, so other addons reuse the port detection and the monitor

It works like idf.py monitor or the Arduino serial monitor, without any extra dependency: it auto-detects the connected port, and speaks to it through stty on macOS/Linux/BSD and through the .NET System.IO.Ports api on Windows.

Install

sh
$ xmake addon --install serial-tools

The board addons (esp32-devel, avr-devel) depend on it, so installing them installs this one too.

Usage

sh
$ xmake monitor --list                       # the available serial ports
$ xmake monitor                              # the only connected port, 115200 by default
$ xmake monitor --port=/dev/ttyUSB0 --baud=9600
$ xmake monitor --databits=8 --parity=even --stopbits=1

Ctrl-C exits.

OptionDefaultDescription
-p, --portauto-detectedthe serial port
-b, --baud115200the baud rate
-d, --databits85, 6, 7, 8
--paritynonenone, even, odd
-s, --stopbits11, 2
-l, --listlist the available ports

Reuse the serial module

Another addon can depend on it and import the module:

lua
import("@addon.serial-tools.serial")

local port = serial.resolve_port(get_config("port"))   -- auto-detected when nil
serial.monitor(port, {baud = 115200})
InterfaceDescription
serial.ports()the available serial ports of the host
serial.resolve_port(port)the given port, or auto-detect it (raises when ambiguous)
serial.monitor(port, opt)stream until Ctrl-C, opt = {baud, databits, parity, stopbits, quiet}