Skip to content

Commit

Permalink
Automatic detection of port on upload (resolve #15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Oct 3, 2014
1 parent 1c4b97c commit 024be2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release History
---------

* 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)
Expand Down
18 changes: 14 additions & 4 deletions platformio/builder/scripts/atmelavr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
DefaultEnvironment, Exit)

from platformio.util import reset_serialport
from platformio.util import get_serialports, reset_serialport

env = DefaultEnvironment()

Expand Down Expand Up @@ -164,9 +164,19 @@ def rpi_sysgpio(path, value):

is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) &
set(COMMAND_LINE_TARGETS))
if is_uptarget and not env.subst("$UPLOAD_PORT"):
Exit("Please specify environment 'upload_port' or use global "
"--upload-port option.")

if is_uptarget:
# 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
Expand Down

0 comments on commit 024be2e

Please sign in to comment.