Skip to content

Commit 9867c34

Browse files
use serial buffer for initialization messages when uploading games (#2062)
fix upload not working - use serial buffer Co-authored-by: fayd <[email protected]>
1 parent afa02a6 commit 9867c34

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/lib/upload.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,20 @@ export const getIsLegacySerial = async (
128128
await writer.ready
129129
await writer.write(new Uint8Array([ 0, 1, 2, 3, 4 ]).buffer)
130130

131+
// 128-char buffer
132+
let serialBuffer = " ".repeat(128)
133+
131134
while (true) {
132135
const { value, done } = await reader.read()
136+
133137
if (done) return null
134138
logSerialOutput(value)
135139

136-
if (value.indexOf('found startup seq!') >= 0) return true
137-
if (value.indexOf('legacy detected') >= 0) return false
140+
serialBuffer = serialBuffer.concat(value)
141+
serialBuffer = serialBuffer.slice(serialBuffer.length - 128, serialBuffer.length)
142+
143+
if (serialBuffer.indexOf('found startup seq!') >= 0) return true
144+
if (serialBuffer.indexOf('legacy detected') >= 0) return false
138145
}
139146
}
140147

0 commit comments

Comments
 (0)