This commit is contained in:
2026-03-07 08:51:50 +01:00
parent 4f3fbff258
commit f85143d7e5
60 changed files with 3245 additions and 1205 deletions

View File

@@ -0,0 +1,31 @@
import { bus } from '../../bus/SerialBus';
import { Command, FrameType } from '../constants';
export class PlayFileCommand {
async execute(path: string): Promise<boolean | null> {
try {
const p = new TextEncoder().encode(path);
// Wir brauchen: 1 Byte Flags + 1 Byte Länge + Pfad
const req = new Uint8Array(p.length + 2);
req[0] = 0x01; // 1. Byte: Flags (LSB: 1 = sofort abspielen)
req[1] = p.length; // 2. Byte: Länge für get_path() im C-Code
req.set(p, 2); // Ab 3. Byte: Der Pfad-String
await bus.sendRequest(Command.PLAY, req);
// Warten auf das ACK vom Board
if (await bus.waitForSync()) {
const typeArr = await bus.readExact(1);
if (typeArr[0] === FrameType.ACK) {
return true;
}
}
} catch (e) {
console.error("PlayFileCommand failed:", e);
} finally {
bus.releaseReadLock();
}
return null;
}
}