Verify that serial port is ready for connection before uploading

This commit is contained in:
Ivan Kravets
2017-05-30 14:06:25 +03:00
parent f6a3d9f474
commit 198dadc209

View File

@ -23,7 +23,7 @@ from shutil import copyfile
from time import sleep
from SCons.Node.Alias import Alias
from serial import Serial
from serial import Serial, SerialException
from platformio import util
@ -72,6 +72,11 @@ def WaitForNewSerialPort(env, before):
new_port = p['port']
break
try:
Serial(new_port)
except SerialException:
sleep(1)
if not new_port:
sys.stderr.write("Error: Couldn't find a board on the selected port. "
"Check that you have the correct port selected. "