serload: add exit command, correctly parse prompt after command
This commit is contained in:
parent
7751d85765
commit
79baf3cef5
1 changed files with 7 additions and 2 deletions
|
|
@ -78,6 +78,9 @@ def commandwait(ser, cmd):
|
|||
print("timeout sending '{}' command".format(cmd))
|
||||
return None
|
||||
|
||||
if resp.startswith(b"> "):
|
||||
resp = resp[2:]
|
||||
|
||||
if resp != bytearray(cmd + b"\r\n"):
|
||||
print("invalid response to '{}' command".format(cmd))
|
||||
return None
|
||||
|
|
@ -323,7 +326,7 @@ def showdata(ser):
|
|||
promptseen = True
|
||||
else:
|
||||
print(c.decode('utf8'), end='')
|
||||
rest = ser.read(1)
|
||||
rest = ser.read(1) # read trailing space of prompt
|
||||
|
||||
|
||||
def localdir():
|
||||
|
|
@ -360,8 +363,10 @@ def interactive(ser):
|
|||
print("superfluous argument")
|
||||
else:
|
||||
localdir()
|
||||
elif cmd == 'exit' or cmd == 'x':
|
||||
done = True
|
||||
else:
|
||||
print("Unknown command. Valid commands are: dir get ldir put")
|
||||
print("Unknown command. Valid commands are: dir get ldir put exit")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue