Skip to content

Commit

Permalink
WIP, more progress on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
jLynx committed Jan 31, 2024
1 parent d8f57ee commit 156bfbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/components/SerialProvider/SerialProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,18 @@ 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 = 350;
let blob = new Blob([data]);
const arrayBuffer = await blob.arrayBuffer();
const chunkSize = 60;

// 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));
// }
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}`);
}
writer.releaseLock();

setMessageQueue((prevQueue) => prevQueue.slice(1)); // Remove the message we just wrote from the queue
Expand Down
2 changes: 1 addition & 1 deletion src/utils/serialUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const useWriteCommand = () => {
let blob = new Blob([bytes]);
const arrayBuffer = await blob.arrayBuffer();

const chunkSize = 100000;
const chunkSize = 9000;

console.log("Total length: ", arrayBuffer.byteLength);

Expand Down

0 comments on commit 156bfbe

Please sign in to comment.