diff --git a/HISTORY.rst b/HISTORY.rst index c1efa30c..0f81ad63 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,8 @@ Release History 2.1.1 (2015-??-??) ------------------ +* Automatically detect upload port using VID:PID board settings + (`issue #231 `_) * Improved detection of build changes * Avoided ``LibInstallDependencyError`` when more then 1 library is found (`issue #229 `_) diff --git a/platformio/__init__.py b/platformio/__init__.py index e3c0b661..128fd088 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 1, "1.dev3") +VERSION = (2, 1, "1.dev4") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index 4dd2f3d1..1cc75a53 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -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")