Skip to content

Commit

Permalink
Automatically detect upload port using VID:PID board settings // Resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Jun 8, 2015
1 parent 3b7ad2d commit f868c64
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Release History
2.1.1 (2015-??-??)
------------------

* Automatically detect upload port using VID:PID board settings
(`issue #231 <https://github.com/platformio/platformio/issues/231>`_)
* Improved detection of build changes
* Avoided ``LibInstallDependencyError`` when more then 1 library is found
(`issue #229 <https://github.com/platformio/platformio/issues/229>`_)
Expand Down
2 changes: 1 addition & 1 deletion platformio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.

VERSION = (2, 1, "1.dev3")
VERSION = (2, 1, "1.dev4")
__version__ = ".".join([str(s) for s in VERSION])

__title__ = "platformio"
Expand Down
15 changes: 11 additions & 4 deletions platformio/builder/tools/pioupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,25 @@ def AutodetectUploadPort(env):
if (not item['name'] or
not any([l in item['name'].lower() for l in msdlabels])):
continue
print "Auto-detected UPLOAD_PORT/DISK: %s" % item['disk']
env.Replace(UPLOAD_PORT=item['disk'])
break
else:
board_build_opts = env.get("BOARD_OPTIONS", {}).get("build", {})
board_hwid = ("%s:%s" % (
board_build_opts.get("vid"),
board_build_opts.get("pid")
)).replace("0x", "")

for item in get_serialports():
if "VID:PID" not in item['hwid']:
continue
print "Auto-detected UPLOAD_PORT: %s" % item['port']
env.Replace(UPLOAD_PORT=item['port'])
break
if board_hwid in item['hwid']:
break

if "UPLOAD_PORT" not in env:
if "UPLOAD_PORT" in env:
print "Auto-detected UPLOAD_PORT/DISK: %s" % env['UPLOAD_PORT']
else:
Exit("Error: Please specify `upload_port` for environment or use "
"global `--upload-port` option.\n"
"For the some development platforms it can be USB flash drive\n")
Expand Down

0 comments on commit f868c64

Please sign in to comment.