import { ProgramIniConfig } from "@v5x/serial";
const config = new ProgramIniConfig();
config.baseName = "slot_1";
config.program.name = "Robot";
config.program.slot = 0;
config.autorun = true;
const binary = new Uint8Array(
await fetch("/robot.bin").then((res) => res.arrayBuffer()),
);
const uploaded = await device.brain.uploadProgram(
config,
binary,
undefined,
(state, current, total) => console.log(state, current, total),
);
if (uploaded.isErr()) throw uploaded.error;
if (!uploaded.value) throw new Error("Upload was not acknowledged");