stk500-esm
Version:
A modern, ESM-compatible, TypeScript implementation of the STK500v1 protocol for programming Arduino boards directly from Node.js or the browser.
12 lines (11 loc) • 623 B
TypeScript
import type { Duplex } from "node:stream";
/**
* Receives data from a stream, looking for specific starting bytes.
*
* @param stream - The read/write stream to receive data from.
* @param timeout - The maximum time to wait for data, in milliseconds.
* @param responseLength - The expected length of the response.
* @returns A promise that resolves with the received data as a Uint8Array.
* @throws Will throw an error if the timeout is reached or if the received data exceeds the expected length.
*/
export default function receiveData(stream: Duplex, timeout: number, responseLength: number): Promise<Uint8Array>;