Reference

UART

Auxiliary UART handles and console-routing words for boards that expose them.


UART is a ESP32 peripheral surface. It is for serial devices and, on some boards, explicit console routing. It is not part of the beginner Frothy beginner path.

Availability

The esp32_devkit_v1 board source exposes auxiliary UART bindings. The active console itself is still special: it carries REPL input, output, and host attachment.

Auxiliary UART

uart.init: (uart) (tx, rx, baud) -> Int

Creates an auxiliary UART handle.

aux is uart.init: UART_TX, UART_RX, 115200

uart.write: (uart) (byte, uart) -> nil

Writes one byte.

uart.write: 65, aux

uart.read: (uart) (uart) -> Int

Reads one byte.

uart.read: aux

uart.key?: (uart) (uart) -> Bool

Returns true when at least one byte is waiting.

when uart.key?: aux [
  uart.read: aux
]

Console Routing

Boards that support console routing expose words for the active REPL transport:

console.info: (uart) () -> nil

Reports the current console route.

console.default: (uart) () -> nil

Returns the console to its default route.

console.uart!: (uart) (port, tx, rx, baud) -> nil

Moves the console to a selected UART route.

Use console-routing words carefully. If you move the REPL away from the host connection you are using, you can make the board appear unresponsive until you attach through the new route or reset to a safe state.