[OTA] Fix "Error response from device" if OK response comes to early (#1695)
Because TCP is stream-based, an earlier read can 'take away' the "OK" response from the device, so that a later read doesn't get the message.
This commit is contained in:
parent
a7ddf39521
commit
bdc45e39ef
@ -179,6 +179,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
|
|||||||
try:
|
try:
|
||||||
connection.sendall(chunk)
|
connection.sendall(chunk)
|
||||||
res = connection.recv(10)
|
res = connection.recv(10)
|
||||||
|
lastResponseContainedOK = 'OK' in res.decode()
|
||||||
except:
|
except:
|
||||||
sys.stderr.write('\n')
|
sys.stderr.write('\n')
|
||||||
logging.error('Error Uploading')
|
logging.error('Error Uploading')
|
||||||
@ -187,6 +188,13 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
|
|||||||
sock.close()
|
sock.close()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
if lastResponseContainedOK:
|
||||||
|
logging.info('Success')
|
||||||
|
connection.close()
|
||||||
|
f.close()
|
||||||
|
sock.close()
|
||||||
|
return 0
|
||||||
|
|
||||||
sys.stderr.write('\n')
|
sys.stderr.write('\n')
|
||||||
logging.info('Waiting for result...')
|
logging.info('Waiting for result...')
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user