switching to faster comms

node_mode
Jake 2025-09-28 22:05:51 +08:00
parent 84d24d93a2
commit bcb240773d
1 changed files with 54 additions and 48 deletions

View File

@ -235,7 +235,9 @@ window.onload = () => {
const header = [0xAA, 0x55]; const header = [0xAA, 0x55];
const length = payload.length; const length = payload.length;
const message = [...header, commandCode, length, ...payload]; const lengthHigh = (length >> 8) & 0xFF;
const lengthLow = length & 0xFF;
const message = [...header, commandCode, lengthHigh, lengthLow, ...payload];
const writer = port.writable.getWriter(); const writer = port.writable.getWriter();
await writer.write(new Uint8Array(message)); await writer.write(new Uint8Array(message));
@ -426,8 +428,12 @@ window.onload = () => {
writer.releaseLock(); writer.releaseLock();
console.log(`Sent chunk: ${filename} offset=${offset} size=${chunkData.length}`); console.log(`Sent chunk: ${filename} offset=${offset} size=${chunkData.length}`);
console.log(packet);
}
console.log("Total animation size:", totalSize);
} }
}
function waitForOkResponse(timeoutMs = 1000) { function waitForOkResponse(timeoutMs = 1000) {
@ -443,7 +449,7 @@ window.onload = () => {
resolve(true); resolve(true);
}); });
}); });
} }