pamoja for TypeScript - v0.2.0
    Preparing search index...

    Class SerialPort

    One serial port, shared by the program and every driver built on it.

    SerialPort.open(path, settings) opens the kernel's serial device raw on a Linux board and throws anywhere else. SerialPort.looped(settings) is a line with TX wired to RX, SerialPort.pair(settings) the two ends of a null-modem cable, and SerialPort.scripted(settings, steps) a port that checks each write against a script. write and read return promises that reject with the reason.

    Index
    • get received(): number

      How many bytes have been read through the port.

      Returns number

    • get remaining(): number | null

      How many steps a script has left, or null when the port is not scripted.

      Returns number | null

    • get waitedMicros(): number

      How long reads have waited without an answer, and waits have waited, in microseconds, whether or not the process slept through it.

      Returns number

    • get written(): number

      How many bytes have been written through the port.

      Returns number

    • Drops whatever has arrived and not been read, as a client does before a request so a stale reply cannot be taken for the new one.

      Returns void

    • Reads up to max bytes, waiting up to timeoutMs for the first one when nothing has arrived. Resolves with what arrived, empty when the timeout passed with nothing.

      Parameters

      • max: number
      • timeoutMs: number

      Returns Promise<Buffer<ArrayBufferLike>>

    • Waits, as a protocol does to leave the line silent between frames: really on the kernel's device, and anywhere else the wait is only counted.

      Parameters

      • ms: number

      Returns Promise<void>

    • Writes bytes, resolving once they have left the UART. Rejects when a script expected another write, or with the kernel's reason.

      Parameters

      • bytes: Buffer

      Returns Promise<void>

    • Returns the bits one character takes on the wire: a start bit, eight data bits, the parity bit if there is one, and the stop bits.

      Parameters

      Returns number

    • Opens the kernel's serial device raw: /dev/serial0 for a Raspberry Pi's own UART, /dev/ttyUSB0 or /dev/ttyACM0 for a USB adapter. Throws anywhere but Linux, for a speed that is not a standard rate from 1200 to 921600, and when the device cannot be opened.

      Parameters

      Returns SerialPort

    • Returns how long bytes sent back to back take on the wire, in microseconds, rounded up.

      Parameters

      Returns number