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])
|
||||||
|
print('.', end='', flush=True)
|
||||||
|
for _ in range(5): # try 5 times
|
||||||
sendcmd(fd, 'getc')
|
sendcmd(fd, 'getc')
|
||||||
os.write(fd, c)
|
os.write(fd, c)
|
||||||
os.read(fd, 2) # read prompt
|
os.read(fd, 2) # read prompt
|
||||||
sendcmd(fd, 'putc a')
|
sendcmd(fd, 'print a')
|
||||||
|
s = b''
|
||||||
|
while True:
|
||||||
r = os.read(fd, 1) # putc result
|
r = os.read(fd, 1) # putc result
|
||||||
os.read(fd, 2) # read prompt
|
if not r.isdigit():
|
||||||
if r != c:
|
break
|
||||||
print(f"Mismatch at byte {i}! {c} != {r}")
|
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