mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 12:08:07 +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:
parent
270ad926c9
commit
30a0f69101
@ -47,14 +47,26 @@ def main():
|
|||||||
|
|
||||||
for i, c in enumerate(fcontents):
|
for i, c in enumerate(fcontents):
|
||||||
c = bytes([c])
|
c = bytes([c])
|
||||||
sendcmd(fd, 'getc')
|
print('.', end='', flush=True)
|
||||||
os.write(fd, c)
|
for _ in range(5): # try 5 times
|
||||||
os.read(fd, 2) # read prompt
|
sendcmd(fd, 'getc')
|
||||||
sendcmd(fd, 'putc a')
|
os.write(fd, c)
|
||||||
r = os.read(fd, 1) # putc result
|
os.read(fd, 2) # read prompt
|
||||||
os.read(fd, 2) # read prompt
|
sendcmd(fd, 'print a')
|
||||||
if r != c:
|
s = b''
|
||||||
print(f"Mismatch at byte {i}! {c} != {r}")
|
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')
|
sendcmd(fd, 'poke m a')
|
||||||
os.read(fd, 2) # read prompt
|
os.read(fd, 2) # read prompt
|
||||||
sendcmd(fd, 'm=m+1')
|
sendcmd(fd, 'm=m+1')
|
||||||
|
Loading…
Reference in New Issue
Block a user