import { FileDownloadTarget, FileVendor } from "@v5x/serial";
const files = await device.brain.listFiles(FileVendor.USER);
if (files.isErr()) throw files.error;
const data = await device.brain.readFile("slot_1.ini");
if (data.isErr()) throw data.error;
const written = await device.brain.writeFile({
filename: "example.txt",
vendor: FileVendor.USER,
downloadTarget: FileDownloadTarget.FILE_TARGET_QSPI,
buf: new TextEncoder().encode("hello"),
autoRun: false,
});
if (written.isErr()) throw written.error;
if (!written.value) throw new Error("Write was not acknowledged");
console.log(files.value, new TextDecoder().decode(data.value));
removeFile("example.txt"). removeAllFiles() clears the user vendor.
File removal is destructive. Stay out of the system and firmware vendors
unless you know exactly what the operation does.