From 93e0bf890295387e8d8d72ae7a0e551a8a84d018 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Fri, 8 May 2020 11:21:27 +0200 Subject: [PATCH] hub: check response to size message The hub responds to every message with a checksum. The mpy size message is no different, so we need to read it. This fixes the checksum messages being out of sync by one. --- src/actions/hub.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/actions/hub.ts b/src/actions/hub.ts index 1fc80b8b..c6fc209e 100644 --- a/src/actions/hub.ts +++ b/src/actions/hub.ts @@ -57,10 +57,12 @@ export function downloadAndRun(data: ArrayBuffer): HubThunkAction { // TODO: might need to flush checksum queue here // first send payload size as big-endian 32-bit integer + const size_checksum = getChecksum(); const sizeBuf = new Uint8Array(4); const sizeView = new DataView(sizeBuf.buffer); sizeView.setUint32(0, data.byteLength, true); await dispatch(write(sizeBuf)); + console.log(await size_checksum); // Then send payload in 100 byte chunks waiting for checksum after // each chunk