Skip to main content
Connect to UART serial ports on Lager Boxes for serial communication with devices.

Syntax

Arguments

Options


Usage

Read-Only Mode (Default)

Interactive Mode

Get Serial Port Info

A Net Held By Another Session

A UART device takes one reader at a time, so a second session on the same net is refused:
Two nets can name the same device. In that case the error names the device path and the net that holds it: UART device /dev/ttyUSB0 is already in use by net 'SERIAL2'. The take-over command names that net too. Ask the box who holds what:
How long a holder keeps the net:
  • A holder whose client reads gone releases the net within about 0.1 seconds. If the adapter re-enumerates at that time, the release can take up to 60 seconds.
  • A holder whose computer went to sleep, or lost its network, still reads connected for about 85 seconds.
  • A holder whose reader reads stopped does not block you. The next lager uart on the net reclaims it.
A holder that reads connected can belong to somebody, so check before you take it:
--force releases every session that holds the net, and then connects. If it releases a session, it prints Released the session that held 'SERIAL1'. If nothing held the net, it prints nothing. The session that you displaced stops receiving data and prints Error: UART net 'SERIAL1' was taken over by another client. --force acts only on the net that you name. If the error names a device path, another net on the same device holds it. Take over the net that the error names. An older box does not name that net, so use --sessions to find it. --sessions prints one of these messages instead of a table:
  • No UART sessions are active on this box. No session holds a net.
  • This box does not report UART sessions; update it with lager update. The box is older than 0.46.0. Run lager update. On such a box, --force prints a warning that the box is too old to support it.
--force cannot clear this error: UART device /dev/ttyUSB0 is already in use (locked by another session or the lager uart CLI). Another process holds the port, for example a lager python script that opened the UART net. Stop that process first.
--force takes the box lock, as every lager uart command that connects does. If another user holds the box lock, it fails with Error: Box 'my-lager-box' is locked by <holder>. --sessions does not take the box lock, so it works while another user holds it.
If the box does not start the session within 15 seconds, the command prints Error: the box did not start the UART session within 15s and exits 1.

Serial Configuration

Baudrate

Common baudrates:
  • 9600 (default for many devices)
  • 19200
  • 38400
  • 57600
  • 115200 (common for embedded development)
  • 230400
  • 460800
  • 921600

Data Format

Flow Control

Flow control types cannot be combined.

Line Endings

Use --opost to automatically convert line endings on output.

Command Echo

In interactive mode, many device CLIs echo each command back before they reply. Lager already shows what you type, so it hides that echo. After each command, Lager drops the next line only if it is the command itself. It ignores line endings, color codes, and a prompt in front of the command. Any other line is shown, so a device that does not echo still shows its reply. For a device you know does not echo, --no-echo turns this off and shows every received line:

Supported USB Serial Adapters

The following USB-to-serial adapters are automatically detected and supported: These adapters are automatically recognized by lager instruments and can be configured as UART nets.

Device Path Support

UART nets can reference devices two ways: USB Serial Number (preferred):
Direct Device Path (fallback): if the adapter has no serial number, save a net on its device path. The last argument is a label of your choice. Then connect to the net by name. lager uart does not accept a device path in place of a net name.

Examples


WebSocket Connection

The UART command uses WebSocket for communication:
  • Provides real-time bidirectional data
  • Supports both read-only and interactive modes
  • If the USB adapter re-enumerates, the box reopens it for up to 60 seconds and the session continues. The CLI prints [UART device disconnected - reconnecting...] while it waits.
  • The CLI does not reconnect to the box. If the connection to the box drops, the session ends. Run the command again.

Troubleshooting

Device Not Found

Permission Denied

No Output

  • Check baudrate matches device
  • Verify TX/RX connections
  • Try interactive mode to test input
  • Check flow control settings

Notes

  • Interactive mode requires a TTY terminal
  • USB serial numbers are truncated for display
  • Default net can be set with lager defaults add --uart-net
  • The box reopens an adapter that re-enumerates, for up to 60 seconds

See Also