From d4ffc38d97531ebfe2fe3f91585e62080f562486 Mon Sep 17 00:00:00 2001 From: jLynx Date: Wed, 31 Jan 2024 23:05:20 +1300 Subject: [PATCH] Revert "WIP, more progress on mac" This reverts commit 156bfbe114fb046ef5bd8d9a94642058a539ae85. --- .../SerialProvider/SerialProvider.tsx | 19 +++++++++---------- src/utils/serialUtils.tsx | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/SerialProvider/SerialProvider.tsx b/src/components/SerialProvider/SerialProvider.tsx index 8a54f88..5df5cc5 100644 --- a/src/components/SerialProvider/SerialProvider.tsx +++ b/src/components/SerialProvider/SerialProvider.tsx @@ -386,18 +386,17 @@ const useWebSerial = ({ if (writer) { try { // Once speed is fixed, this can be swapped in for the loop below - // await writer.write(data); + await writer.write(data); - let blob = new Blob([data]); - const arrayBuffer = await blob.arrayBuffer(); - const chunkSize = 60; + // let blob = new Blob([data]); + // const arrayBuffer = await blob.arrayBuffer(); + // const chunkSize = 350; - for (let i = 0; i < arrayBuffer.byteLength; i += chunkSize) { - const chunk = arrayBuffer.slice(i, i + chunkSize); - await delay(5); - await writer.write(new Uint8Array(chunk)); - console.log("CHUNK:", `${i}/${arrayBuffer.byteLength}`); - } + // for (let i = 0; i < arrayBuffer.byteLength; i += chunkSize) { + // const chunk = arrayBuffer.slice(i, i + chunkSize); + // await delay(5); + // await writer.write(new Uint8Array(chunk)); + // } writer.releaseLock(); setMessageQueue((prevQueue) => prevQueue.slice(1)); // Remove the message we just wrote from the queue diff --git a/src/utils/serialUtils.tsx b/src/utils/serialUtils.tsx index cfe5d4e..42d5787 100644 --- a/src/utils/serialUtils.tsx +++ b/src/utils/serialUtils.tsx @@ -93,7 +93,7 @@ export const useWriteCommand = () => { let blob = new Blob([bytes]); const arrayBuffer = await blob.arrayBuffer(); - const chunkSize = 9000; + const chunkSize = 100000; console.log("Total length: ", arrayBuffer.byteLength);