1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 15:48:05 +11:00

Fix broken uploadb.py

putc didn't work well with any byte value on most terminal configuration. It
was a bad idea...
This commit is contained in:
Virgil Dupras 2019-12-02 22:57:22 -05:00
parent 270ad926c9
commit 30a0f69101

View File

@ -47,14 +47,26 @@ def main():
for i, c in enumerate(fcontents):
c = bytes([c])
sendcmd(fd, 'getc')
os.write(fd, c)
os.read(fd, 2) # read prompt
sendcmd(fd, 'putc a')
r = os.read(fd, 1) # putc result
os.read(fd, 2) # read prompt
if r != c:
print(f"Mismatch at byte {i}! {c} != {r}")
print('.', end='', flush=True)
for _ in range(5): # try 5 times
sendcmd(fd, 'getc')
os.write(fd, c)
os.read(fd, 2) # read prompt
sendcmd(fd, 'print a')
s = b''
while True:
r = os.read(fd, 1) # putc result
if not r.isdigit():
break
s += r
os.read(fd, 3) # read prompt
if int(s) == c[0]:
break
else:
print(f"Mismatch at byte {i}! {c} != {r}. Retrying")
else:
print("Maximum retries reached, abort")
return 1
sendcmd(fd, 'poke m a')
os.read(fd, 2) # read prompt
sendcmd(fd, 'm=m+1')