forked from platformio/platformio-core
Automatic detection of port on upload (resolve #15)
This commit is contained in:
@ -5,6 +5,7 @@ Release History
|
|||||||
---------
|
---------
|
||||||
|
|
||||||
* Fixed bug with order for includes in conversation from INO/PDE to CPP
|
* Fixed bug with order for includes in conversation from INO/PDE to CPP
|
||||||
|
* Automatic detection of port on upload (`issue #15 <https://github.com/ivankravets/platformio/issues/15>`_)
|
||||||
|
|
||||||
|
|
||||||
0.7.0 (2014-09-24)
|
0.7.0 (2014-09-24)
|
||||||
|
@ -11,7 +11,7 @@ from time import sleep
|
|||||||
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
|
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
|
||||||
DefaultEnvironment, Exit)
|
DefaultEnvironment, Exit)
|
||||||
|
|
||||||
from platformio.util import reset_serialport
|
from platformio.util import get_serialports, reset_serialport
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
@ -164,9 +164,19 @@ AlwaysBuild(uploadeep)
|
|||||||
|
|
||||||
is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) &
|
is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) &
|
||||||
set(COMMAND_LINE_TARGETS))
|
set(COMMAND_LINE_TARGETS))
|
||||||
if is_uptarget and not env.subst("$UPLOAD_PORT"):
|
|
||||||
Exit("Please specify environment 'upload_port' or use global "
|
if is_uptarget:
|
||||||
"--upload-port option.")
|
# try autodetect upload port
|
||||||
|
if "UPLOAD_PORT" not in env:
|
||||||
|
for item in get_serialports():
|
||||||
|
if "VID:PID" in item['hwid']:
|
||||||
|
print ("Auto-detected UPLOAD_PORT: %s" % item['port'])
|
||||||
|
env['UPLOAD_PORT'] = item['port']
|
||||||
|
break
|
||||||
|
|
||||||
|
if "UPLOAD_PORT" not in env:
|
||||||
|
Exit("Please specify environment 'upload_port' or use global "
|
||||||
|
"--upload-port option.")
|
||||||
|
|
||||||
#
|
#
|
||||||
# Setup default targets
|
# Setup default targets
|
||||||
|
Reference in New Issue
Block a user