Skip to main content

UsbBridge

caution

This service is rc and may change in the future.

This service is normally not announced or otherwise exposed on the serial bus. It is used to communicate with a USB-Jacdac bridge at the USB layer. The host sends broadcast packets to this service to control the link layer. The device responds with broadcast reports (no-one else does that). These packets are not forwarded to the UART Jacdac line.

Packets are sent over USB Serial (CDC). The host shall set the CDC to 1Mbaud 8N1 (even though in some cases the USB interface is connected directly to the MCU and line settings are ignored).

The CDC line carries both Jacdac frames and serial logging output. Jacdac frames have valid CRC and are framed by delimeter characters and possibly fragmented.

0xFE is used as a framing byte. Note that bytes 0xF8-0xFF are always invalid UTF-8. 0xFF occurs relatively often in Jacdac packets, so is not used for framing.

The following sequences are supported:

  • 0xFE 0xF8 - literal 0xFE
  • 0xFE 0xF9 - reserved; ignore
  • 0xFE 0xFA - indicates that some serial logs were dropped at this point
  • 0xFE 0xFB - indicates that some Jacdac frames were dropped at this point
  • 0xFE 0xFC - Jacdac frame start
  • 0xFE 0xFD - Jacdac frame end

0xFE followed by any other byte:

  • in serial, should be treated as literal 0xFE (and the byte as itself, unless it's 0xFE)
  • in frame data, should terminate the current frame fragment, and ideally have all data (incl. fragment start) in the current frame fragment treated as serial

import { UsbBridge } from "@devicescript/core"

const usbBridge = new UsbBridge()

Commands

disablePackets

Disables forwarding of Jacdac packets.

usbBridge.disablePackets(): Promise<void>

enablePackets

Enables forwarding of Jacdac packets.

usbBridge.enablePackets(): Promise<void>

disableLog

Disables forwarding of serial log messages.

usbBridge.disableLog(): Promise<void>

enableLog

Enables forwarding of serial log messages.

usbBridge.enableLog(): Promise<void>