UNPKG

stk500-esm

Version:

A modern, ESM-compatible, TypeScript implementation of the STK500v1 protocol for programming Arduino boards directly from Node.js or the browser.

25 lines (24 loc) 1.03 kB
import type { Duplex } from "node:stream"; /** * Options for sending a command to the device. */ interface SendCommandOptions { /** The command to send, as a Uint8Array or array of numbers. */ cmd: Uint8Array | number[]; /** The timeout duration in milliseconds (optional). */ timeout?: number; /** The expected response data (optional). */ responseData?: Uint8Array; /** The expected length of the response (optional). */ responseLength?: number; } /** * Sends a command to the device and waits for a response. * * @param stream - The read/write stream for communication with the device. * @param opt - Options for the command, including the command itself and response expectations. * @returns A promise that resolves with the response data as a Uint8Array. * @throws Will throw an error if sending fails, if the response doesn't match expectations, or if a timeout occurs. */ export default function sendCommand(stream: Duplex, opt: SendCommandOptions): Promise<Uint8Array>; export {};