Skip to content

Commit 905c69a

Browse files
Update src/js/protocols/WebSerial.js
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3a00a68 commit 905c69a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/js/protocols/WebSerial.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,19 @@ class WebSerial extends EventTarget {
338338
}
339339

340340
async batchWrite(data) {
341+
// AT32 on macOS requires smaller chunks (63 bytes) to work correctly due to
342+
// USB buffer size limitations in the macOS implementation
341343
const batchWriteSize = 63;
342344
let remainingData = data;
343345
while (remainingData.byteLength > batchWriteSize) {
344346
const sliceData = remainingData.slice(0, batchWriteSize);
345347
remainingData = remainingData.slice(batchWriteSize);
346-
await this.writer.write(sliceData);
348+
try {
349+
await this.writer.write(sliceData);
350+
} catch (error) {
351+
console.error(`${this.logHead} Error writing batch chunk:`, error);
352+
throw error; // Re-throw to be caught by the send method
353+
}
347354
}
348355
await this.writer.write(remainingData);
349356
}

0 commit comments

Comments
 (0)